forked from VimPlug/jedi
other modules also adapt to the new evaluate_representation now
This commit is contained in:
@@ -14,6 +14,7 @@ import os
|
||||
|
||||
import parsing
|
||||
import parsing_representation as pr
|
||||
import evaluate_representation as er
|
||||
import dynamic
|
||||
import imports
|
||||
import evaluate
|
||||
@@ -103,7 +104,7 @@ class Script(object):
|
||||
completions = []
|
||||
debug.dbg('possible scopes', scopes)
|
||||
for s in scopes:
|
||||
if s.isinstance(evaluate.Function):
|
||||
if s.isinstance(er.Function):
|
||||
names = s.get_magic_method_names()
|
||||
else:
|
||||
if isinstance(s, imports.ImportPath):
|
||||
|
||||
@@ -16,6 +16,7 @@ import settings
|
||||
import evaluate
|
||||
import imports
|
||||
import parsing_representation as pr
|
||||
import evaluate_representation as er
|
||||
import keywords
|
||||
|
||||
|
||||
@@ -65,7 +66,7 @@ class BaseDefinition(object):
|
||||
"""The type of the definition."""
|
||||
# generate the type
|
||||
stripped = self.definition
|
||||
if isinstance(self.definition, evaluate.InstanceElement):
|
||||
if isinstance(self.definition, er.InstanceElement):
|
||||
stripped = self.definition.var
|
||||
return type(stripped).__name__
|
||||
|
||||
@@ -242,7 +243,7 @@ class Completion(BaseDefinition):
|
||||
"""
|
||||
if self._followed_definitions is None:
|
||||
if self.definition.isinstance(pr.Statement):
|
||||
defs = evaluate.follow_statement(self.definition)
|
||||
defs = er.follow_statement(self.definition)
|
||||
elif self.definition.isinstance(pr.Import):
|
||||
defs = imports.strip_imports([self.definition])
|
||||
else:
|
||||
@@ -273,18 +274,18 @@ class Definition(BaseDefinition):
|
||||
in testing. e.g. for ``isinstance`` it returns ``def isinstance``.
|
||||
"""
|
||||
d = self.definition
|
||||
if isinstance(d, evaluate.InstanceElement):
|
||||
if isinstance(d, er.InstanceElement):
|
||||
d = d.var
|
||||
if isinstance(d, pr.Name):
|
||||
d = d.parent
|
||||
|
||||
if isinstance(d, evaluate.Array):
|
||||
if isinstance(d, er.Array):
|
||||
d = 'class ' + d.type
|
||||
elif isinstance(d, (pr.Class, evaluate.Class, evaluate.Instance)):
|
||||
elif isinstance(d, (pr.Class, er.Class, er.Instance)):
|
||||
d = 'class ' + unicode(d.name)
|
||||
elif isinstance(d, (evaluate.Function, pr.Function)):
|
||||
elif isinstance(d, (er.Function, pr.Function)):
|
||||
d = 'def ' + unicode(d.name)
|
||||
elif isinstance(d, evaluate.pr.Module):
|
||||
elif isinstance(d, pr.Module):
|
||||
# only show module name
|
||||
d = 'module %s' % self.module_name
|
||||
elif self.is_keyword:
|
||||
@@ -344,8 +345,8 @@ class CallDef(object):
|
||||
|
||||
@property
|
||||
def params(self):
|
||||
if self.executable.isinstance(evaluate.Function):
|
||||
if isinstance(self.executable, evaluate.InstanceElement):
|
||||
if self.executable.isinstance(er.Function):
|
||||
if isinstance(self.executable, er.InstanceElement):
|
||||
return self.executable.params[1:]
|
||||
return self.executable.params
|
||||
else:
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import re
|
||||
|
||||
import evaluate
|
||||
import evaluate_representation as er
|
||||
import parsing
|
||||
import parsing_representation as pr
|
||||
|
||||
DOCSTRING_PARAM_PATTERNS = [
|
||||
r'\s*:type\s+%s:\s*([^\n]+)', # Sphinx
|
||||
@@ -89,10 +89,10 @@ def strip_rest_role(type_str):
|
||||
|
||||
|
||||
def find_return_types(func):
|
||||
if isinstance(func, evaluate.InstanceElement):
|
||||
if isinstance(func, er.InstanceElement):
|
||||
func = func.var
|
||||
|
||||
if isinstance(func, evaluate.Function):
|
||||
if isinstance(func, er.Function):
|
||||
func = func.base_func
|
||||
|
||||
type_str = search_return_in_docstr(func.docstr)
|
||||
@@ -101,7 +101,7 @@ def find_return_types(func):
|
||||
|
||||
p = parsing.Parser(type_str, None, (1, 0), no_docstr=True)
|
||||
p.user_stmt.parent = func
|
||||
return list(evaluate.follow_statement(p.user_stmt))
|
||||
return list(er.follow_statement(p.user_stmt))
|
||||
|
||||
def search_return_in_docstr(code):
|
||||
for p in DOCSTRING_RETURN_PATTERNS:
|
||||
|
||||
@@ -11,6 +11,7 @@ import os
|
||||
|
||||
import cache
|
||||
import parsing_representation as pr
|
||||
import evaluate_representation as er
|
||||
import modules
|
||||
import evaluate
|
||||
import helpers
|
||||
@@ -255,13 +256,13 @@ def _check_array_additions(compare_array, module, is_list):
|
||||
|
||||
def get_execution_parent(element, *stop_classes):
|
||||
""" Used to get an Instance/Execution parent """
|
||||
if isinstance(element, evaluate.Array):
|
||||
if isinstance(element, er.Array):
|
||||
stmt = element._array.parent_stmt
|
||||
else:
|
||||
# must be instance
|
||||
stmt = element.var_args.parent_stmt
|
||||
if isinstance(stmt, evaluate.InstanceElement):
|
||||
stop_classes = list(stop_classes) + [evaluate.Function]
|
||||
if isinstance(stmt, er.InstanceElement):
|
||||
stop_classes = list(stop_classes) + [er.Function]
|
||||
return stmt.get_parent_until(stop_classes)
|
||||
|
||||
temp_param_add = settings.dynamic_params_for_other_modules
|
||||
@@ -269,7 +270,7 @@ def _check_array_additions(compare_array, module, is_list):
|
||||
|
||||
search_names = ['append', 'extend', 'insert'] if is_list else \
|
||||
['add', 'update']
|
||||
comp_arr_parent = get_execution_parent(compare_array, evaluate.Execution)
|
||||
comp_arr_parent = get_execution_parent(compare_array, er.Execution)
|
||||
possible_stmts = []
|
||||
res = []
|
||||
for n in search_names:
|
||||
@@ -282,15 +283,15 @@ def _check_array_additions(compare_array, module, is_list):
|
||||
# can search for the same statement, that is in the module
|
||||
# dict. Executions are somewhat special in jedi, since they
|
||||
# literally copy the contents of a function.
|
||||
if isinstance(comp_arr_parent, evaluate.Execution):
|
||||
if isinstance(comp_arr_parent, er.Execution):
|
||||
stmt = comp_arr_parent. \
|
||||
get_statement_for_position(stmt.start_pos)
|
||||
if stmt is None:
|
||||
continue
|
||||
# InstanceElements are special, because they don't get copied,
|
||||
# but have this wrapper around them.
|
||||
if isinstance(comp_arr_parent, evaluate.InstanceElement):
|
||||
stmt = evaluate.InstanceElement(comp_arr_parent.instance, stmt)
|
||||
if isinstance(comp_arr_parent, er.InstanceElement):
|
||||
stmt = er.InstanceElement(comp_arr_parent.instance, stmt)
|
||||
|
||||
if evaluate.follow_statement.push_stmt(stmt):
|
||||
# check recursion
|
||||
@@ -327,7 +328,7 @@ class ArrayInstance(pr.Base):
|
||||
"""
|
||||
items = []
|
||||
for array in evaluate.follow_call_list(self.var_args):
|
||||
if isinstance(array, evaluate.Instance) and len(array.var_args):
|
||||
if isinstance(array, er.Instance) and len(array.var_args):
|
||||
temp = array.var_args[0][0]
|
||||
if isinstance(temp, ArrayInstance):
|
||||
# prevent recursions
|
||||
@@ -474,12 +475,12 @@ def check_statement_information(stmt, search_name):
|
||||
assert isinstance(classes_call, pr.Call)
|
||||
result = []
|
||||
for c in evaluate.follow_call(classes_call):
|
||||
if isinstance(c, evaluate.Array):
|
||||
if isinstance(c, er.Array):
|
||||
result += c.get_index_types()
|
||||
else:
|
||||
result.append(c)
|
||||
for i, c in enumerate(result):
|
||||
result[i] = evaluate.Instance(c)
|
||||
result[i] = er.Instance(c)
|
||||
return result
|
||||
except AssertionError:
|
||||
return []
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import copy
|
||||
|
||||
import parsing_representation as pr
|
||||
import evaluate
|
||||
import evaluate_representation as er
|
||||
import debug
|
||||
import builtin
|
||||
import settings
|
||||
@@ -119,7 +119,7 @@ class ExecutionRecursionDecorator(object):
|
||||
if cls.execution_count > settings.max_executions:
|
||||
return True
|
||||
|
||||
if isinstance(execution.base, (evaluate.Generator, evaluate.Array)):
|
||||
if isinstance(execution.base, (er.Generator, er.Array)):
|
||||
return False
|
||||
module = execution.get_parent_until()
|
||||
if evaluate_generator or module == builtin.Builtin.scope:
|
||||
|
||||
Reference in New Issue
Block a user