forked from palantir/python-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefinition.py
26 lines (22 loc) · 922 Bytes
/
definition.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright 2017 Palantir Technologies, Inc.
import logging
from pyls import hookimpl, uris
log = logging.getLogger(__name__)
@hookimpl
def pyls_definitions(config, document, position):
settings = config.plugin_settings('jedi_definition')
definitions = document.jedi_script(position).goto_assignments(
follow_imports=settings.get('follow_imports', True),
follow_builtin_imports=settings.get('follow_builtin_imports', True))
return [
{
'uri': uris.uri_with(document.uri, path=d.module_path),
'range': {
'start': {'line': d.line - 1, 'character': d.column},
'end': {'line': d.line - 1, 'character': d.column + len(d.name)},
}
}
for d in definitions
if d.is_definition() and d.line is not None and d.column is not None and
d.module_path is not None and not d.in_builtin_module()
]