Skip to content

suggest identifiers that are not yet imported #25820

Closed

Description

@danrubel
No description provided.

Activity

  1. alexander-doroshko commented on Feb 19, 2016

    @alexander-doroshko

    Will this suggestion have a SourceEdit for the IDE to insert import (or to modify show/hide list)?

  2. danrubel commented on Feb 19, 2016

    @danrubel
    Author

    Yes.

  3. added
    P2A bug or feature request we're likely to work on
    and removed on Mar 1, 2016
  4. danrubel commented on Sep 14, 2016

    @danrubel
    Author

    When implementing this, we should be sure not to suggest test classes when completing in lib directory.

  5. danrubel commented on Oct 10, 2016

    @danrubel
    Author

    To correctly implement this we must only suggest unimported types appropriate for the file being edited. More specifically...

    • when editing a file in the lib/ directory, we should only suggest types in the lib/ directory or in packages in the dependencies: section of the pubspec.yaml.
    • when editing a file in the bin/, example/, or web/ directories, we should only suggest types in that directory or the lib/ directory or in packages in the dependencies: section of the pubspec.yaml.
    • when editing other files, we can suggest types anywhere in the package or in either the dependencies: or dev_dependencies: sections of the pubspec.yaml.
    • when suggesting types from other packages, do not suggest types only accessible from lib/src (internal by convention) similar to what was done for Quick Fix

    The blocking issue is that currently, there is no way for the completion service to know which packages are listed in dependencies: or dev_dependencies: sections of the pubspec.yaml.

  6. davidmorgan commented on Dec 1, 2016

    @davidmorgan
    Contributor

    Am I right in thinking that this issue covers auto-completing to methods of types I haven't imported yet?

    i.e. if I type 'new Foo()..', and 'Foo' is not imported, it will still suggest completions that come from Foo?

    This is something I miss from IntelliJ's Java behaviour -- it means you can write a whole line of code before going back to add the import.

    Thanks!

  7. danrubel commented on Dec 1, 2016

    @danrubel
    Author

    Yes. Implementing it correctly (see above) means some additional low level functionality in analyzer in addition to the code completion mods.

    This is something I'd definitely like to see added, but have not had the cycles to get to it. There's a laundry list of things to do and I don't have a good feel for where this one fits in the priority list.

  8. davidmorgan commented on Dec 1, 2016

    @davidmorgan
    Contributor

    Thanks. I will stay subscribed ;)

  9. manuelF commented on Dec 2, 2016

    @manuelF

    +1, this would be super handy to make the IDE a more seamless experience.

  10. hooluupog commented on Oct 3, 2017

    @hooluupog

    +1, it's one of must-have features i am using everyday in Go( Goimports is automatically ran on every save of file to fix imports and format code).

  11. scheglov commented on Apr 1, 2018

    @scheglov
    Contributor

    @davidmorgan, answering on your question in #25820 (comment), my understanding is that answer is "no". This issue is about suggesting imports for top-level declarations from not yet imported libraries. What you are asking is kind of "speculative" resolution of some identifiers, even if there is no corresponding import, pretend that there is one. In theory this could be done, but why? If there is a missing import and you get a compilation error, use the Quick Fix and then get further analysis and code completion.

    @danrubel is right in #25820 (comment) that we need to suggest only identifiers from libraries that are potentially accessible in the source library. But that's not the same as resolution without imports.

  12. 9 remaining items

  13. kandroid29 commented on Feb 26, 2019

    @kandroid29

    Having to move up and down to add the import for a class is a very bad experience, it is waste of time and distraction from what I am doing. So I think auto import suggestion is a required feature for modern IDE.

  14. scheglov commented on Feb 26, 2019

    @scheglov
    Contributor

    FYI, we implemented this, you probably will get it with the next IntelliJ and Dart SDK build.
    JetBrains/intellij-plugins#637

    It will show everything available to you, prioritizing libraries that are already imports (because for these you have already made your choice), and adding new imports with or without import prefix depending on whether the new import will introduce ambiguity or will be shadowed at the port of usage.

    Bonus point is that because available declarations are cached on the client (IntelliJ), we have to transfer much less data, so completions are faster. I saw improvements from 53 ms for about 1600 completions, to 5 ms when producing 5000+ completions.

    image

  15. kandroid29 commented on Feb 26, 2019

    @kandroid29

    @scheglov great! will this also be supported in Android Studio?

  16. scheglov commented on Feb 26, 2019

    @scheglov
    Contributor

    Yes, Android Studio uses the same Dart Analysis Server, and the same Dart plugin for IntelliJ.
    When specifically, I don't know, maybe @stevemessick ?

  17. 12people commented on Mar 24, 2019

    @12people

    How about Visual Studio Code? How can I make autoimport work there.

  18. DanTup commented on Mar 25, 2019

    @DanTup
    Collaborator

    @12people VS Code work is being tracked at Dart-Code/Dart-Code#1060. I'd like to have some additional testing before it's included in a release - if you're interested in trying it out with a preview build, please drop a comment on that issue.

  19. passsy commented on Mar 25, 2019

    @passsy

    I just tested version 191.6183.41. Suggestions of Future and List works but I don't get any suggestions for 3rd party classes, i.e. ListMultimap from quiver as shown in the screenshot above. (yes, I added the dependency)

    Screen-Shot-2019-03-25-10-51-17 06

  20. alexander-doroshko commented on Apr 1, 2019

    @alexander-doroshko

    @passsy, try with the latest Dart SDK 2.2.1-dev.x.x release.

  21. passsy commented on Apr 3, 2019

    @passsy

    I can confirm it is now working with

    • IntelliJ IDEA 2019.1 (Ultimate Edition) Build #IU-191.6183.87, built on March 27, 2019
    • Dart VM version: 2.2.0 (Tue Feb 26 15:04:32 2019 +0100) on "macos_x64"
    • Dart plugin version 191.6183.88 from Apr 02, 2019
  22. vrendina commented on May 28, 2019

    @vrendina

    Android Studio 3.4.1 seems to be pretty far behind IntelliJ IDEA 2019.1.2 with their Dart plugin version and was lacking this functionality even though it has been available for 2 months. Moving from Android Studio to IntelliJ for Flutter development!

  23. shinayser commented on Oct 14, 2019

    @shinayser

    I am having problem with auto completing the new Extension Functions from dart 2.6.0. I have added a new file called "time.dart" with some extensions, like this:

    image

    My main file just can't auto complete it. If I try to fix the error I get the following:

    image

    As soon as I move the extensions to the same file as main, everything works:

    image

    If I add the import manually, it also works:

    image

    My Dart for Intellij plugin version is 192.6817.14

  24. scheglov commented on Oct 14, 2019

    @scheglov
    Contributor

    @shinayser Please open a new issue https://github.com/dart-lang/sdk/issues.

    Auto-import for extensions probably will not work, because auto-import works syntactically, i.e. we just know top-level names to include. But for extensions we need to match on clauses against target expressions.

    We might implement quick fix.

  25. cyberpwnn commented on Nov 19, 2020

    @cyberpwnn

    A core feature of an IDE tool / SDK has still yet to be implemented... or work if it is. Is there an eta when I can write at normal speeds in dart?

  26. bwilkerson commented on Nov 19, 2020

    @bwilkerson
    Member

    Which IDE / editor are you using? The functionality is working in several editors, so I'm wondering whether the problem is specific to some editors.

    Can you provide us with an example of a case in which it fails to work? There are a couple of known exceptions where it doesn't yet work, but the issue was closed because it appears to be working in general and we prefer having finer-grained issues when a piece of a feature is broken.

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

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work ondevexp-completionIssues with the analysis server's code completion featurelegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions