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

Usage highlighting broken in VSCode #59695

Open
stereotype441 opened this issue Dec 10, 2024 · 6 comments
Open

Usage highlighting broken in VSCode #59695

stereotype441 opened this issue Dec 10, 2024 · 6 comments
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request

Comments

@stereotype441
Copy link
Member

I recently re-built my SDK, and I'm no longer seeing usages highlighted when clicking on an identifier in VSCode.

I've bisected the issue and it appears to have started with 6f992ae.

CC @bwilkerson @scheglov

@stereotype441 stereotype441 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-server labels Dec 10, 2024
@scheglov
Copy link
Contributor

@DanTup What LSP command / handler does VS Code use to highlight usages?

@stereotype441 is it broken for all kinds of elements, e.g. local variables, classes, getters, etc?

@DanTup
Copy link
Collaborator

DanTup commented Dec 11, 2024

@DanTup What LSP command / handler does VS Code use to highlight usages?

LSP calls these "Document Highlights" and the implementation uses OccurrencesCollectorImpl (which should match the legacy implementation).

In a quick test of class names (running from source as of around 4 hours ago) I do still see them showing up:

image

@stereotype441
Copy link
Member Author

Hmm, I thought it was broken for everything, but now I can't reproduce the problem at all. I'm not sure what happened.

I will keep an eye out, and if it happens again, I'll post more exact repro instructions.

@stereotype441
Copy link
Member Author

Ok, I have more information. The problem seems to happen only in certain files. For example, in my checkout of the Dart SDK, document highlights work in pkg/analyzer/lib/dart/analysis/analysis_context_collection.dart, but not in pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart.

I played around a bit in pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart, and found that if I modify the AnalysisContextCollectionImpl constructor so that its updateAnalysisOptions2 argument has type void Function()? instead of void Function({required AnalysisOptionsImpl analysisOptions, required ContextRoot contextRoot, required DartSdk sdk})?, then highlights begin to work throughout the file.

Does that help?

@bwilkerson
Copy link
Member

I don't see anything obviously wrong with the AST structure created for that constructor. My best guess at this point is that the code might be throwing an exception that's being caught in such a way that it's returning an empty list of references.

@DanTup
Copy link
Collaborator

DanTup commented Dec 12, 2024

@stereotype441 do you have an exact git hash and example offset where it's not working? I'm browsing the source at 8a28378 and running the server from Dart SDK version: 3.7.0-edge.0c527e1b9f187c823263d19f9a3c2df8a76ccc22 (main) (Tue Dec 10 04:36:59 2024 +0000) on "windows_x64" but it does seem to work in the noted file for me:

image

@scheglov scheglov added the P3 A lower priority bug or feature request label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

4 participants