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

CompletionSuggestion not support auto import from library in vscode #50449

Closed
zmtzawqlp opened this issue Nov 12, 2022 · 7 comments
Closed

CompletionSuggestion not support auto import from library in vscode #50449

zmtzawqlp opened this issue Nov 12, 2022 · 7 comments
Labels
analyzer-completion Issues with the analysis server's code completion feature analyzer-plugin area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request

Comments

@zmtzawqlp
Copy link
Contributor

This tracker is for issues related to:

  • Analyzer

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. do i miss anything? or how can i do a completion with auto import library, thanks.

  /// 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;
@zmtzawqlp
Copy link
Contributor Author

maybe useNotImportedCompletions is not true at my side, but how can i set it?

@vsmenon vsmenon added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Nov 12, 2022
@pq pq added analyzer-completion Issues with the analysis server's code completion feature analyzer-plugin P3 A lower priority bug or feature request labels Nov 14, 2022
@pq
Copy link
Member

pq commented Nov 14, 2022

@bwilkerson @scheglov ?

@zmtzawqlp
Copy link
Contributor Author

class CompletionGetSuggestions2Result implements ResponseResult {

it seems that only analysis_server can use CompletionGetSuggestions2Result(completion.getSuggestions2).

in analyzer_plugin , it still CompletionGetSuggestionsResult.

/// Handle a 'completion.getSuggestions' request.
///
/// Throw a [RequestFailure] if the request could not be handled.
Future<CompletionGetSuggestionsResult> handleCompletionGetSuggestions(
    CompletionGetSuggestionsParams parameters) async {
  return CompletionGetSuggestionsResult(
      -1, -1, const <CompletionSuggestion>[]);
}

so libraryUri is omitted, right? in this case, then what time could we use this api? thanks for your time.

@bwilkerson
Copy link
Member

tl;dr Maybe never.

The analyzer_plugin package is an unsupported prototype of one possible way that we could support plugins for the analyzer. We actively discourage its use. And because it's not supported we don't have any plans to enhance its functionality. We do occasionally improve the code because the analysis server makes use of some of that code, but that only happens when doing so is the most convenient way for us to improve the analysis server.

@zmtzawqlp
Copy link
Contributor Author

zmtzawqlp commented Nov 16, 2022

I'm sad to heart that. analyzer_plugin is useful for who want to add custom lints or completions, it provides the possibility. Thank you all the same, please keep this issue open in case any update.

@zmtzawqlp
Copy link
Contributor Author

it seems that it support in android studio but fail in vscode, does vscode have limitation ?

@zmtzawqlp zmtzawqlp changed the title CompletionSuggestion not support auto import from library CompletionSuggestion not support auto import from library in vscode Nov 18, 2022
@DanTup
Copy link
Collaborator

DanTup commented Dec 15, 2022

This was fixed by 019fb7a (more info in Dart-Code/Dart-Code#4275 which was the same report).

@DanTup DanTup closed this as completed Dec 15, 2022
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 analyzer-plugin area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

5 participants