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

Add method references CodeLens #5928

Merged
merged 6 commits into from Sep 29, 2020
Merged

Add method references CodeLens #5928

merged 6 commits into from Sep 29, 2020

Conversation

vsrs
Copy link
Contributor

@vsrs vsrs commented Sep 1, 2020

The PR adds CodeLens for methods and free-standing functions:

method_refs

Relates to #5836

editors/code/package.json Outdated Show resolved Hide resolved
@vsrs vsrs marked this pull request as draft September 2, 2020 14:03
let position = from_proto::file_position(&snap, doc_position.clone())?;
let locations = snap
.analysis
.find_all_refs(position, None)
Copy link
Member

Choose a reason for hiding this comment

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

Hm, yeah, I am still not happy about factoring here -- way to many logic happens in the handlers.

But it also is non-trivial to properly factor the logic given the two-phase requests.

I think there's a better solution here, but I haven't looked in the details yet. I expect we want to use exactly the same pattern for code lenses as for assists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just reuse existing find_all_refs method and convert the results to LSP types. And that's all.

I think there's a better solution here, but I haven't looked in the details yet.

Perhaps we can (should) utilize the fact that Code Lens Request supports partial results. But it requires a lot of work and if you do not mind I'd prefer to leave it for another PR.

@vsrs vsrs marked this pull request as ready for review September 2, 2020 15:46
@vsrs
Copy link
Contributor Author

vsrs commented Sep 2, 2020

By the way, one question. Current reference search mechanism does not support trait implementations:
image

It is possible to detect such situations and do not show No references lens. However, I decided to leave it as it is in case someday RA will support it. Am I right or am I missing something??

@matklad
Copy link
Member

matklad commented Sep 2, 2020 via email

@xsoheilalizadeh
Copy link

@vsrs I think No references isn't the best option for showing the method or function which hasn't any references, 0 references is a better choice, as far as I could see other implementation does the same, like c# in vscode and visual studio.

@matklad
Copy link
Member

matklad commented Sep 29, 2020

r=me with #5928 (comment) addressed

bors d+

@bors
Copy link
Contributor

bors bot commented Sep 29, 2020

✌️ vsrs can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@vsrs
Copy link
Contributor Author

vsrs commented Sep 29, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 29, 2020

@bors bors bot merged commit bdc1f76 into rust-lang:master Sep 29, 2020
@vsrs vsrs deleted the ref_lens branch September 29, 2020 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants