Skip to content

Commit d3a0414

Browse files
committed
fix #293 use master of Jedi
1 parent 2284074 commit d3a0414

60 files changed

Lines changed: 62 additions & 36 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[submodule "docs"]
22
path = docs
33
url = https://github.com/DonJayamanne/pythonVSCodeDocs.git
4-
branch = help
4+
branch = help
5+
[submodule "pythonFiles/preview/jedi"]
6+
path = pythonFiles/preview/jedi
7+
url = https://github.com/davidhalter/jedi.git

pythonFiles/completion.py

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import sys
55
import json
66
import traceback
7-
sys.path.append(os.path.dirname(__file__))
8-
import jedi
9-
# remove jedi from path after we import it so it will not be completed
10-
sys.path.pop(0)
117

128
WORD_RE = re.compile(r'\w')
139

@@ -26,7 +22,7 @@ def __init__(self):
2622

2723
def _get_definition_type(self, definition):
2824
is_built_in = definition.in_builtin_module
29-
#if definition.type not in ['import', 'keyword'] and is_built_in():
25+
# if definition.type not in ['import', 'keyword'] and is_built_in():
3026
# return 'builtin'
3127
if definition.type in ['statement'] and definition.name.isupper():
3228
return 'constant'
@@ -107,7 +103,7 @@ def _get_call_signatures_with_args(self, script):
107103
except KeyError:
108104
call_signatures = []
109105
for signature in call_signatures:
110-
sig = {"name": "", "description": "", "docstring": "",
106+
sig = {"name": "", "description": "", "docstring": "",
111107
"paramindex": 0, "params": [], "bracketstart": []}
112108
sig["description"] = signature.description
113109
sig["docstring"] = signature.docstring()
@@ -129,10 +125,11 @@ def _get_call_signatures_with_args(self, script):
129125
except ValueError:
130126
name = param.description
131127
value = None
132-
#if name.startswith('*'):
128+
# if name.startswith('*'):
133129
# continue
134130
#_signatures.append((signature, name, value))
135-
sig["params"].append({"name": name, "value":value, "docstring":param.docstring(), "description":param.description})
131+
sig["params"].append({"name": name, "value": value, "docstring": param.docstring(
132+
), "description": param.description})
136133
return _signatures
137134

138135
def _serialize_completions(self, script, identifier=None, prefix=''):
@@ -151,11 +148,11 @@ def _serialize_completions(self, script, identifier=None, prefix=''):
151148

152149
for signature, name, value in self._get_call_signatures(script):
153150
if not self.fuzzy_matcher and not name.lower().startswith(
154-
prefix.lower()):
151+
prefix.lower()):
155152
continue
156153
_completion = {
157154
'type': 'property',
158-
'raw_type':'',
155+
'raw_type': '',
159156
'rightLabel': self._additional_info(signature)
160157
}
161158
# we pass 'text' here only for fuzzy matcher
@@ -193,8 +190,8 @@ def _serialize_completions(self, script, identifier=None, prefix=''):
193190
}
194191
if any([c['text'].split('=')[0] == _completion['text']
195192
for c in _completions]):
196-
# ignore function arguments we already have
197-
continue
193+
# ignore function arguments we already have
194+
continue
198195
_completions.append(_completion)
199196
return json.dumps({'id': identifier, 'results': _completions})
200197

@@ -208,7 +205,7 @@ def _serialize_arguments(self, script, identifier=None):
208205
Returns:
209206
Serialized string to send to VSCode.
210207
"""
211-
return json.dumps({"id": identifier, "results" : self._get_call_signatures_with_args(script) })
208+
return json.dumps({"id": identifier, "results": self._get_call_signatures_with_args(script)})
212209

213210
def _serialize_definitions(self, definitions, identifier=None):
214211
"""Serialize response to be read from VSCode.
@@ -222,14 +219,14 @@ def _serialize_definitions(self, definitions, identifier=None):
222219
"""
223220

224221
def _top_definition(definition):
225-
for d in definition.goto_assignments():
226-
if d == definition:
227-
continue
228-
if d.type == 'import':
229-
return _top_definition(d)
230-
else:
231-
return d
232-
return definition
222+
for d in definition.goto_assignments():
223+
if d == definition:
224+
continue
225+
if d.type == 'import':
226+
return _top_definition(d)
227+
else:
228+
return d
229+
return definition
233230

234231
_definitions = []
235232
for definition in definitions:
@@ -252,16 +249,16 @@ def _top_definition(definition):
252249
return json.dumps({'id': identifier, 'results': _definitions})
253250

254251
def _serialize_usages(self, usages, identifier=None):
255-
_usages = []
256-
for usage in usages:
257-
_usages.append({
258-
'name': usage.name,
259-
'moduleName': usage.module_name,
260-
'fileName': usage.module_path,
261-
'line': usage.line,
262-
'column': usage.column,
263-
})
264-
return json.dumps({'id': identifier, 'results': _usages})
252+
_usages = []
253+
for usage in usages:
254+
_usages.append({
255+
'name': usage.name,
256+
'moduleName': usage.module_name,
257+
'fileName': usage.module_path,
258+
'line': usage.line,
259+
'column': usage.column,
260+
})
261+
return json.dumps({'id': identifier, 'results': _usages})
265262

266263
def _deserialize(self, request):
267264
"""Deserialize request from VSCode.
@@ -309,11 +306,11 @@ def _process_request(self, request):
309306
if lookup == 'names':
310307
return self._write_response(self._serialize_definitions(
311308
jedi.api.names(
312-
source=request.get('source', None),
309+
source=request.get('source', None),
313310
path=request.get('path', ''),
314311
all_scopes=True),
315312
request['id']))
316-
313+
317314
script = jedi.api.Script(
318315
source=request.get('source', None), line=request['line'] + 1,
319316
column=request['column'], path=request.get('path', ''))
@@ -345,4 +342,19 @@ def watch(self):
345342
sys.stderr.flush()
346343

347344
if __name__ == '__main__':
345+
jediPreview = False
346+
if len(sys.argv) > 1 and sys.argv[1] == 'preview':
347+
jediPath = os.path.join(os.path.dirname(__file__), 'preview', 'jedi')
348+
jediPreview = False
349+
else:
350+
jediPath = os.path.join(os.path.dirname(__file__), 'release')
351+
352+
sys.path.append(jediPath)
353+
import jedi
354+
if jediPreview:
355+
jedi.settings.cache_directory = os.path.join(
356+
jedi.settings.cache_directory, 'v' + jedi.__version__.replace('.', ''))
357+
358+
# remove jedi from path after we import it so it will not be completed
359+
sys.path.pop(0)
348360
JediCompletion().watch()

pythonFiles/jedi/.DS_Store

-6 KB
Binary file not shown.

pythonFiles/preview/jedi

Submodule jedi added at 7a34789
File renamed without changes.

0 commit comments

Comments
 (0)