IDEA-154816 Do not show "Select classes to import" when "Add imports on the fly"...
authorpeter <peter@jetbrains.com>
Sun, 1 May 2016 16:28:21 +0000 (18:28 +0200)
committerpeter <peter@jetbrains.com>
Mon, 2 May 2016 06:58:56 +0000 (08:58 +0200)
java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java

index 1686eab868916c5e204a243ffbd6af3108d76bbe..70460bfca8ea6ed284e190542311d9b6ea02b7a4 100644 (file)
@@ -15,6 +15,8 @@
  */
 package com.intellij.codeInsight.editorActions;
 
+import com.intellij.codeInsight.CodeInsightSettings;
+import com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFix;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.util.TextRange;
@@ -100,6 +102,16 @@ public class JavaCopyPasteReferenceProcessor extends CopyPasteReferenceProcessor
         }
       }
     }
+
+    if (CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY) {
+      for (int i = 0; i < refs.length; i++) {
+        PsiJavaCodeReferenceElement ref = refs[i];
+        if (ref != null && new ImportClassFix(ref).getClassesToImport().size() <= 1) {
+          refs[i] = null;
+        }
+      }
+    }
+
     return refs;
   }