question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code completion does not behave correctly

See original GitHub issue

Hi!

I have a problem with code completion with my project. It worked up until a certain point but then stopped working. I first noticed the issue some time during the holidays. I can’t pinpoint to a specific version of VSCode, Dart-Code or the Flutter SDK as I’ve tried several different version and combinations by downgrading.

TLTR; Dart-Code can analyze my code but fails to provide quick fixes.

What doesn’t work:

  • Code completion with classes from within my project
  • Quick Fixes (missing import statements, remove unused imports, surround with new widget, etc)

What works:

  • Code completion of external packages from pub
  • Code formatting
  • Static analysis (using pedantic rules)
  • Refactoring like renaming classes
  • Classes are found without problem once I add the import statements manually

What I’ve tried (and didn’t fix the problem)

  • Downgrading versions of VSCode, Dart-Code and Flutter SDK
  • Deleting all generated files:
    rm -rf .dart_tool/ build/ .flutter-plugins .flutter-plugins-dependencies .packages
    

Strange occurrence: Deleting the files worked once and the next morning code completion the problem magically reappeared. Deleting doesn’t work anymore.

The problem doesn’t appear when I create a new project using flutter create myproject. I’ve added the analyzer logs to this gist: https://gist.github.com/fusion44/87bf104afba4cf1edcecf80781a75522.

My repository: https://github.com/fusion44/sendmany

Any idea what might cause this? Thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Jan 8, 2020

Thanks! I was able to repro this from your video and code.

I traced the issue back to the analysis_options.yaml file in your lib folder. I believe what’s happening is the analysis server is finding that file in lib and then treating that folder as the project root - which means it doesn’t find the referenced packages. If you rename this file away and reload VS Code, the quick-fixes seem to appear.

As far as I can tell, the analysis_options.yaml file should be alongside the pubspec.yaml (see https://dart.dev/guides/language/analysis-options#the-analysis-options-file), though I do recall seeing discussion about it being nested. It’s slightly strange that if you manually add the import then things work - so it’s possible this is a bug - @bwilkerson might be able to confirm.

0reactions
DanTupcommented, Jan 10, 2020

@fusion44 based on Brian’s comment above, it sounds like this can be considered an analysis server bug, so it should be raised at https://github.com/dart-lang/sdk/issues. If the SDK is updated to handle this, it won’t require any changes in the VS Code extension.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code completion in Pycharm is not working properly
**If code completion doesn't work, this may be due to one of the following reasons:** 1.The Power Save Mode is on (File |...
Read more >
Code completion | PyCharm Documentation - JetBrains
You can create syntactically correct code constructs by using statement completion Ctrl+Shift+Enter . It inserts the necessary syntax elements ...
Read more >
IntelliSense in Visual Studio Code
IntelliSense. IntelliSense is a general term for various code editing features including: code completion, parameter info, quick info, and member lists.
Read more >
Code completion not working in 10.2 | Apple Developer Forums
Only solution that seems to work is to move the current file into the main folder from any of the sub-folders. Auto code...
Read more >
Intelligent code completion - Wikipedia
Intelligent code completion is a context-aware code completion feature in some programming environments that speeds up the process of coding applications by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found