From e437ec514251a8443e62db71d0fdae38a3118758 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 1 May 2016 18:28:21 +0200 Subject: [PATCH] IDEA-154816 Do not show "Select classes to import" when "Add imports on the fly" is enabled --- .../JavaCopyPasteReferenceProcessor.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java index 1686eab86891..70460bfca8ea 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java @@ -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; }