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

Dart LSP re-analyzes project when typing starts after period of inactivity #55815

Closed
Reprevise opened this issue May 22, 2024 · 6 comments
Closed
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@Reprevise
Copy link

If I open my Flutter project, then go to do something else and come back and start typing again, the LSP seems to re-analyze the whole project again. Autocomplete gets stuck on "Loading...", etc. I have sent logs to @DanTup for a previous issue (#52947) that include this issue.

I believe it starts here: (Line 845 onwards)

1716386168792:Req:{"jsonrpc"::"2.0","id"::1,"method"::"dart/diagnosticServer","clientRequestTime"::1716386168793}
@mit-mit mit-mit added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label May 22, 2024
@DanTup
Copy link
Collaborator

DanTup commented May 22, 2024

In the log you sent, following the diagnosticServer command (which occurs when you run "Open Analyzer Diagnostics" from the command palette) I see a file opened (auth.dart) which does trigger some analysis, but it seems to be very quick.

Can you clarify exactly what you're seeing that makes it seem like it's reanalyzing the whole project? You mention slow completion above, but the first completion in this log seems to be quite a long way after the line you quoted above.

It would be useful to have a log along with some approx timings and description of what you see, for ex:

10:00 left VS Code open
10:10 returned to VS Code and opened foo.dart
10:10 immediately invoked completion - showed "loading" for approx x seconds

That would make it easier to find the relevant part of the log and know exactly which parts are important.

Thanks!

@Reprevise
Copy link
Author

Can you clarify exactly what you're seeing that makes it seem like it's reanalyzing the whole project? You mention slow completion above, but the first completion in this log seems to be quite a long way after the line you quoted above.

I see the "Analyzing" spinner in VSCode in the bottom left when I start typing. I'm guessing you saw my edits on line 3692 in the log file and indeed that is a ways away from line 845! However, I distinctly remember as soon as I started typing and looking at the instr log file again, it ballooned like it added a few thousand lines right after. Seeing as those 3000 lines are basically all from custom_lint, I'm unsure if this is a Dart LSP issue.

@DanTup
Copy link
Collaborator

DanTup commented May 22, 2024

I see the "Analyzing" spinner in VSCode in the bottom left when I start typing

It is normal to see "analyzing" appear for a short period when you type (because typing does trigger analysis of the files being changed), however it shouldn't last long.

Looking at the log, I see that a lot of this work seemed to start after you opened the file and I agree it does seem like it might be in custom_lint. I will do some testing and see if I can repro and confirm what's happening.

@DanTup
Copy link
Collaborator

DanTup commented May 22, 2024

@Reprevise I tried to reproduce this issue by adding custom_lint to a project, but it did not occur. All of the diagnostic updates I see are specifically for the files I'm modifying.

When you see this - do you know if all the files that appear in the log (as sending new diagnostic) depend on the file you're modifying? If you're able to reproduce this behaviour in any shareable project, I'd be keen to test with it.

@Reprevise
Copy link
Author

Reprevise commented May 22, 2024

When you see this - do you know if all the files that appear in the log (as sending new diagnostic) depend on the file you're modifying?

It's pretty likely, considering that auth file is a "core" file. At this point, I'm tempted to close this issue as I believe it's just a custom_lint issue. I do experience it a bit w/o plugins but its acceptable (maybe like a second of delay, if that, and its on a "core" file. Other files are a lot faster with it).

@DanTup
Copy link
Collaborator

DanTup commented May 22, 2024

Based on your description it does sound like this is normal re-analysis of files that depend on the one modified, and custom_lint (or the lints - I don't know if you're just using theirs or have your own) is taking some time to re-analyze those.

You might be able to isolate this to a particular lint (or set of lints) by enabling/disabling them (I'm not too familiar with custom_lint so I don't know how easy that is), or the specific lints don't seem to matter (and it just takes a long time regardless of which lint(s) are enabled), it might be worth filing an issue against custom_lint with the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

3 participants