Skip to content
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

Merged
merged 33 commits into from
Dec 11, 2017
Merged

Fetch tooltip details on-demand for auto-completions #368

merged 33 commits into from
Dec 11, 2017

Conversation

MikhailArkhipov
Copy link

@MikhailArkhipov MikhailArkhipov commented Dec 7, 2017

  • Removed fetching documentation along with completion
  • Added per-item documentation resolution
  • Moved completion and hover code to completion source and hover source so completion can use tooltip data
  • Cleaned up affected files

Closes #152

@DonJayamanne DonJayamanne self-requested a review December 7, 2017 21:48
else:
_completion['description'] = self._generate_signature(
signature)
# if self.show_doc_strings:
Copy link
Member

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?

Copy link
Author

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.

Copy link
Member

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. 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@jeffwidman
Copy link

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.

@DonJayamanne
Copy link

@MikhailArkhipov
Finally, please remove the following files (they are no longer used as a result of the code changes):

  • src/client/jedi/parsers/CompletionParser.ts
  • extractSignatureAndDocumentation function in src/client/providers/jediHelpers.ts

public async getDocumentation(completionItem: vscode.CompletionItem, token: vscode.CancellationToken): Promise<string> {
const documentPosition = DocumentPosition.fromObject(completionItem);
if (documentPosition === undefined) {
Promise.resolve<string>('');

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;

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).

Copy link
Author

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

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

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 (.)

@@ -1,8 +1,12 @@
import * as proxy from './jediProxy';
// Copyright (c) Microsoft Corporation. All rights reserved.

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);

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.

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:

  1. 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.
  2. Ensure the above resolveCompletionItem populates both documentation and detail

Copy link
Author

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.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I got the signature, good catch. But - choices, choices. Details is a plain string which is displayed on top of the documentation. But in a tooltip it is markdown/colorized. So, do we want TS way or display info with colors? I kinda like colored version...

image

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.

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.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only new files?

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 = '';

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without detail, you loose the signature displayed for every item (see below).
This is something that was requested some time ago in the extension (in some issue).
screen shot 2017-12-08 at 5 19 58 pm

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).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll chat Monday

@DonJayamanne
Copy link

@MikhailArkhipov The travis test is failing in one place, thats been fixed in a PR of mine. execObservable should output print statements (removed that test as I've changed the way results are streamed out, and the last item sent in some cases is just the crlf).

@brettcannon brettcannon changed the title #152 takes too much time to load pandas intellisense Fetch tooltip details on-demand for auto-completions Dec 11, 2017
@MikhailArkhipov MikhailArkhipov merged commit 8d79301 into microsoft:master Dec 11, 2017
@MikhailArkhipov MikhailArkhipov deleted the 152 branch December 13, 2017 22:46
DonJayamanne added a commit that referenced this pull request Dec 14, 2017
* upstream/master:
  Fetch tooltip details on-demand for auto-completions (#368)
  Fix interpreter display (#391)
@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

takes too much time to load pandas intellisense
4 participants