forked from VimPlug/jedi
Starting to replace the old API code for static analysis.
This commit is contained in:
@@ -534,6 +534,22 @@ class Script(object):
|
||||
else:
|
||||
check_types(f())
|
||||
|
||||
for node in self._parser.module().nodes_to_execute():
|
||||
if node.type in ('funcdef', 'classdef'):
|
||||
if node.type == 'classdef':
|
||||
continue
|
||||
raise NotImplementedError
|
||||
er.Function(self._evaluator, node).get_decorated_func()
|
||||
elif isinstance(node, tree.Import):
|
||||
import_names = set(node.get_defined_names())
|
||||
if node.is_nested():
|
||||
import_names |= set(path[-1] for path in node.paths())
|
||||
for n in import_names:
|
||||
imports.ImportWrapper(self._evaluator, n).follow()
|
||||
else:
|
||||
check_types(self._evaluator.eval_element(node))
|
||||
|
||||
"""
|
||||
#statements = set(chain(*self._parser.module().used_names.values()))
|
||||
nodes, imp_names, decorated_funcs = \
|
||||
analysis.get_executable_nodes(self._parser.module())
|
||||
@@ -545,6 +561,7 @@ class Script(object):
|
||||
|
||||
for dec_func in decorated_funcs:
|
||||
er.Function(self._evaluator, dec_func).get_decorated_func()
|
||||
"""
|
||||
|
||||
ana = [a for a in self._evaluator.analysis if self.path == a.path]
|
||||
return sorted(set(ana), key=lambda x: x.line)
|
||||
|
||||
@@ -337,7 +337,8 @@ class Name(Leaf):
|
||||
return indexes
|
||||
|
||||
def nodes_to_execute(self, last_added=False):
|
||||
yield self
|
||||
if last_added is False:
|
||||
yield self
|
||||
|
||||
|
||||
class Literal(LeafWithNewLines):
|
||||
@@ -509,6 +510,7 @@ class Node(BaseNode):
|
||||
result = []
|
||||
if self.type not in Node._IGNORE_EXECUTE_NODES:
|
||||
result.append(self)
|
||||
last_added = True
|
||||
|
||||
for child in self.children:
|
||||
result += child.nodes_to_execute(last_added)
|
||||
@@ -742,7 +744,7 @@ class Class(ClassOrFunc):
|
||||
def nodes_to_execute(self, last_added=False):
|
||||
# Yield itself, class needs to be executed for decorator checks.
|
||||
yield self
|
||||
for param in self.params:
|
||||
for param in self.get_super_arglist:
|
||||
if param.default is None:
|
||||
yield param.default
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user