forked from VimPlug/jedi
Remove a lot of the old Name.names usages in favor of a direct NamePart usage.
This commit is contained in:
@@ -433,7 +433,7 @@ class Script(object):
|
||||
and d.start_pos == (0, 0):
|
||||
i = imports.ImportWrapper(self._evaluator, d.parent).follow(is_goto=True)
|
||||
definitions.remove(d)
|
||||
definitions |= follow_inexistent_imports(i.names[-1])
|
||||
definitions |= follow_inexistent_imports(i)
|
||||
return definitions
|
||||
|
||||
goto_path = self._user_context.get_path_under_cursor()
|
||||
@@ -468,7 +468,7 @@ class Script(object):
|
||||
if add_import_name:
|
||||
import_name = user_stmt.get_defined_names()
|
||||
# imports have only one name
|
||||
np = import_name[0].names[-1]
|
||||
np = import_name[0]
|
||||
if not user_stmt.star and unicode(name_part) == unicode(np):
|
||||
definitions.append(np)
|
||||
else:
|
||||
@@ -573,7 +573,7 @@ class Script(object):
|
||||
key_name = unicode(detail[0][0].name)
|
||||
except (IndexError, AttributeError):
|
||||
pass
|
||||
return [classes.CallSignature(self._evaluator, o.name.names[-1], call, index, key_name)
|
||||
return [classes.CallSignature(self._evaluator, o.name, call, index, key_name)
|
||||
for o in origins if hasattr(o, 'py__call__')]
|
||||
|
||||
def _analysis(self):
|
||||
@@ -584,7 +584,7 @@ class Script(object):
|
||||
iw = imports.ImportWrapper(self._evaluator, i,
|
||||
nested_resolve=True).follow()
|
||||
if i.is_nested() and any(not isinstance(i, pr.Module) for i in iw):
|
||||
analysis.add(self._evaluator, 'import-error', i.namespace.names[-1])
|
||||
analysis.add(self._evaluator, 'import-error', i.namespace_names[-1])
|
||||
for stmt in sorted(stmts, key=lambda obj: obj.start_pos):
|
||||
if not (isinstance(stmt.parent, pr.ForFlow)
|
||||
and stmt.parent.set_stmt == stmt):
|
||||
|
||||
@@ -37,7 +37,7 @@ def defined_names(evaluator, scope):
|
||||
include_builtin=False), None)
|
||||
names = pair[1] if pair else []
|
||||
names = [n for n in names if isinstance(n, pr.Import) or (len(n) == 1)]
|
||||
return [Definition(evaluator, d.names[-1]) for d in sorted(names, key=lambda s: s.start_pos)]
|
||||
return [Definition(evaluator, d) for d in sorted(names, key=lambda s: s.start_pos)]
|
||||
|
||||
|
||||
class BaseDefinition(object):
|
||||
@@ -176,8 +176,8 @@ class BaseDefinition(object):
|
||||
par = self._definition
|
||||
while par is not None:
|
||||
if isinstance(par, pr.Import):
|
||||
insert_nonnone(par.namespace)
|
||||
insert_nonnone(par.from_ns)
|
||||
insert_nonnone(par.namespace_names)
|
||||
insert_nonnone(par.from_names)
|
||||
if par.relative_count == 0:
|
||||
break
|
||||
with common.ignored(AttributeError):
|
||||
@@ -376,12 +376,12 @@ class BaseDefinition(object):
|
||||
params = sub.params[1:] # ignore self
|
||||
except KeyError:
|
||||
return []
|
||||
return [_Param(self._evaluator, p.get_name().names[-1]) for p in params]
|
||||
return [_Param(self._evaluator, p.get_name()) for p in params]
|
||||
|
||||
def parent(self):
|
||||
scope = self._definition.get_parent_scope()
|
||||
non_flow = scope.get_parent_until(pr.Flow, reverse=True)
|
||||
return Definition(self._evaluator, non_flow.name.names[-1])
|
||||
return Definition(self._evaluator, non_flow.name)
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s %s>" % (type(self).__name__, self.description)
|
||||
@@ -539,7 +539,7 @@ class Completion(BaseDefinition):
|
||||
it's just PITA-slow.
|
||||
"""
|
||||
defs = self._follow_statements_imports()
|
||||
return [Definition(self._evaluator, d.name.names[-1]) for d in defs]
|
||||
return [Definition(self._evaluator, d.name) for d in defs]
|
||||
|
||||
|
||||
class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
||||
|
||||
Reference in New Issue
Block a user