forked from VimPlug/jedi
use find_types instead of find_names
This commit is contained in:
@@ -178,7 +178,7 @@ class Evaluator(object):
|
|||||||
builtin_scope = builtin.Builtin.scope
|
builtin_scope = builtin.Builtin.scope
|
||||||
yield builtin_scope, builtin_scope.get_defined_names()
|
yield builtin_scope, builtin_scope.get_defined_names()
|
||||||
|
|
||||||
def find_name(self, scope, name_str, position=None, search_global=False,
|
def find_types(self, scope, name_str, position=None, search_global=False,
|
||||||
is_goto=False, resolve_decorator=True):
|
is_goto=False, resolve_decorator=True):
|
||||||
"""
|
"""
|
||||||
This is the search function. The most important part to debug.
|
This is the search function. The most important part to debug.
|
||||||
@@ -310,11 +310,11 @@ class Evaluator(object):
|
|||||||
else:
|
else:
|
||||||
if isinstance(current, pr.NamePart):
|
if isinstance(current, pr.NamePart):
|
||||||
# This is the first global lookup.
|
# This is the first global lookup.
|
||||||
scopes = self.find_name(scope, current, position=position,
|
scopes = self.find_types(scope, current, position=position,
|
||||||
search_global=True)
|
search_global=True)
|
||||||
else:
|
else:
|
||||||
# for pr.Literal
|
# for pr.Literal
|
||||||
scopes = self.find_name(builtin.Builtin.scope, current.type_as_string())
|
scopes = self.find_types(builtin.Builtin.scope, current.type_as_string())
|
||||||
# Make instances of those number/string objects.
|
# Make instances of those number/string objects.
|
||||||
scopes = itertools.chain.from_iterable(
|
scopes = itertools.chain.from_iterable(
|
||||||
self.execute(s, (current.value,)) for s in scopes
|
self.execute(s, (current.value,)) for s in scopes
|
||||||
@@ -380,7 +380,7 @@ class Evaluator(object):
|
|||||||
# This is the typical lookup while chaining things.
|
# This is the typical lookup while chaining things.
|
||||||
if filter_private_variable(type, scope, current):
|
if filter_private_variable(type, scope, current):
|
||||||
return []
|
return []
|
||||||
result = imports.strip_imports(self, self.find_name(type, current,
|
result = imports.strip_imports(self, self.find_types(type, current,
|
||||||
position=position))
|
position=position))
|
||||||
return self.follow_path(path, set(result), scope, position=position)
|
return self.follow_path(path, set(result), scope, position=position)
|
||||||
|
|
||||||
@@ -443,7 +443,7 @@ class Evaluator(object):
|
|||||||
search_global = True
|
search_global = True
|
||||||
follow_res = []
|
follow_res = []
|
||||||
for s in scopes:
|
for s in scopes:
|
||||||
follow_res += self.find_name(s, search, pos,
|
follow_res += self.find_types(s, search, pos,
|
||||||
search_global=search_global, is_goto=True)
|
search_global=search_global, is_goto=True)
|
||||||
return follow_res, search
|
return follow_res, search
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ def search_params(evaluator, param):
|
|||||||
pos = None
|
pos = None
|
||||||
from jedi.evaluate import representation as er
|
from jedi.evaluate import representation as er
|
||||||
for scope in scopes:
|
for scope in scopes:
|
||||||
s = evaluator.find_name(scope, func_name, position=pos,
|
s = evaluator.find_types(scope, func_name, position=pos,
|
||||||
search_global=not first,
|
search_global=not first,
|
||||||
resolve_decorator=False)
|
resolve_decorator=False)
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class NameFinder(object):
|
|||||||
if r.is_global():
|
if r.is_global():
|
||||||
for token_name in r.token_list[1:]:
|
for token_name in r.token_list[1:]:
|
||||||
if isinstance(token_name, pr.Name):
|
if isinstance(token_name, pr.Name):
|
||||||
add = evaluator.find_name(r.parent, str(token_name))
|
add = evaluator.find_types(r.parent, str(token_name))
|
||||||
else:
|
else:
|
||||||
# generated objects are used within executions, but these
|
# generated objects are used within executions, but these
|
||||||
# objects are in functions, and we have to dynamically
|
# objects are in functions, and we have to dynamically
|
||||||
@@ -79,7 +79,7 @@ class NameFinder(object):
|
|||||||
c = r.expression_list()[0]
|
c = r.expression_list()[0]
|
||||||
if c in ('*', '**'):
|
if c in ('*', '**'):
|
||||||
t = 'tuple' if c == '*' else 'dict'
|
t = 'tuple' if c == '*' else 'dict'
|
||||||
res_new = evaluator.execute(evaluator.find_name(builtin.Builtin.scope, t)[0])
|
res_new = evaluator.execute(evaluator.find_types(builtin.Builtin.scope, t)[0])
|
||||||
if not r.assignment_details:
|
if not r.assignment_details:
|
||||||
# this means that there are no default params,
|
# this means that there are no default params,
|
||||||
# so just ignore it.
|
# so just ignore it.
|
||||||
@@ -258,6 +258,7 @@ class NameFinder(object):
|
|||||||
|
|
||||||
def find(self, scopes, resolve_decorator=True):
|
def find(self, scopes, resolve_decorator=True):
|
||||||
filtered = self.filter_name(scopes)
|
filtered = self.filter_name(scopes)
|
||||||
|
print 'f', filtered
|
||||||
return self._resolve_descriptors(self._remove_statements(filtered,
|
return self._resolve_descriptors(self._remove_statements(filtered,
|
||||||
resolve_decorator))
|
resolve_decorator))
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ class ImportPath(pr.Base):
|
|||||||
elif rest:
|
elif rest:
|
||||||
if is_goto:
|
if is_goto:
|
||||||
scopes = itertools.chain.from_iterable(
|
scopes = itertools.chain.from_iterable(
|
||||||
self._evaluator.find_name(s, rest[0], is_goto=True)
|
self._evaluator.find_types(s, rest[0], is_goto=True)
|
||||||
for s in scopes)
|
for s in scopes)
|
||||||
else:
|
else:
|
||||||
scopes = itertools.chain.from_iterable(
|
scopes = itertools.chain.from_iterable(
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class Array(use_metaclass(CachedMetaClass, pr.Base)):
|
|||||||
It returns e.g. for a list: append, pop, ...
|
It returns e.g. for a list: append, pop, ...
|
||||||
"""
|
"""
|
||||||
# `array.type` is a string with the type, e.g. 'list'.
|
# `array.type` is a string with the type, e.g. 'list'.
|
||||||
scope = self._evaluator.find_name(builtin.Builtin.scope, self._array.type)[0]
|
scope = self._evaluator.find_types(builtin.Builtin.scope, self._array.type)[0]
|
||||||
scope = self._evaluator.execute(scope)[0] # builtins only have one class
|
scope = self._evaluator.execute(scope)[0] # builtins only have one class
|
||||||
names = scope.get_defined_names()
|
names = scope.get_defined_names()
|
||||||
return [ArrayMethod(n) for n in names]
|
return [ArrayMethod(n) for n in names]
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)):
|
|||||||
supers.append(cls)
|
supers.append(cls)
|
||||||
if not supers and self.base.parent != builtin.Builtin.scope:
|
if not supers and self.base.parent != builtin.Builtin.scope:
|
||||||
# add `object` to classes
|
# add `object` to classes
|
||||||
supers += self._evaluator.find_name(builtin.Builtin.scope, 'object')
|
supers += self._evaluator.find_types(builtin.Builtin.scope, 'object')
|
||||||
return supers
|
return supers
|
||||||
|
|
||||||
@memoize_default(default=())
|
@memoize_default(default=())
|
||||||
@@ -285,7 +285,7 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)):
|
|||||||
@memoize_default(default=())
|
@memoize_default(default=())
|
||||||
def get_defined_names(self):
|
def get_defined_names(self):
|
||||||
result = self.instance_names()
|
result = self.instance_names()
|
||||||
type_cls = self._evaluator.find_name(builtin.Builtin.scope, 'type')[0]
|
type_cls = self._evaluator.find_types(builtin.Builtin.scope, 'type')[0]
|
||||||
return result + type_cls.base.get_defined_names()
|
return result + type_cls.base.get_defined_names()
|
||||||
|
|
||||||
def get_subscope_by_name(self, name):
|
def get_subscope_by_name(self, name):
|
||||||
|
|||||||
Reference in New Issue
Block a user