different solution for imports in davidhalter/jedi-vim#44

This commit is contained in:
David Halter
2012-12-09 19:10:35 +01:00
parent 48a45ee55b
commit a012880c0c
3 changed files with 4 additions and 8 deletions

View File

@@ -237,7 +237,8 @@ class Script(object):
# add keywords
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))
def goto(self):

View File

@@ -34,10 +34,7 @@ class BaseDefinition(object):
self.is_keyword = isinstance(definition, keywords.Keyword)
# generate a path to the definition
try:
self.module_path = str(definition.get_parent_until().path)
except AttributeError:
self.module_path = None
@property
def type(self):
@@ -231,8 +228,6 @@ class Definition(BaseDefinition):
d = 'module %s' % self.module_name
elif self.is_keyword:
d = 'keyword %s' % d.name
elif isinstance(d, type(imports.ImportPath.GlobalNamespace)):
d = 'Global Namespace'
else:
d = d.get_code().replace('\n', '')
return d

View File

@@ -262,7 +262,7 @@ class TestRegression(Base):
assert [d.doc for d in defs]
defs = self.get_def("import")
print [d.doc for d in defs]
assert len(defs) == 1
assert [d.doc for d in defs]