1
0
forked from VimPlug/jedi

Move get_node() to tree_node and replace all the custom classdefs/funcdefs.

This commit is contained in:
Dave Halter
2017-01-05 23:43:12 +01:00
parent b44f0aae5d
commit ae8e43d3c7
24 changed files with 90 additions and 99 deletions

View File

@@ -367,7 +367,8 @@ class BaseDefinition(object):
if isinstance(context, er.FunctionExecutionContext):
# TODO the function context should be a part of the function
# execution context.
context = er.FunctionContext(self._evaluator, context.parent_context, context.funcdef)
context = er.FunctionContext(
self._evaluator, context.parent_context, context.tree_node)
return Definition(self._evaluator, context.name)
def __repr__(self):
@@ -690,7 +691,7 @@ class _Help(object):
if followed:
# TODO: Use all of the followed objects as input to Documentation.
context = next(iter(followed))
return context.get_node()
return context.tree_node
if self._name.tree_name is None:
return None
return self._name.tree_name.get_definition()

View File

@@ -51,7 +51,7 @@ def get_user_scope(module_context, position):
"""
Returns the scope in which the user resides. This includes flows.
"""
user_stmt = module_context.module_node.get_statement_for_position(position)
user_stmt = module_context.tree_node.get_statement_for_position(position)
if user_stmt is None:
def scan(scope):
for s in scope.children:
@@ -62,7 +62,7 @@ def get_user_scope(module_context, position):
return scan(s)
return None
scanned_node = scan(module_context.module_node)
scanned_node = scan(module_context.tree_node)
if scanned_node:
return module_context.create_context(scanned_node, node_is_context=True)
return module_context
@@ -74,7 +74,7 @@ class Completion:
def __init__(self, evaluator, module, code_lines, position, call_signatures_method):
self._evaluator = evaluator
self._module_context = module
self._module_node = module.module_node
self._module_node = module.tree_node
self._code_lines = code_lines
# The first step of completions is to get the name
@@ -197,7 +197,7 @@ class Completion:
debug.dbg('trailer completion contexts: %s', contexts)
for context in contexts:
for filter in context.get_filters(
search_global=False, origin_scope=user_context.get_node()):
search_global=False, origin_scope=user_context.tree_node):
completion_names += filter.values()
return completion_names

View File

@@ -36,7 +36,7 @@ def usages(evaluator, definition_names, mods):
definition_names = set(resolve_names(definition_names))
for m in imports.get_modules_containing_name(evaluator, mods, search_name):
if isinstance(m, ModuleContext):
for name_node in m.module_node.used_names.get(search_name, []):
for name_node in m.tree_node.used_names.get(search_name, []):
context = evaluator.create_context(m, name_node)
result = evaluator.goto(context, name_node)
if [c for c in compare_array(result) if c in compare_definitions]: