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

Completion is not working well #49054

Closed
stevemessick opened this issue May 18, 2022 · 28 comments
Closed

Completion is not working well #49054

stevemessick opened this issue May 18, 2022 · 28 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. P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@stevemessick
Copy link
Contributor

The Flutter plugin is getting multiple reports that completion is not working or not working well. Unfortunately, I cannot transfer them, so I'll add links here.

flutter/flutter-intellij#6177
flutter/flutter-intellij#6176

@lrhn lrhn added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label May 18, 2022
@ldsouza93
Copy link

ldsouza93 commented May 19, 2022

Not only code completion, the alt+enter shortcut using Android Studio is broken too

i have to hit the ESC button a few times or even move the cursor focus around the code to switch the alt+enter suggestions when fixing code

@lntls
Copy link

lntls commented May 19, 2022

Same here
屏幕截图 2022-05-19 120037
expect
package:flutter/material.dart

@srawlins
Copy link
Member

@scheglov @bwilkerson @jwren This may be related to the new protocol. Or related to out-of-scope identifiers. So far it looks to be isolated to IntelliJ...

It looks like suggestions are coming back, but they are missing some obvious suggestions that the user expects, and also received pre-Flutter 3.0 / Dart 2.17.0.

@scheglov
Copy link
Contributor

@0htls without more data it is hard to say if this is a bug in the server, or the way you use it.
In flutter/flutter#104149 a conclusion was that there is a missing dependency.
image

@lntls
Copy link

lntls commented May 21, 2022

@scheglov
屏幕截图 2022-05-21 112135
Good:
屏幕截图 2022-05-21 112206

Adding build_runner
屏幕截图 2022-05-21 113850
Bad:
屏幕截图 2022-05-21 114036

@ldsouza93
Copy link

after the latest update i still dont get suggestion for setstate, inistate, dispose etc.

@scheglov
Copy link
Contributor

@0htls Thank you, I can reproduce it.

@scheglov
Copy link
Contributor

The issue is that while we suggest all possible imports, including package:flutter/material.dart, we have just too many of them (and we start getting too many because of this additional dependency and its transitive dependencies). And all of these suggestions have the same relevance, and the same ideal fuzzy matching score. So, we cut at 100 items, and package:flutter/material.dart does not make it.

But the fuzzy matching score should not be the same, this happens because we decide that the prefix to match against is the empty string. This is a bug that should be fixed. And probably this will fix the issue.

@scheglov
Copy link
Contributor

@Anfet
Copy link

Anfet commented May 23, 2022

Wow. That's so cool.
When it will be available, as it's killing development speed.

Perhaps a configuration somewhere is present?

@serendipity1004
Copy link

@scheglov if I downgrade back to 2.x versions then I get the autocomplete back. Is there something we could do until the patches are released as a temporary solution?

copybara-service bot pushed a commit that referenced this issue May 24, 2022
…FILENAME

Bug: #49054
Change-Id: I127944d9eca20f0d8a57e26b3050fcfcb381d2b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245623
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
@sunnykinger
Copy link

after the latest update i still dont get suggestion for setstate, inistate, dispose etc.

going through the same problem. any temporary solution?

@AlexV525
Copy link
Contributor

So, we cut at 100 items, and package:flutter/material.dart does not make it.

@scheglov It doesn't seem to be cut here. When I was trying to import package:collection, whether I type col or package:col, the suggestion tells me nothing relevant. Also, I've counted the number of suggestions when typing package: and it doesn't match 100.

image

@srawlins srawlins added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed bug labels Jun 1, 2022
@Kerrely
Copy link

Kerrely commented Jun 6, 2022

I'm not sure if this is the same problem. But I experienced several times that the Dart Analyzer just stopped working either completely or started behaving really weirdly (not showing suggestions at all or colouring of keywords in the code completely disappeared) especially after switching between branches that had different dependencies. Running flutter clean, flutter pub cache repair or invalidating cache etc did not help. The only thing that helped me once was deleting the .pub-cache folder completely from the flutter's SDK folder. Then the IDE restart and flutter clean/flutter pub get helped.

@stevemessick
Copy link
Contributor Author

Flutter 3.0.2 is available now and it should fix the issues with code completion. Please create a new issue here if you see more problems.

@lntls
Copy link

lntls commented Jun 11, 2022

Flutter 3.0.2 is available now and it should fix the issues with code completion. Please create a new issue here if you see more problems.

屏幕截图 2022-06-11 090850
Completion still not working well in Flutter 3.0.2

@Gridzzle
Copy link

Flutter 3.0.2 is available now and it should fix the issues with code completion. Please create a new issue here if you see more problems.

Auto-completion still not working with everything, such as setState, initState, Colors auto complete

@serendipity1004
Copy link

@stevemessick I can also confirm that it is still not working on 3.0.2. import 'mat' leads to auto completion of only dart:math

@scheglov
Copy link
Contributor

I'm adding the fix to https://dart-review.googlesource.com/c/sdk/+/248080, to cherry pick as #49239

copybara-service bot pushed a commit that referenced this issue Jul 12, 2022
This is a patch release that fixes:

- Improve code completion for Flutter (issue [#49054][]).
- Fix crash on ARM (issue [#106510][]).
- Fix compiler crash with Finalizable parameters (issue [#49402][]).

[#49054]: #49054
[#106510]: flutter/flutter#106510
[#49402]: #49402

Change-Id: I9a814603d9793b75b764fd0f384e89017e773c50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251109
Reviewed-by: Alexander Thomas <[email protected]>
Commit-Queue: William Hesse <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jul 12, 2022
This is a patch release that fixes:

- Improve code completion for Flutter (issue [#49054][]).
- Fix crash on ARM (issue [#106510][]).
- Fix compiler crash with Finalizable parameters (issue [#49402][]).

[#49054]: #49054
[#106510]: flutter/flutter#106510
[#49402]: #49402

Change-Id: I9a814603d9793b75b764fd0f384e89017e773c50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251109
Reviewed-by: Alexander Thomas <[email protected]>
Commit-Queue: William Hesse <[email protected]>
@fisforfaheem
Copy link

Also having suggestions but very slow in vs code isndiers

@Anfet
Copy link

Anfet commented Jul 14, 2022

3.0.5 helped, but some suggestions, especially from other modules, aren't given.
Also code complete performance is degrading after few hours of coding.

@AlexV525
Copy link
Contributor

3.0.5 helped, but some suggestions, especially from other modules, aren't given. Also code complete performance is degrading after few hours of coding.

Can you submit new issues with some more specific statements? That helps to investigate the root cause.

@fisforfaheem
Copy link

fisforfaheem commented Jul 14, 2022 via email

@Anfet
Copy link

Anfet commented Jul 15, 2022

image
As you see here, even jsonEncode cannot be completed.

From the view of it. Code complete (CC) is working, working, working and then once you stumble across a big import, or a questionable import, CC starts to throttle really hard.
It take it quite some time even to refresh errors.

i.e. you write String get prop() => and it gets underlined as error.
then you remove the brackets, and only after 10-15 seconds when underline error disappears.

@S-Man42
Copy link

S-Man42 commented Dec 2, 2022

I still have the problem. The auto completion only shows me methods and classes from already imported classes, but does not suggest me any from the rest of the project, not even my own classes (that are not explicitly imported). I need to add the import manually...

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.3.7, on Microsoft Windows [Version 10.0.19045.2251], locale de-DE)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.3)
[√] Connected device (3 available)
    ! Device emulator-5554 is not authorized.
      You might need to check your device for an authorization dialog.
[√] HTTP Host Availability

I already removed and cleared every possible cache directory (Gradle, Pub, AndroidStudio, IntelliJ, ...). No PowerSave mode. Restarted Dart Analysis.

@webMing
Copy link

webMing commented Aug 3, 2023

Hi i really want to known how to get code hints using VSC :


@override
  Widget build(BuildContext context) {
    return ElevatedButton(onPressed: onPressed, child: child)
  }

In build method i type Eleva....... i can get ElevatedButton hint , so this good. and then "onPreesed" is hightLight , so i delete it and type "(" but not show any "(){} or () =>" function to hint , what should i do ?
thanks

@srawlins
Copy link
Member

srawlins commented Aug 3, 2023

@webMing please file questions similar to this at a user forum with more users who can look and answer.

@SNNafi
Copy link

SNNafi commented Jul 31, 2024

If I add build_runner in my project as dev_dependencies, then the Option + Return shortcut is not working in Android Studio. It doesn't show anything

My Flutter configs

[✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-arm64, locale en-US)
    • Flutter version 3.22.3 on channel stable at /Users/snnafi/FlutterSDK/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (2 weeks ago), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/snnafi/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.91.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

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. P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests