Skip to content

Commit 50178ca

Browse files
authored
Rope completions syntax (#307)
1 parent 38b744f commit 50178ca

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

pyls/plugins/rope_completion.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ def pyls_completions(config, workspace, document, position):
3030
rope_project = workspace._rope_project_builder(rope_config)
3131
document_rope = document._rope_resource(rope_config)
3232

33-
definitions = code_assist(rope_project, document.source, offset, document_rope, maxfixes=3)
33+
try:
34+
definitions = code_assist(rope_project, document.source, offset, document_rope, maxfixes=3)
35+
except Exception as e: # pylint: disable=broad-except
36+
log.debug("Failed to run Rope code assist: %s", e)
37+
return []
3438

3539
definitions = sorted_proposals(definitions)
3640
new_definitions = []

pyls/workspace.py

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def _rope_project_builder(self, rope_config):
9191
rope_folder = rope_config.get('ropeFolder')
9292
self.__rope = Project(self._root_path, ropefolder=rope_folder)
9393
self.__rope.prefs.set('extension_modules', self.PRELOADED_MODULES)
94+
self.__rope.prefs.set('ignore_syntax_errors', True)
95+
self.__rope.prefs.set('ignore_bad_imports', True)
9496
self.__rope.validate()
9597
return self.__rope
9698

test/plugins/test_symbols.py

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def sym(name):
4040
# Not going to get too in-depth here else we're just testing Jedi
4141
assert sym('a')['location']['range']['start'] == {'line': 2, 'character': 0}
4242

43+
# Ensure that the symbol range spans the whole definition
44+
assert sym('main')['location']['range']['start'] == {'line': 9, 'character': 0}
45+
assert sym('main')['location']['range']['end'] == {'line': 12, 'character': 0}
46+
4347

4448
def test_symbols_all_scopes(config):
4549
doc = Document(DOC_URI, DOC)

0 commit comments

Comments
 (0)