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

Code completion suggestions are irrelevant / context unaware #55651

Open
barthbv opened this issue May 6, 2024 · 2 comments
Open

Code completion suggestions are irrelevant / context unaware #55651

barthbv opened this issue May 6, 2024 · 2 comments
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)

Comments

@barthbv
Copy link

barthbv commented May 6, 2024

This tracker is for issues related to:

  • Dart analyzer and linter

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:

  • 3.0.5
    to
  • 3.3.4 (currently used)
  • 3.5.0

Tested in IDEs:

  • Android Studio
  • VSCode
  • IntelliJ Idea

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 the dynamic 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)
required_keyword

Typing the keyword this inside a class to reference a member points to an object in the dart:html package (this is not a web project, so the linter knows importing it is wrong).
Expected: this and throw first, and the rest, but imports from the dart:html package probably shouldn't be suggested in a non web project
this_keyword

Note: typing only "t" yields better results but still contains far fetched suggestions
this_keyword_2

Here, the constructor of a class contains a named bool parameter. Trying to type false as a value suggests a load of unrelated non bool objects, and even the factory 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")
constructor
constructor_vscode

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 !

@bwilkerson bwilkerson added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-completion Issues with the analysis server's code completion feature P2 A bug or feature request we're likely to work on labels May 6, 2024
@bwilkerson
Copy link
Member

Thanks for the feedback!

And we're sorry about the regressions. I'm not sure exactly why they occurred, but they're almost certainly a result of some changes we're making to streamline the implementation of code completion. We take the quality of code completion seriously and will look into the known cases, like the ones above, as soon as possible.

@barthbv
Copy link
Author

barthbv commented May 6, 2024

You're welcome, and for sure don't be sorry ! I didn't report to complain, i reported to inform 👍
Thank YOU for your work and dedication, if i can help with anything just let me know.

@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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)
Projects
None yet
Development

No branches or pull requests

3 participants