Skip to content

CompletionSuggestion auto-imports don't work for plugin-contributed completions #4275

Closed

Description

@zmtzawqlp

I'm making a plugin base on analyzer_plugin and follow the doc https://github.com/dart-lang/sdk/blob/master/pkg/analyzer_plugin/doc/tutorial/completion.md

The problem is that libraryUri is set and isNotImported is set to true, but it still has not 'auto import from xxx' in completion.

  /// This field is omitted if getSuggestions was used rather than
  /// getSuggestions2.
  ///
  /// This field is omitted if this suggestion corresponds to a locally
  /// declared element.
  ///
  /// If this suggestion corresponds to an already imported element, then this
  /// field is the URI of a library that provides this element, not the URI of
  /// the library where the element is declared.
  ///
  /// If this suggestion corresponds to an element from a not yet imported
  /// library, this field is the URI of a library that could be imported to
  /// make this suggestion accessible in the file where completion was
  /// requested, such as package:foo/bar.dart or
  /// file:///home/me/workspace/foo/test/bar_test.dart.
  String? libraryUri;

  /// True if the suggestion is for an element from a not yet imported library.
  /// This field is omitted if the element is declared locally, or is from
  /// library is already imported, so that the suggestion can be inserted as
  /// is, or if getSuggestions was used rather than getSuggestions2.
  bool? isNotImported;

i found the comment at
dart-lang/sdk#38894 (comment). it's only happen in vscode, have any update for this? thanks.

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Nov 18, 2022
  2. changed the title [-]CompletionSuggestion not support auto import from library in vscode[/-] [+]CompletionSuggestion auto-imports don't work for plugin-contributed completions[/+] on Nov 23, 2022
  3. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    and removed
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Nov 23, 2022
  4. added this to the v3.54.0 milestone on Nov 23, 2022
  5. DanTup commented on Nov 23, 2022

    @DanTup
    Member

    I have a fix for review at https://dart-review.googlesource.com/c/sdk/+/271701.

    This change is in the Dart SDK so (once merged) the fix will only show up in a future Dart SDK release (and not a VS Code extension release).

  6. DanTup commented on Nov 23, 2022

    @DanTup
    Member

    This is fixed by dart-lang/sdk@019fb7a and will ship in a future release of the Dart SDK. If you need to test this sooner, you could use a dev SDK from https://dart.dev/get-dart/archive#dev-channel once the release date shown is newer than todays date.

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 bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions