forked from VimPlug/jedi
use defined_names also for modules, fixes symbol browsing issues - fixes #344
This commit is contained in:
@@ -4,6 +4,7 @@ These classes are the much bigger part of the whole API, because they contain
|
|||||||
the interesting information about completion and goto operations.
|
the interesting information about completion and goto operations.
|
||||||
"""
|
"""
|
||||||
import warnings
|
import warnings
|
||||||
|
from itertools import chain
|
||||||
|
|
||||||
from jedi._compatibility import next, unicode, use_metaclass
|
from jedi._compatibility import next, unicode, use_metaclass
|
||||||
from jedi import settings
|
from jedi import settings
|
||||||
@@ -523,7 +524,7 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
|||||||
if isinstance(d, er.InstanceElement):
|
if isinstance(d, er.InstanceElement):
|
||||||
d = d.var
|
d = d.var
|
||||||
|
|
||||||
if isinstance(d, compiled.CompiledObject):
|
if isinstance(d, (compiled.CompiledObject, compiled.CompiledName)):
|
||||||
name = d.name
|
name = d.name
|
||||||
elif isinstance(d, pr.Name):
|
elif isinstance(d, pr.Name):
|
||||||
name = d.names[-1]
|
name = d.names[-1]
|
||||||
@@ -624,12 +625,12 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
|||||||
|
|
||||||
:rtype: list of Definition
|
:rtype: list of Definition
|
||||||
"""
|
"""
|
||||||
d = self._definition
|
defs = self._follow_statements_imports()
|
||||||
if isinstance(d, er.InstanceElement):
|
# For now we don't want base classes or evaluate decorators.
|
||||||
d = d.var
|
defs = [d.base if isinstance(d, (er.Class, er.Function)) else d for d in defs]
|
||||||
if isinstance(d, pr.Name):
|
iterable = (defined_names(self._evaluator, d) for d in defs)
|
||||||
d = d.parent
|
iterable = list(iterable)
|
||||||
return defined_names(self._evaluator, d)
|
return list(chain.from_iterable(iterable))
|
||||||
|
|
||||||
|
|
||||||
class CallSignature(Definition):
|
class CallSignature(Definition):
|
||||||
|
|||||||
@@ -143,18 +143,13 @@ class CompiledObject(Base):
|
|||||||
return hasattr(self.obj, '__call__')
|
return hasattr(self.obj, '__call__')
|
||||||
|
|
||||||
|
|
||||||
class CompiledName(object):
|
class CompiledName(FakeName):
|
||||||
def __init__(self, obj, name):
|
def __init__(self, obj, name):
|
||||||
|
super(CompiledName, self).__init__(name)
|
||||||
self._obj = obj
|
self._obj = obj
|
||||||
self.name = name
|
self.name = name
|
||||||
self.start_pos = 0, 0 # an illegal start_pos, to make sorting easy.
|
self.start_pos = 0, 0 # an illegal start_pos, to make sorting easy.
|
||||||
|
|
||||||
def get_parent_until(self):
|
|
||||||
return self.parent.get_parent_until()
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s: (%s).%s>' % (type(self).__name__, self._obj.name, self.name)
|
return '<%s: (%s).%s>' % (type(self).__name__, self._obj.name, self.name)
|
||||||
|
|
||||||
@@ -164,12 +159,9 @@ class CompiledName(object):
|
|||||||
module = self._obj.get_parent_until()
|
module = self._obj.get_parent_until()
|
||||||
return _create_from_name(module, self._obj, self.name)
|
return _create_from_name(module, self._obj, self.name)
|
||||||
|
|
||||||
@property
|
@parent.setter
|
||||||
def names(self):
|
def parent(self, value):
|
||||||
return [self.name] # compatibility with parser.representation.Name
|
pass # Just ignore this, FakeName tries to overwrite the parent attribute.
|
||||||
|
|
||||||
def get_code(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
|
|
||||||
def load_module(path, name):
|
def load_module(path, name):
|
||||||
|
|||||||
Reference in New Issue
Block a user