Code completion adds prefix to imports in IntelliJ 2019.1

@gastonmuijtjens commented on May 8, 2019, 2:34 PM UTC:

Accepting classes from code completion sometimes adds “prefix0” to the auto import. This happens in IntelliJ IDEA 2019.1, but does not seem to happen in Android Studio 3.4.

This only seems to happen when there is another instance of the class already in the same file and is added on one of the lines above where this class is used. Accepting the code completion when using the same class again on one of the lines after does not seem to cause problems.

See the attached GIF for an example:
ezgif-3-f114787acdc7

Steps to Reproduce

  • Pressing enter on code completion of a class, when the class is already defined somewhere else in the file and the new definition is on one of the lines above (see attached GIF).

Version info

[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E226, locale
    en-US)
    • Flutter version 1.5.4-hotfix.2 at /usr/local/Custom/flutter
    • Framework revision 7a4c33425d (9 days ago), 2019-04-29 11:05:24 -0700
    • Engine revision 52c7a1e849
    • Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/gastonmuijtjens/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1343-b01)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit
      https://flutter.dev/setup/#android-setup for detailed instructions.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2.1, Build version 10E1001
    • ios-deploy 1.9.4
    • CocoaPods version 1.6.1

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 35.2.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1343-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 35.2.3
    • Dart plugin version 191.7141.44

[✓] VS Code (version 1.33.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.0.0

[✓] Connected device (1 available)
    • Android SDK built for x86 64 • emulator-5554                        •
      android-x64 • Android 9 (API 28) (emulator)

! Doctor found issues in 1 category.

This issue was moved by devoncarew from flutter/flutter-intellij#3475.

Author: Fantashit

4 thoughts on “Code completion adds prefix to imports in IntelliJ 2019.1

  1. I’m having this same issue for months. If there is anything I can help with, just ask!

    [√] Flutter (Channel stable, v1.7.8+hotfix.4, on Microsoft Windows [versão 10.0.17763.615], locale pt-BR)
    [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [√] Android Studio (version 3.4)
    [√] IntelliJ IDEA Community Edition (version 2019.2)
    [√] Connected device (1 available)
    

    I don’t know if this can be related but, sometimes the auto complete gives me the same options twice:
    image

    image

    One completion suggests the library name as the import. The other completion suggests me to import only the file.

  2. I had to remove adding import prefixes in 4f8f592. So, going forward this problem should be “fixed”. Unfortunately I don’t know how to check into which Flutter version this change to Dart SDK is included.

  3. That change is in Dart 2.6.0-dev.2.0, but stable Flutter is only Dart v2.5.0.

    As far as I can tell, beta, dev and master channels are all > 2.6.0-dev.2.0, so the issue should be fixed in any of those.

Comments are closed.