Skip to content

analysis_options.yaml in lib folder breaks auto-import and quick-fixes #2470

Closed

Description

@medz

Hello, after I upgraded the VS Code plug-in for Flutter and Flutter & Dart, the automatic import and quick repair functions failed!

Before I upgrade, I enter the class name under lib / or the API name exposed in the third-party package will automatically import its file.

For example, if I enter StatelessWidget, multiple options will appear:

-Import from package: flutter / material.dart.
-Import from package: flutter / widgets.dart.
...

But now there is no response after input! Just prompt me for the correct Class name, but it will no longer be automatically imported after clicking!

Before, when I manually input "StatelessWidget", for example, after the mouse is placed in the class name position, there will be multiple imported quick fixes! But now it is gone!

** I have n’t made any changes to the settings of the plugin **, it worked fine before, but it no longer works!

This is my plugin settings:

image

As you can see, I have not personalized any settings for Dart & Flutter!

The contents of my .package file are normal:

# Generated by pub on 2020-05-19 15:29:23.374474.
_fe_analyzer_shared:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/_fe_analyzer_shared-3.0.0/lib/
analyzer:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.39.8/lib/
archive:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/archive-2.0.13/lib/
args:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/args-1.6.0/lib/
async:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/async-2.4.1/lib/
boolean_selector:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/boolean_selector-2.0.0/lib/
bot_toast:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/bot_toast-3.0.0/lib/
build:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/build-1.3.0/lib/
build_config:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/build_config-0.4.2/lib/
build_daemon:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/build_daemon-2.1.4/lib/
build_resolvers:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/build_resolvers-1.3.9/lib/
build_runner:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/build_runner-1.10.0/lib/
build_runner_core:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/build_runner_core-5.2.0/lib/
built_collection:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/built_collection-4.3.2/lib/
built_value:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/built_value-7.1.0/lib/
built_value_generator:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/built_value_generator-7.1.0/lib/
cached_network_image:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/cached_network_image-2.2.0+1/lib/
charcode:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/charcode-1.1.3/lib/
checked_yaml:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/checked_yaml-1.0.2/lib/
chewie:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/chewie-0.9.10/lib/
chewie_audio:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/chewie_audio-1.0.0+1/lib/
clock:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/clock-1.0.1/lib/
code_builder:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/code_builder-3.2.1/lib/
collection:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/collection-1.14.12/lib/
convert:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/convert-2.1.1/lib/
cookie_jar:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/cookie_jar-1.0.1/lib/
crypto:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/crypto-2.1.4/lib/
css_colors:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/css_colors-1.0.2/lib/
csslib:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/csslib-0.16.1/lib/
cupertino_icons:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/cupertino_icons-0.1.3/lib/
dart_style:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/dart_style-1.3.6/lib/
dio:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/dio-3.0.9/lib/
dio_cookie_manager:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/dio_cookie_manager-1.0.0/lib/
equatable:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/equatable-1.1.1/lib/
file:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/file-5.1.0/lib/
fixnum:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/fixnum-0.10.11/lib/
flutter:file:///Users/seven/Desktop/work/flutter/packages/flutter/lib/
flutter_cache_manager:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/flutter_cache_manager-1.2.2/lib/
flutter_html:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/flutter_html-1.0.0/lib/
flutter_localizations:file:///Users/seven/Desktop/work/flutter/packages/flutter_localizations/lib/
flutter_plugin_android_lifecycle:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/flutter_plugin_android_lifecycle-1.0.7/lib/
flutter_screenutil:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/flutter_screenutil-1.1.0/lib/
flutter_staggered_grid_view:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/flutter_staggered_grid_view-0.3.0/lib/
flutter_svg:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/flutter_svg-0.17.4/lib/
flutter_test:file:///Users/seven/Desktop/work/flutter/packages/flutter_test/lib/
flutter_web_plugins:file:///Users/seven/Desktop/work/flutter/packages/flutter_web_plugins/lib/
fluwx:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/fluwx-2.1.0/lib/
geolocator:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/geolocator-5.3.1/lib/
glob:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/glob-1.2.0/lib/
google_api_availability:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/google_api_availability-2.0.4/lib/
graphs:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/graphs-0.2.0/lib/
html:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/html-0.14.0+3/lib/
http:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/http-0.12.1/lib/
http_multi_server:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/http_multi_server-2.2.0/lib/
http_parser:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/http_parser-3.1.4/lib/
image:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/image-2.1.12/lib/
image_cropper:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/image_cropper-1.2.2/lib/
image_gallery_saver:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/image_gallery_saver-1.2.2/lib/
image_picker:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.6+1/lib/
image_picker_platform_interface:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/image_picker_platform_interface-1.0.0/lib/
install_plugin:file:///Users/seven/.pub-cache/git/flutter_install_plugin-4244b1ae9002f57c41fc5bae61a17f3ca51685ab/lib/
intl:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/intl-0.16.1/lib/
io:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/io-0.3.4/lib/
jpush_flutter:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/jpush_flutter-0.5.5/lib/
js:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/js-0.6.1+1/lib/
json_annotation:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/json_annotation-3.0.1/lib/
location_permissions:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/location_permissions-2.0.5/lib/
logging:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/logging-0.11.4/lib/
matcher:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.6/lib/
meta:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/meta-1.1.8/lib/
mime:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/mime-0.9.6+3/lib/
multi_image_picker:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/multi_image_picker-4.6.7/lib/
nested:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/nested-0.0.4/lib/
node_interop:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/node_interop-1.1.1/lib/
node_io:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/node_io-1.1.1/lib/
numeral:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/numeral-1.0.4/lib/
open_iconic_flutter:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/open_iconic_flutter-0.3.0/lib/
package_config:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/package_config-1.9.3/lib/
package_info:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/package_info-0.4.0+18/lib/
path:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/path-1.6.4/lib/
path_drawing:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/path_drawing-0.4.1/lib/
path_parsing:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/path_parsing-0.1.4/lib/
path_provider:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.8/lib/
path_provider_macos:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/path_provider_macos-0.0.4+2/lib/
path_provider_platform_interface:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/path_provider_platform_interface-1.0.2/lib/
pedantic:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/pedantic-1.9.0/lib/
permission_handler:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/permission_handler-5.0.0+hotfix.6/lib/
permission_handler_platform_interface:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/permission_handler_platform_interface-2.0.0/lib/
petitparser:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/petitparser-2.4.0/lib/
photo_view:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/photo_view-0.9.2/lib/
platform:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/platform-2.2.1/lib/
plugin_platform_interface:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/plugin_platform_interface-1.0.2/lib/
pool:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/pool-1.4.0/lib/
provider:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/provider-4.1.2/lib/
pub_semver:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/pub_semver-1.4.4/lib/
pubspec_parse:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/pubspec_parse-0.1.5/lib/
pull_to_refresh:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/pull_to_refresh-1.5.8/lib/
qr:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/qr-1.2.0/lib/
qr_flutter:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/qr_flutter-3.2.0/lib/
quiver:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/quiver-2.1.3/lib/
rxdart:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/rxdart-0.24.1/lib/
screen:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/screen-0.0.5/lib/
share:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/share-0.6.4+2/lib/
shared_preferences:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.7+2/lib/
shared_preferences_macos:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_macos-0.0.1+8/lib/
shared_preferences_platform_interface:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_platform_interface-1.0.4/lib/
shared_preferences_web:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-0.1.2+5/lib/
shelf:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/shelf-0.7.5/lib/
shelf_web_socket:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/shelf_web_socket-0.2.3/lib/
sky_engine:file:///Users/seven/Desktop/work/flutter/bin/cache/pkg/sky_engine/lib/
snsmax_localization:file:///Users/seven/.pub-cache/git/snsmax_localization-d283c5b3e1602224d70d9a34bb9903b193011b03/lib/
source_gen:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/source_gen-0.9.5/lib/
source_span:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/source_span-1.7.0/lib/
sqflite:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.0+1/lib/
sqflite_common:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/sqflite_common-1.0.1/lib/
stack_trace:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/stack_trace-1.9.3/lib/
stream_channel:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/stream_channel-2.0.0/lib/
stream_transform:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/stream_transform-1.2.0/lib/
string_scanner:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/string_scanner-1.0.5/lib/
synchronized:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/synchronized-2.2.0/lib/
term_glyph:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/term_glyph-1.1.0/lib/
test_api:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/test_api-0.2.15/lib/
timing:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/timing-0.1.1+2/lib/
typed_data:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/typed_data-1.1.6/lib/
url_launcher:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.4.7/lib/
url_launcher_macos:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_macos-0.0.1+5/lib/
url_launcher_platform_interface:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_platform_interface-1.0.7/lib/
url_launcher_web:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_web-0.1.1+5/lib/
uuid:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/uuid-2.0.4/lib/
vector_math:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/vector_math-2.0.8/lib/
video_player:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/video_player-0.10.11/lib/
video_player_platform_interface:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/video_player_platform_interface-2.0.2/lib/
video_player_web:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/video_player_web-0.1.3/lib/
wakelock:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.1.4+1/lib/
watcher:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/watcher-0.9.7+15/lib/
web_socket_channel:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/web_socket_channel-1.1.0/lib/
webview_flutter:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.21/lib/
xml:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/xml-3.6.1/lib/
yaml:file:///Users/seven/.pub-cache/hosted/pub.flutter-io.cn/yaml-2.2.1/lib/
app:lib/

A small video was recorded to watch the current situation:

https://github.com/medz/wtf/blob/master/QQ20200519-171917-HD.mp4

Activity

  1. medz commented on May 19, 2020

    @medz
    Author

    I tried to delete flutter and dart, as well as the generated cache and configuration files, and uninstall the VS Code plugin and then reinstall all to solve this problem, but I failed!

  2. medz commented on May 19, 2020

    @medz
    Author

    Show information about the installed tooling:

    image

  3. medz commented on May 19, 2020

    @medz
    Author

    .dart_tool/package_config.json

    image

  4. medz commented on May 19, 2020

    @medz
    Author

    My VS Code plugins:

    image

  5. DanTup commented on May 19, 2020

    @DanTup
    Member

    @medz thanks for the detailed info and video! In the video, the completions are not showing the "auto import" text against them asI'd expect:

    Screenshot 2020-05-19 at 11 57 07

    Here's how they look for me:

    Screenshot 2020-05-19 at 11 57 16

    A few things to check:

    • Auto import completions are still enabled:
      Screenshot 2020-05-19 at 11 59 08
    • There are no errors in the VS Code dev console (click Help -> Toggle Developer Tools then the Console tab)
    • Does it happen only in this project, or also in a new project created with Flutter: New Project?
    • Try enabling the analysis server log and capture a log while reproducing this (doing this on a new clean project would be best so there's less logged)
  6. added
    awaiting infoRequires more information from the customer to progress
    on May 19, 2020
  7. medz commented on May 19, 2020

    @medz
    Author

    @DanTup

    Auto import completions are still enabled: true
    image

    There are no errors in the VS Code dev console:
    image

    Q: Does it happen only in this project, or also in a new project created with Flutter: New Project?
    A: Only exists in existing projects

  8. medz commented on May 19, 2020

    @medz
    Author

    Create a new flutter or dart project is ok.

    I compared the caches of various projects, and they are all ok. Very strange question! I have tried to solve this problem for about a week, and there is no progress at present.

  9. DanTup commented on May 19, 2020

    @DanTup
    Member

    Just to be sure, you don't have the setting overriden in the workspace/folder?

    Screenshot 2020-05-19 at 12 22 51

    Otherwise, are you able to capture a log mentioned above for your main project (please check it contains nothing sensitive before sharing - you can email it to me at [email protected] if you don't want to attach it here).

  10. medz commented on May 19, 2020

    @medz
    Author
  11. medz commented on May 19, 2020

    @medz
    Author

    I don't know how to capture this log😭

  12. medz commented on May 19, 2020

    @medz
    Author

    @DanTup I think I found the problem. I created an analysis_options.yaml file and put it in the lib directory by mistake!

  13. medz commented on May 19, 2020

    @medz
    Author

    OMG!
    This bug caused by this reason is simply too weird. . . I used the most stupid method, created a new flutter project, and then copied a small number of files to the new project one by one, and then tested whether auto import was normal. In the end, it was caused by incorrectly placing the analysis_options.yaml file. . .

  14. DanTup commented on May 19, 2020

    @DanTup
    Member

    @medz glad you tracked it down! Though this sounds like a strange way for things to fail. I'll do some testing to see if I can reproduce here, and if so, see if we can find some better way to handle this than things being subtly broken!

  15. 12 remaining items

  16. modified the milestones: v3.11.0, On Deck on May 20, 2020
  17. DanTup commented on Jun 2, 2020

    @DanTup
    Member

    @scheglov any thoughts on the above? I think apiContextRoots.first is the cause of this, but I don't understand the correct way to fix it.

  18. scheglov commented on Jun 10, 2020

    @scheglov

    This is not something I could solve easily.
    I consider the current implementation of DAS as a technical debt.
    I'd like to see it reimplemented on top of AnalysisContextCollection.

  19. DanTup commented on Jun 17, 2020

    @DanTup
    Member

    @scheglov is that a big job? Would it be worth generating a warning if there's an analysis_options.yaml in a folder that's not the project root in the meantime?

  20. scheglov commented on Jun 17, 2020

    @scheglov

    If we ignore these extra analysis_options.yaml files in all analyzer tools (DAS and command-line analyzer), then it makes sense to warn the user about this.

  21. modified the milestones: On Deck, Backlog on Jul 2, 2020
  22. modified the milestones: On Deck, v3.106.0 on Feb 10, 2025
  23. DanTup commented on Feb 10, 2025

    @DanTup
    Member

    I'm unable to reproduce this on latest code. Probably it was either fixed by the move off Available Declarations, or the recent changes to not produce additional contexts for nested analysis_options.yaml files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions