mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-11 08:11:50 +08:00
different solution for imports in davidhalter/jedi-vim#44
This commit is contained in:
@@ -237,7 +237,8 @@ class Script(object):
|
|||||||
# add keywords
|
# add keywords
|
||||||
scopes |= keywords.get_keywords(string=goto_path, pos=self.pos)
|
scopes |= keywords.get_keywords(string=goto_path, pos=self.pos)
|
||||||
|
|
||||||
d = set([api_classes.Definition(s) for s in scopes])
|
d = set([api_classes.Definition(s) for s in scopes
|
||||||
|
if not isinstance(s, imports.ImportPath._GlobalNamespace)])
|
||||||
return sorted(d, key=lambda x: (x.module_path, x.start_pos))
|
return sorted(d, key=lambda x: (x.module_path, x.start_pos))
|
||||||
|
|
||||||
def goto(self):
|
def goto(self):
|
||||||
|
|||||||
@@ -34,10 +34,7 @@ class BaseDefinition(object):
|
|||||||
self.is_keyword = isinstance(definition, keywords.Keyword)
|
self.is_keyword = isinstance(definition, keywords.Keyword)
|
||||||
|
|
||||||
# generate a path to the definition
|
# generate a path to the definition
|
||||||
try:
|
|
||||||
self.module_path = str(definition.get_parent_until().path)
|
self.module_path = str(definition.get_parent_until().path)
|
||||||
except AttributeError:
|
|
||||||
self.module_path = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self):
|
def type(self):
|
||||||
@@ -231,8 +228,6 @@ class Definition(BaseDefinition):
|
|||||||
d = 'module %s' % self.module_name
|
d = 'module %s' % self.module_name
|
||||||
elif self.is_keyword:
|
elif self.is_keyword:
|
||||||
d = 'keyword %s' % d.name
|
d = 'keyword %s' % d.name
|
||||||
elif isinstance(d, type(imports.ImportPath.GlobalNamespace)):
|
|
||||||
d = 'Global Namespace'
|
|
||||||
else:
|
else:
|
||||||
d = d.get_code().replace('\n', '')
|
d = d.get_code().replace('\n', '')
|
||||||
return d
|
return d
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ class TestRegression(Base):
|
|||||||
assert [d.doc for d in defs]
|
assert [d.doc for d in defs]
|
||||||
|
|
||||||
defs = self.get_def("import")
|
defs = self.get_def("import")
|
||||||
print [d.doc for d in defs]
|
assert len(defs) == 1
|
||||||
assert [d.doc for d in defs]
|
assert [d.doc for d in defs]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user