Code completion suggestions are irrelevant / context unaware #55651
Labels
analyzer-completion
Issues with the analysis server's code completion feature
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
This tracker is for issues related to:
Summary:
Code completion suggestions are flooded with irrelevant entries and / or are not context aware since (roughly) Dart 3.
I've been noticing a decrease in accuracy of the code suggestions for a while that had the relevant suggestion buried below various references to unused packages or even keywords that would result in wrong syntax. (examples below)
Tested with Dart versions:
to
Tested in IDEs:
System:
Mac OS 14.4.1 (but the issue was probably noticed before that)
Flutter 3.19.6 (current)
Dart 3.3.4 (bundled)
Examples:
Typing the keyword
required
for a named parameter up to the first 3 letters suggests thedynamic
variables "r"/"re"/"req".Expected:
required
first and possible others below (even though i wouldn't think declaring a variable this way would be recommended)Typing the keyword
this
inside a class to reference a member points to an object in thedart:html
package (this is not a web project, so the linter knows importing it is wrong).Expected:
this
andthrow
first, and the rest, but imports from thedart:html
package probably shouldn't be suggested in a non web projectNote: typing only "t" yields better results but still contains far fetched suggestions
Here, the constructor of a class contains a named
bool
parameter. Trying to typefalse
as a value suggests a load of unrelated nonbool
objects, and even thefactory
keyword as the first pick in VSCode (happens on a base flutter project, so the suggestion order is influenced by the"import "package:flutter/material.dart"
)Tests i've conducted:
The different sdk versions i've tried all suffer from this to various degrees, 3.0.5 was the one with the most relevant suggestions.
I've not tested with all the individual versions since but i've continuously kept my environment updated and the problem has persisted since.
In Android Studio, flipped every "code completion" parameter available.
In VSCode i tried various combinations of the Dart settings
"useLegacyAnalyzerProtocol"
,"autoImportCompletions"
,"editor.suggestSelection"
,"editor.wordBasedSuggestions"
and the likes, yielding various results, improving some situations here and there but i could see the issue was not resolved, and the suggestions were nowhere near the accuracy i was used to before.The different IDEs all suffer from this, with some minor variations, although as expected Android Studio and IntelliJ Idea behave the same.
The issue persisted over 2 computers (albeit both apple) and several clean installations of several systems (probably Mac OS 12 - 14)
The dart sdk used is bundled in flutter since i'm using flutter, but to be sure i've installed it separately and made sure the IDEs used that one instead, same results.
In VSCode, tried setting both the Dart and the Flutter extensions to "pre-release", each separately and both at the same time, same results.
I know some issues are already opened on the subject but i felt they did not fully address my problem so i opened this one, thanks for reading !
The text was updated successfully, but these errors were encountered: