forked from VimPlug/jedi
static analysis prototype decription
This commit is contained in:
@@ -92,6 +92,7 @@ class Evaluator(object):
|
|||||||
self.compiled_cache = {} # see `compiled.create()`
|
self.compiled_cache = {} # see `compiled.create()`
|
||||||
self.recursion_detector = recursion.RecursionDetector()
|
self.recursion_detector = recursion.RecursionDetector()
|
||||||
self.execution_recursion_detector = recursion.ExecutionRecursionDetector()
|
self.execution_recursion_detector = recursion.ExecutionRecursionDetector()
|
||||||
|
self.analysis = []
|
||||||
|
|
||||||
def find_types(self, scope, name_str, position=None, search_global=False,
|
def find_types(self, scope, name_str, position=None, search_global=False,
|
||||||
is_goto=False, resolve_decorator=True):
|
is_goto=False, resolve_decorator=True):
|
||||||
|
|||||||
43
jedi/evaluate/analysis.py
Normal file
43
jedi/evaluate/analysis.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
"""
|
||||||
|
Module for statical analysis.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from jedi import debug
|
||||||
|
|
||||||
|
|
||||||
|
CODES = {
|
||||||
|
'inaccesible': (1, 'Attribute is not accessible.'),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Error(object):
|
||||||
|
def __init__(self, name, start_pos):
|
||||||
|
self._start_pos = start_pos
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def line(self):
|
||||||
|
return self._start_pos[0]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def column(self):
|
||||||
|
return self._start_pos[1]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def code(self):
|
||||||
|
# The class name start
|
||||||
|
first = self.__class__.__name__[0]
|
||||||
|
return first + str(CODES[self.name][0])
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return '%s: %s' % (self.code, self.line)
|
||||||
|
|
||||||
|
|
||||||
|
class Warning(Error):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def add(evaluator, code, typ=Error):
|
||||||
|
instance = typ()
|
||||||
|
debug.warning(str(Error))
|
||||||
|
evaluator.analysis.append(instance)
|
||||||
Reference in New Issue
Block a user