Skip to content

Missing import suggestions #30295

Open
Open

Description

@JFixby

Reproduction steps:

Example project: https://github.com/JFixby/DartImportsExample

class A located in the lib/folderA/class_a_file.dart
content:

class A {
  static String fieldF = "";
}

class C located in the lib/class_c_depends_on_a.dart depends on the A
content:

class C {
  C() {
    // editing this line
  }
}

What was done

print A. in the constructor of the class C

What is expected

to see a list of suggested imports with proposal to import lib/folderA/class_a_file.dart

What is actually happening

no relevant suggestions

image

Setup

IDEA version: community 2017.2
Dart plugin: 172.3317.48

Activity

  1. alexander-doroshko commented on Aug 15, 2017

    @alexander-doroshko

    @JFixby, your screenshot shows code completion popup. Code completion suggests items that may appear at the caret position. Import statement can't appear after A., that's why you do not see it.

    You'll get a suggestion to add import if you invoke quick fix on red code (Alt+Enter):
    image

    It would be great if code completion helped to write class names from files that are not imported yet and auto-imserted required import statements. Since code completion is powered by the Analysis Server this issue is tracked at SDK end, see #25820 and #21931.

    As for this issue, I think it can be closed.

  2. JFixby commented on Aug 15, 2017

    @JFixby
    Author

    I'll use Eclipse to illustrate what I mean:

    Write Collections. and it shows list of suggested methods of different classes that have name Collections.
    Clicking on a suggestion auto-completes statement and adds related import.

    Saves a lot of time.

    image

  3. JFixby commented on Aug 15, 2017

    @JFixby
    Author

    Please treat it as a feature request and re-open.

  4. alexander-doroshko commented on Aug 15, 2017

    @alexander-doroshko

    Thanks for the example! This is pretty much similar to what is asked in #25820 and #21931. Ok, I'm reopening and moving to area-analyzer. Let @bwilkerson take another look.

  5. added
    P2A bug or feature request we're likely to work on
    on Aug 16, 2017
  6. added
    devexp-serverIssues related to some aspect of the analysis server
    on Jun 8, 2020
  7. added
    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
    and removed on Feb 25, 2025
  8. FMorschel commented on Sep 7, 2026

    @FMorschel
    Contributor
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

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-serverIssues related to some aspect of the analysis servertype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions