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:
@@ -357,7 +357,7 @@ class Evaluator(object):
|
||||
params = typ.params
|
||||
for param in params:
|
||||
if unicode(param.get_name()) == unicode(named_param_name):
|
||||
param_names.append(param.get_name().names[-1])
|
||||
param_names.append(param.get_name())
|
||||
return param_names
|
||||
return [call_path[0]]
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ class NameFinder(object):
|
||||
if isinstance(p, pr.Flow) and p.command == 'except' and p.inputs:
|
||||
as_names = p.inputs[0].as_names
|
||||
try:
|
||||
if as_names[0].names[-1] == name:
|
||||
if as_names[0] == name:
|
||||
# TODO check for types that are not classes and add it to
|
||||
# the static analysis report.
|
||||
types = list(chain.from_iterable(
|
||||
@@ -589,7 +589,7 @@ def find_assignments(lhs, results, seek_name):
|
||||
"""
|
||||
if isinstance(lhs, pr.Array):
|
||||
return _assign_tuples(lhs, results, seek_name)
|
||||
elif unicode(lhs.name.names[-1]) == seek_name:
|
||||
elif unicode(lhs.name) == seek_name:
|
||||
return results
|
||||
else:
|
||||
return []
|
||||
|
||||
@@ -217,7 +217,7 @@ def get_module_name_parts(module):
|
||||
def scope_name_parts(scope):
|
||||
for s in scope.subscopes:
|
||||
# Yield the name parts, not names.
|
||||
yield s.name.names[0]
|
||||
yield s.name
|
||||
for need_yield_from in scope_name_parts(s):
|
||||
yield need_yield_from
|
||||
|
||||
@@ -237,8 +237,8 @@ def get_module_name_parts(module):
|
||||
# token_list anymore, but for now this is the easiest way to get
|
||||
# all the name_parts.
|
||||
for tok in stmt_or_import._token_list:
|
||||
if isinstance(tok, pr.Name):
|
||||
name_parts.update(tok.names)
|
||||
if isinstance(tok, pr.NamePart):
|
||||
name_parts.add(tok)
|
||||
|
||||
return name_parts
|
||||
|
||||
|
||||
@@ -67,13 +67,13 @@ class ImportWrapper(pr.Base):
|
||||
|
||||
# rest is import_path resolution
|
||||
import_path = []
|
||||
if import_stmt.from_ns:
|
||||
import_path += import_stmt.from_ns.names
|
||||
if import_stmt.namespace:
|
||||
if import_stmt.from_names:
|
||||
import_path += import_stmt.from_names
|
||||
if import_stmt.namespace_names:
|
||||
if self.import_stmt.is_nested() and not nested_resolve:
|
||||
import_path.append(import_stmt.namespace.names[0])
|
||||
import_path.append(import_stmt.namespace_names[0])
|
||||
else:
|
||||
import_path += import_stmt.namespace.names
|
||||
import_path += import_stmt.namespace_names
|
||||
|
||||
for i in range(kill_count + int(is_like_search)):
|
||||
if import_path:
|
||||
@@ -140,9 +140,9 @@ class ImportWrapper(pr.Base):
|
||||
for s, scope_names in finder.get_names_of_scope(self._evaluator,
|
||||
scope, include_builtin=False):
|
||||
for n in scope_names:
|
||||
if self.import_stmt.from_ns is None \
|
||||
if self.import_stmt.from_names is None \
|
||||
or self.is_partial_import:
|
||||
# from_ns must be defined to access module
|
||||
# from_names must be defined to access module
|
||||
# values plus a partial import means that there
|
||||
# is something after the import, which
|
||||
# automatically implies that there must not be
|
||||
@@ -198,7 +198,7 @@ class ImportWrapper(pr.Base):
|
||||
|
||||
# goto only accepts Names or NameParts
|
||||
if is_goto and not rest:
|
||||
scopes = [s.name.names[-1] for s in scopes]
|
||||
scopes = [s.name for s in scopes]
|
||||
|
||||
# follow the rest of the import (not FS -> classes, functions)
|
||||
if len(rest) > 1 or rest and self.is_like_search:
|
||||
@@ -243,12 +243,12 @@ class NestedImportModule(pr.Module):
|
||||
# This is not an existing Import statement. Therefore, set position to
|
||||
# 0 (0 is not a valid line number).
|
||||
zero = (0, 0)
|
||||
names = [unicode(name_part) for name_part in i.namespace.names[1:]]
|
||||
names = [unicode(name_part) for name_part in i.namespace_names[1:]]
|
||||
name = helpers.FakeName(names, self._nested_import)
|
||||
new = pr.Import(i._sub_module, zero, zero, name)
|
||||
new.parent = self._module
|
||||
debug.dbg('Generated a nested import: %s', new)
|
||||
return helpers.FakeName(str(i.namespace.names[1]), new)
|
||||
return helpers.FakeName(str(i.namespace_names[1]), new)
|
||||
|
||||
def _get_defined_names(self):
|
||||
"""
|
||||
|
||||
@@ -224,6 +224,7 @@ class Array(use_metaclass(CachedMetaClass, IterableWrapper)):
|
||||
return "<e%s of %s>" % (type(self).__name__, self._array)
|
||||
|
||||
|
||||
# TODO REMOVE, not used.
|
||||
class ArrayMethod(IterableWrapper):
|
||||
"""
|
||||
A name, e.g. `list.append`, it is used to access the original array
|
||||
|
||||
@@ -359,8 +359,6 @@ def _gen_param_name_copy(func, var_args, param, keys=(), values=(), array_type=N
|
||||
new_param.set_expression_list([arr])
|
||||
|
||||
name = copy.copy(param.get_name())
|
||||
name.names = [copy.copy(name.names[0])]
|
||||
name.names[0].parent = name
|
||||
name.parent = new_param
|
||||
return name
|
||||
|
||||
|
||||
@@ -303,12 +303,6 @@ class InstanceElement(use_metaclass(CachedMetaClass, pr.Base)):
|
||||
return [get_instance_el(self._evaluator, self.instance, command, self.is_class_var)
|
||||
for command in self.var.expression_list()]
|
||||
|
||||
@property
|
||||
@underscore_memoization
|
||||
def names(self):
|
||||
return [pr.NamePart(helpers.FakeSubModule, unicode(n), self, n.start_pos)
|
||||
for n in self.var.names]
|
||||
|
||||
@property
|
||||
@underscore_memoization
|
||||
def name(self):
|
||||
|
||||
Reference in New Issue
Block a user