Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Add references codelens support #933

Merged
merged 1 commit into from
Apr 20, 2017
Merged

Conversation

theSoenke
Copy link
Contributor

@theSoenke theSoenke commented Apr 19, 2017

This PR adds support for reference codelenses as discussed in #726

There are still a few issues:

  • Debug console shows guru errors when file contains syntax errors and is not saved
  • Does not work with method receivers. Issue here is probably that the go parser returns 1 as a start character in a line for functions. It works for functions without receivers because i add an offset of 5 characters
  • Slow for big projects. This is more an issue with guru

@msftclas
Copy link

@theSoenke,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

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

Your code at present has linting errors which is breaking the build. Run npm run lint and you can see the list of errors.

For the guru errors you are seeing, see #726 (comment)

includeDeclaration: false
};
let position = symbol.location.range.start;
if (symbol.kind === vscode.SymbolKind.Function) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here as to why 5 is being added? Helps the next person reading this code :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point :)

@@ -19,7 +19,7 @@ export class GoReferenceProvider implements vscode.ReferenceProvider {
});
}

private doFindReferences(document: vscode.TextDocument, position: vscode.Position, options: { includeDeclaration: boolean }, token: vscode.CancellationToken): Thenable<vscode.Location[]> {
public doFindReferences(document: vscode.TextDocument, position: vscode.Position, options: { includeDeclaration: boolean }, token: vscode.CancellationToken): Thenable<vscode.Location[]> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am guessing the reason you are using doFindReferences instead of provideReferences is because the latter does a saveAll before finding the references.

My another guess for why saveAll was put in place was because guru was made to run on saved files.

Now that we have guru working on unsaved files as well (with the -modified flag), lets remove the saveAll that happens in provideReferences and you can use it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, saveAll was the reason for that. Removed saveAll and set provideReferences back to private

@ramya-rao-a
Copy link
Contributor

For the slowness issue, have you considered using resolveCodeLens ?

@theSoenke
Copy link
Contributor Author

Looks like resolveCodeLens could make a lot sense here. I will look into it.

@ramya-rao-a ramya-rao-a merged commit 4aecaa6 into microsoft:master Apr 20, 2017
@ramya-rao-a
Copy link
Contributor

@theSoenke I have merged the PR, but please continue looking at the resolveCodeLens option and send a different PR for it ?

@theSoenke theSoenke deleted the codelens branch April 21, 2017 19:25
@theSoenke
Copy link
Contributor Author

@ramya-rao-a Great! I've submitted a PR to use resolveCodeLens #938

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.

None yet

3 participants