-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Icons to Completions #2337
Add Icons to Completions #2337
Changes from all commits
437232f
c9ef27e
188d5f1
92a1173
339e72d
e945fba
7f66c81
dd14afd
28fba86
66031ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,10 +54,11 @@ def load_plugin(self): | |
self._warmup_thread.start() | ||
|
||
def get_completions(self, info): | ||
"""Return a list of completion strings""" | ||
"""Return a list of (completion, type) tuples""" | ||
completions = self.get_jedi_object('completions', info) | ||
completions = [(c.word, c.type) for c in completions] | ||
debug_print(str(completions)[:100]) | ||
return [c.word for c in completions] | ||
return completions | ||
|
||
def get_info(self, info): | ||
""" | ||
|
@@ -267,7 +268,7 @@ def preload(self): | |
source_code = "import n" | ||
completions = p.get_completions(CodeInfo('completions', source_code, | ||
len(source_code))) | ||
assert 'numpy' in completions | ||
assert ('numpy', 'module') in completions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have an icon for modules? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not. We have an "M" icon for method, but if we used that it would be the same one as the one used in the outline explorer. I could make an "M" with a different color and use it for module. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that would be confuse. What about using a (P) icon for package? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I just saw that you added a new (M) for modules. @goanpeca, what do you think about it? Should we leave it or use a (P) one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because module != package, and P could also be property. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, no problem then. Let's leave your new (M) :-) |
||
|
||
source_code = "import matplotlib.pyplot as plt; plt.imsave" | ||
path, line_nr = p.get_definition(CodeInfo('definition', source_code, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,9 +65,9 @@ def load_plugin(self): | |
self.create_rope_project(root_path=get_conf_path()) | ||
|
||
def get_completions(self, info): | ||
"""Get a list of completions using Rope""" | ||
"""Get a list of (completion, type) tuples using Rope""" | ||
if self.project is None: | ||
return | ||
return [] | ||
filename = info.filename | ||
source_code = info.source_code | ||
offset = info.position | ||
|
@@ -93,10 +93,11 @@ def get_completions(self, info): | |
proposals = rope.contrib.codeassist.sorted_proposals(proposals) | ||
if DEBUG_EDITOR: | ||
log_dt(LOG_FILENAME, "code_assist/sorted_proposals", t0) | ||
return [proposal.name for proposal in proposals] | ||
return [(proposal.name, proposal.type) for proposal in proposals] | ||
except Exception as _error: #analysis:ignore | ||
if DEBUG_EDITOR: | ||
log_last_error(LOG_FILENAME, "get_completion_list") | ||
return [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this addition here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make sure we always return a list (I wasn't sure what else might break if I didn't). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, no problem. Just curious :-) |
||
|
||
def get_info(self, info): | ||
"""Get a formatted calltip and docstring from Rope""" | ||
|
@@ -284,7 +285,7 @@ def close_rope_project(self): | |
source_code = "import numpy; n" | ||
completions = p.get_completions(CodeInfo('completions', source_code, | ||
len(source_code), __file__)) | ||
assert 'numpy' in completions | ||
assert ('numpy', 'module') in completions | ||
|
||
source_code = "import matplotlib.pyplot as plt; plt.imsave" | ||
path, line_nr = p.get_definition(CodeInfo('definition', source_code, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this
debug_print
here? Just curious, I don't know how important that is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you plan to remove or leave this
debug_print
? You haven't answered my question :-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed now, with updated info!