1
0
forked from VimPlug/jedi

pydoc works now also if the cursor is on the class / created context possibility for completions (backward tokenizer)

This commit is contained in:
David Halter
2012-09-05 14:19:40 +02:00
parent 37df49d598
commit abcd3f328a
4 changed files with 52 additions and 7 deletions

View File

@@ -10,6 +10,8 @@ import debug
import imports
import settings
from _compatibility import next
__all__ = ['complete', 'goto', 'get_definition',
'NotFoundError', 'set_debug_function']
@@ -76,7 +78,7 @@ class Definition(object):
try:
# is an array
return self.definition.type
except:
except AttributeError:
# is a statement
return self.definition.get_code()
@@ -252,7 +254,11 @@ def get_definition(source, line, column, source_path):
f = modules.ModuleWithCursor(source_path, source=source, position=pos)
goto_path = f.get_path_under_cursor()
scopes = _prepare_goto(source, pos, source_path, f, goto_path)
context = f.get_context()
if next(context) in ('class', 'def'):
scopes = [f.parser.user_scope]
else:
scopes = _prepare_goto(source, pos, source_path, f, goto_path)
d = [Definition(s) for s in set(scopes)]
_clear_caches()
return d