-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fetch tooltip details on-demand for auto-completions #368
Conversation
pythonFiles/completion.py
Outdated
else: | ||
_completion['description'] = self._generate_signature( | ||
signature) | ||
# if self.show_doc_strings: |
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.
Any reason to keep this (and the other commented-out code) around?
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.
Just in case we need it (or for reference purposes - i.e. how to do the doc fetch). But I am fine removing it, up to you folks.
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.
I say strip it; we have a VCS for a reason. 😉
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.
OK
Fix #152 FYI @MikhailArkhipov if you put this in your PR comment next time rather than the title, then github will auto-close the issue when the PR is merged. |
@MikhailArkhipov
|
public async getDocumentation(completionItem: vscode.CompletionItem, token: vscode.CancellationToken): Promise<string> { | ||
const documentPosition = DocumentPosition.fromObject(completionItem); | ||
if (documentPosition === undefined) { | ||
Promise.resolve<string>(''); |
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 mean to return something? This is a no-op statement.
I think you intend to return something,
Since you're in an async method, you can return the raw value (just as you would in C# 7)
return '';
|
||
public static fromObject(item: object): DocumentPosition { | ||
// tslint:disable-next-line:no-any | ||
return (item as any).documentPosition as DocumentPosition; |
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.
Can we change the name of the property to _documentPosition
or _pyDocumentPosition
, so as to ensure this will not conflict with any future API vscode adds to the TextDocument
object.
Cuz using any
we'll never get any compilation errors (hence the dangers of using any
).
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.
OK
if (lineText.match(/^\s*\/\//)) { | ||
return undefined; | ||
} | ||
// Suppress completion inside string and comments |
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.
Please end sentences with periods (.
)
(item.kind === vscode.SymbolKind.Function || item.kind === vscode.SymbolKind.Method)) { | ||
completionItem.insertText = new vscode.SnippetString(item.text).appendText('(').appendTabstop().appendText(')'); | ||
} | ||
// ensure the built in members are at the bottom |
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.
Please end sentence with period (.
)
src/client/providers/jediHelpers.ts
Outdated
@@ -1,8 +1,12 @@ | |||
import * as proxy from './jediProxy'; | |||
// Copyright (c) Microsoft Corporation. All rights reserved. |
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.
The license headers are to be added only for new files, not existing files. (please check with @brettcannon for further clarification).
const index = tokens.getItemContaining(document.offsetAt(position)); | ||
return index >= 0 && (tokens[index].TokenType === TokenType.String || tokens[index].TokenType === TokenType.Comment); | ||
public async resolveCompletionItem(item: vscode.CompletionItem, token: vscode.CancellationToken): Promise<vscode.CompletionItem> { | ||
item.documentation = await this.completionSource.getDocumentation(item, token); |
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.
We should probably check if item.documentation
is empty or not. If not empty, then try to get the documentation. Else we get the documentation again.
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.
Previous code used to initialize both the documentation
and detail
properties. I believe one is the signature of the method (display on the right of the method) and the other is the full documentation (displayed when you click on the i
information icon).
I just tested the impact of the change, we loose the signature.
Guess we have two issues that need to be addressed:
- Create unit tests to ensure documentation and details properties are validated (something I failed to add). Will be useful for future usage as well, if we use a language server or the like.
- Ensure the above
resolveCompletionItem
populates bothdocumentation
anddetail
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.
I believe VSC is not calling resolve
for items with documentation, but I'' double check.
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.
Oh yes, that's true.
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.
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.
I like the last item (colored version).
@@ -1,107 +1,23 @@ | |||
// Copyright (c) Microsoft Corporation. All rights reserved. | |||
// Licensed under the MIT License. |
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.
Please remove the license header. They should only be added for new files.
@@ -1,76 +1,35 @@ | |||
// Copyright (c) Microsoft Corporation. All rights reserved. | |||
// Licensed under the MIT License. |
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.
Please remove the license header, they should be added for new files.
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.
Only new files?
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.
Yes, apparently that's what CELA have informed Brett.
// Only filling documentation since tooltip already contains | ||
// all the necessary information and is colorized via markdown. | ||
item.documentation = itemInfos[0].tooltip; | ||
item.detail = ''; |
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.
@MikhailArkhipov
I think we'll need the details, lets talk on Monday.
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.
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.
Not sure which one is which (documentation
vs detail
).
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.
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.
We'll chat Monday
@MikhailArkhipov The travis test is failing in one place, thats been fixed in a PR of mine. |
completion source
andhover source
so completion can use tooltip dataCloses #152