IDEA-52846: Auto Import does not work in JSPs
authorDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Tue, 16 Mar 2010 16:42:11 +0000 (19:42 +0300)
committerDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Tue, 16 Mar 2010 16:42:11 +0000 (19:42 +0300)
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java

index 8803aa9b312379999f0437b55a1b21fcffbacb6a..4ab6dc317deb399c4562fbafc1179d8534aa6378 100644 (file)
@@ -141,6 +141,7 @@ public abstract class ImportClassFixBase<T extends PsiElement & PsiReference> im
     if (classes.length == 1
         && (canImportHere = canImportHere(allowCaretNearRef, editor, psiFile, classes[0].getName()))
         && CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY
+        && !JspPsiUtil.isInJspFile(psiFile)
         && codeAnalyzer.canChangeFileSilently(psiFile)) {
       CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
         public void run() {
@@ -152,7 +153,9 @@ public abstract class ImportClassFixBase<T extends PsiElement & PsiReference> im
 
     if (doShow && canImportHere) {
       String hintText = ShowAutoImportPass.getMessage(classes.length > 1, classes[0].getQualifiedName());
-      HintManager.getInstance().showQuestionHint(editor, hintText, myRef.getTextOffset(), myRef.getTextRange().getEndOffset(), action);
+      if (!ApplicationManager.getApplication().isUnitTestMode()) {
+        HintManager.getInstance().showQuestionHint(editor, hintText, myRef.getTextOffset(), myRef.getTextRange().getEndOffset(), action);
+      }
       return Result.POPUP_SHOWN;
     }
     return Result.POPUP_NOT_SHOWN;
@@ -160,7 +163,6 @@ public abstract class ImportClassFixBase<T extends PsiElement & PsiReference> im
 
   private boolean canImportHere(boolean allowCaretNearRef, Editor editor, PsiFile psiFile, String exampleClassName) {
     return (allowCaretNearRef || !isCaretNearRef(editor, myRef)) &&
-           !JspPsiUtil.isInJspFile(psiFile) &&
            !hasUnresolvedImportWhichCanImport(psiFile, exampleClassName);
   }