Inspections - pass onTheFly into ProblemDescriptors & use it to create LAZY refs...
authorAlexey Gopachenko <alexey.gopachenko@jetbrains.com>
Tue, 10 Nov 2009 20:35:38 +0000 (23:35 +0300)
committerAlexey Gopachenko <alexey.gopachenko@jetbrains.com>
Tue, 10 Nov 2009 20:35:38 +0000 (23:35 +0300)
68 files changed:
java/java-impl/src/com/intellij/codeInspection/LossyEncodingInspection.java
java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java
java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java
java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java
java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java
java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java
java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java
java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java
java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java
java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocLocalInspection.java
java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java
java/java-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java
java/java-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java
java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantArrayForVarargsCallInspection.java
java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java
java/java-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java
java/java-impl/src/com/intellij/codeInspection/sameParameterValue/SameParameterValueInspection.java
java/java-impl/src/com/intellij/codeInspection/sameReturnValue/SameReturnValueInspection.java
java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java
java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java
java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java
java/java-impl/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java
java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java
java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java
java/java-tests/testSrc/com/intellij/codeInspection/InlineSameParameterValueTest.java
platform/lang-api/src/com/intellij/codeInspection/InspectionManager.java
platform/lang-api/src/com/intellij/codeInspection/ProblemDescriptor.java
platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java
platform/lang-impl/src/com/intellij/codeInspection/GlobalInspectionUtil.java
platform/lang-impl/src/com/intellij/codeInspection/SyntaxErrorInspection.java
platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java
platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java
platform/lang-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java
platform/lang-impl/src/com/intellij/codeInspection/ex/ProblemDescriptorImpl.java
platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java
plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java
plugins/InspectionGadgets/src/com/siyeh/ig/global/BooleanFieldAlwaysNegatedInspection.java
plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysConstantInspection.java
plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysIgnoredInspection.java
plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateImportedTargetsInspection.java
plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateTargetsInspection.java
plugins/ant/src/com/intellij/lang/ant/validation/AntMissingPropertiesFileInspection.java
plugins/devkit/src/inspections/ComponentNotRegisteredInspection.java
plugins/devkit/src/inspections/DescriptionNotFoundInspection.java
plugins/devkit/src/inspections/RegistrationProblemsInspection.java
plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspection.java
plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java
plugins/java-i18n/src/com/intellij/codeInspection/i18n/InconsistentResourceBundleInspection.java
plugins/java-i18n/src/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspection.java
plugins/java-i18n/src/com/intellij/lang/properties/UnusedMessageFormatParameterInspection.java
plugins/properties/src/com/intellij/codeInspection/duplicatePropertyInspection/DuplicatePropertyInspection.java
plugins/properties/src/com/intellij/lang/properties/UnusedPropertyInspection.java
plugins/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java
plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnGroupsInspection.java
plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnMethodInspection.java
plugins/testng/src/com/theoryinpractice/testng/inspection/JUnitConvertTool.java
plugins/testng/src/com/theoryinpractice/testng/inspection/UndeclaredTestInspection.java
plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java
plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormFileErrorCollector.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/CheckNodeTest.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/HardwiredNamespacePrefix.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/ImplicitTypeConversion.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/IndexZeroPredicate.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/RedundantTypeConversion.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/XPathInspection.java
samples/comparingReferences/source/com/intellij/codeInspection/ComparingReferencesInspection.java
xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsHighlightingUtil.java

index 407f2926f68daf0a91a893eae08b5e3f5c7a2513..9e8514d95b170239d66fb0840103fe7a82c3f8b0 100644 (file)
@@ -76,7 +76,7 @@ public class LossyEncodingInspection extends BaseJavaLocalInspectionTool {
       if (isRepresentable(c, charset)) {
         if (start != -1) {
           ProblemDescriptor descriptor = manager.createProblemDescriptor(file, new TextRange(start, i), InspectionsBundle.message(
-            "unsupported.character.for.the.charset", charset), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+            "unsupported.character.for.the.charset", charset), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
           descriptors.add(descriptor);
           start = -1;
 
@@ -92,7 +92,7 @@ public class LossyEncodingInspection extends BaseJavaLocalInspectionTool {
     }
     if (start != -1) {
       ProblemDescriptor descriptor = manager.createProblemDescriptor(file, new TextRange(start, text.length()), InspectionsBundle.message(
-        "unsupported.character.for.the.charset", charset), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+        "unsupported.character.for.the.charset", charset), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
       descriptors.add(descriptor);
     }
 
@@ -105,4 +105,4 @@ public class LossyEncodingInspection extends BaseJavaLocalInspectionTool {
     CharBuffer buffer = charset.decode(out);
     return str.equals(buffer.toString());
   }
-}
\ No newline at end of file
+}
index f8155df3d035f8276ee5e64b08143d52ad2577c8..c4bc71b35a30926d8658bda2405c513ba91d1f10 100644 (file)
@@ -229,7 +229,8 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{
               if (identifier == null) {
                 identifier = psiMember;
               }
-              result.add(manager.createProblemDescriptor(identifier, description, (LocalQuickFix)fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+              result.add(manager.createProblemDescriptor(identifier, description, (LocalQuickFix)fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                         false));
             }
           }
         }
index 641934454211a8f97f9ec4a43aa18f029ec7f0e7..e1269c8cb59c773f47ff2b7024b6bdfb64be63c8 100644 (file)
@@ -162,7 +162,7 @@ public class CanBeFinalInspection extends GlobalJavaInspectionTool {
       if (psiIdentifier != null) {
         return new ProblemDescriptor[]{manager.createProblemDescriptor(psiIdentifier, InspectionsBundle.message(
           "inspection.export.results.can.be.final.description"), new AcceptSuggested(globalContext.getRefManager()),
-                                                                 ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
+                                                                 ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false)};
       }
     }
     return null;
index 1d350f2a16c652b3553bffeaee2bf56f5db3d752..2e420ba2e7fa5b07fcd177b74e9deaaf347d1fc4 100644 (file)
@@ -40,11 +40,13 @@ class CatchBodyVisitor extends JavaRecursiveElementWalkingVisitor {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.defaultFileTemplateUsage.CatchBodyVisitor");
 
   Collection<ProblemDescriptor> myProblemDescriptors;
+  private boolean myOnTheFly;
   private final InspectionManager myManager;
 
-  public CatchBodyVisitor(InspectionManager manager, Collection<ProblemDescriptor> descriptors) {
+  public CatchBodyVisitor(InspectionManager manager, Collection<ProblemDescriptor> descriptors, boolean onTheFly) {
     myManager = manager;
     myProblemDescriptors = descriptors;
+    myOnTheFly = onTheFly;
   }
 
   @Override public void visitCatchSection(PsiCatchSection section) {
@@ -104,7 +106,8 @@ class CatchBodyVisitor extends JavaRecursiveElementWalkingVisitor {
     }
     Pair<? extends PsiElement, ? extends PsiElement> range = DefaultFileTemplateUsageInspection.getInteriorRange(catchBlock);
     final String description = InspectionsBundle.message("default.file.template.description");
-    ProblemDescriptor descriptor = myManager.createProblemDescriptor(range.first, range.second, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, createQuickFix(section));
+    ProblemDescriptor descriptor = myManager.createProblemDescriptor(range.first, range.second, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                     myOnTheFly, createQuickFix(section));
     myProblemDescriptors.add(descriptor);
   }
 
index 612f8e3ffaedcb1468fbacb68bed1030c7fddbc7..d1156a131a07890fce8be9eef144ee426d8866a2 100644 (file)
@@ -59,10 +59,10 @@ public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionT
   public ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) {
     Collection<ProblemDescriptor> descriptors = new ArrayList<ProblemDescriptor>();
     if (CHECK_METHOD_BODY) {
-      MethodBodyChecker.checkMethodBody(method, manager, descriptors);
+      MethodBodyChecker.checkMethodBody(method, manager, descriptors, isOnTheFly);
     }
     if (CHECK_TRY_CATCH_SECTION) {
-      CatchBodyVisitor visitor = new CatchBodyVisitor(manager, descriptors);
+      CatchBodyVisitor visitor = new CatchBodyVisitor(manager, descriptors, isOnTheFly);
       PsiCodeBlock body = method.getBody();
       if (body != null) {
         body.accept(visitor);
@@ -94,7 +94,7 @@ public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionT
   @Nullable
   public ProblemDescriptor[] checkClass(@NotNull PsiClass aClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
     if (!CHECK_TRY_CATCH_SECTION) return null;
-    CatchBodyVisitor visitor = new CatchBodyVisitor(manager, new ArrayList<ProblemDescriptor>());
+    CatchBodyVisitor visitor = new CatchBodyVisitor(manager, new ArrayList<ProblemDescriptor>(), isOnTheFly);
     PsiClassInitializer[] initializers = aClass.getInitializers();
     for (PsiClassInitializer initializer : initializers) {
       initializer.accept(visitor);
@@ -106,7 +106,7 @@ public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionT
   @Nullable
   public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
     if (!CHECK_FILE_HEADER) return null;
-    ProblemDescriptor descriptor = FileHeaderChecker.checkFileHeader(file, manager);
+    ProblemDescriptor descriptor = FileHeaderChecker.checkFileHeader(file, manager, isOnTheFly);
     return descriptor == null ? null : new ProblemDescriptor[]{descriptor};
   }
 
index 0236386a9c19ed49d7bb281153d4d2a15fdc88e5..7c468e3c18fcfa740da7d71cd63d11c72a400559 100644 (file)
@@ -49,8 +49,7 @@ import java.util.regex.Pattern;
 public class FileHeaderChecker {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.defaultFileTemplateUsage.FileHeaderChecker");
 
-  static ProblemDescriptor checkFileHeader(final PsiFile file,
-                                           final InspectionManager manager) {
+  static ProblemDescriptor checkFileHeader(final PsiFile file, final InspectionManager manager, boolean onTheFly) {
     FileTemplate template = FileTemplateManager.getInstance().getDefaultTemplate(FileTemplateManager.FILE_HEADER_TEMPLATE_NAME);
     TIntObjectHashMap<String> offsetToProperty = new TIntObjectHashMap<String>();
     String templateText = template.getText().trim();
@@ -78,7 +77,7 @@ public class FileHeaderChecker {
       if (element == null) return null;
       LocalQuickFix[] quickFix = createQuickFix(element, matcher, offsetToProperty);
       final String description = InspectionsBundle.message("default.file.template.description");
-      return manager.createProblemDescriptor(element, description, quickFix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+      return manager.createProblemDescriptor(element, description, quickFix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly);
     }
     return null;
   }
index d894108cfcf302c34897ff76aae76de5efefd0c4..2a99d957e10f3607d7f77654fedd7b8f88b4d579 100644 (file)
@@ -15,8 +15,8 @@
  */
 package com.intellij.codeInspection.defaultFileTemplateUsage;
 
-import com.intellij.codeInsight.PsiEquivalenceUtil;
 import com.intellij.codeInsight.CodeInsightUtil;
+import com.intellij.codeInsight.PsiEquivalenceUtil;
 import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils;
 import com.intellij.codeInsight.generation.OverrideImplementUtil;
 import com.intellij.codeInspection.*;
@@ -86,7 +86,7 @@ public class MethodBodyChecker {
 
   static void checkMethodBody(final PsiMethod method,
                               final InspectionManager manager,
-                              final Collection<ProblemDescriptor> problemDescriptors) {
+                              final Collection<ProblemDescriptor> problemDescriptors, boolean onTheFly) {
     PsiType returnType = method.getReturnType();
     if (method.isConstructor() || returnType == null) return;
     PsiCodeBlock body = method.getBody();
@@ -112,7 +112,7 @@ public class MethodBodyChecker {
       Pair<? extends PsiElement, ? extends PsiElement> range = DefaultFileTemplateUsageInspection.getInteriorRange(body);
       final String description = InspectionsBundle.message("default.file.template.description");
       ProblemDescriptor problem = manager.createProblemDescriptor(range.first, range.second, description,
-                                                                  ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                  ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly,
                                                                   createMethodBodyQuickFix(method));
       problemDescriptors.add(problem);
     }
index cd13d258affdd24ab4a83a12e8c5451e8b684494..53071de6f600fa2a463389e53fbab6a1c773cca4 100644 (file)
@@ -84,7 +84,7 @@ public class DependencyInspection extends BaseLocalInspectionTool {
   }
 
   @Nullable
-  public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager, boolean isOnTheFly) {
+  public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
     if (file == null) return null;
     if (file.getViewProvider().getPsi(StdLanguages.JAVA) == null) return null;
     final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(file.getProject());
@@ -100,7 +100,8 @@ public class DependencyInspection extends BaseLocalInspectionTool {
             for (DependencyRule dependencyRule : rule) {
               StringBuffer message = new StringBuffer();
               message.append(MessageFormat.format(InspectionsBundle.message("inspection.dependency.violator.problem.descriptor"), dependencyRule.getDisplayText()));
-              problems.add(manager.createProblemDescriptor(place, message.toString(), new LocalQuickFix[]{new EditDependencyRulesAction(dependencyRule)}, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+              problems.add(manager.createProblemDescriptor(place, message.toString(), new LocalQuickFix[]{new EditDependencyRulesAction(dependencyRule)}, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                           isOnTheFly));
             }
           }
         }
index 3053954c5713b128a5c7758f05f294d0d6d34757..791adeb27e50ee74da67de4543f111eb3abb2400 100644 (file)
@@ -148,7 +148,7 @@ public class EmptyMethodInspection extends GlobalJavaInspectionTool {
 
       final ProblemDescriptor descriptor = manager.createProblemDescriptor(refMethod.getElement().getNavigationElement(), message,
                                                                            fixes.toArray(new LocalQuickFix[fixes.size()]),
-                                                                           ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                           ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
       return new ProblemDescriptor[]{descriptor};
     }
 
index b30cc9d57d2e42b0e26f30f8154d3a2568471872..69a60f1fc0d13483df887c3019a0c2e83d014e6a 100644 (file)
@@ -269,12 +269,15 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
     return new OptionsPanel();
   }
 
-  private static ProblemDescriptor createDescriptor(@NotNull PsiElement element, String template, InspectionManager manager) {
-    return manager.createProblemDescriptor(element, template, (LocalQuickFix [])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+  private static ProblemDescriptor createDescriptor(@NotNull PsiElement element, String template, InspectionManager manager,
+                                                    boolean onTheFly) {
+    return manager.createProblemDescriptor(element, template, (LocalQuickFix [])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                           onTheFly);
   }
 
-  private static ProblemDescriptor createDescriptor(@NotNull PsiElement element, String template, @NotNull LocalQuickFix fix, InspectionManager manager) {
-    return manager.createProblemDescriptor(element, template, fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+  private static ProblemDescriptor createDescriptor(@NotNull PsiElement element, String template, @NotNull LocalQuickFix fix,
+                                                    InspectionManager manager, boolean onTheFly) {
+    return manager.createProblemDescriptor(element, template, fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly);
   }
 
   private static class AddMissingTagFix implements LocalQuickFix {
@@ -356,7 +359,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
     final PsiElement elementToHighlight = nameIdentifier != null ? nameIdentifier : psiClass;
     if (docComment == null) {
       return isJavaDocRequired(psiClass)
-             ? new ProblemDescriptor[]{createDescriptor(elementToHighlight, REQUIRED_JAVADOC_IS_ABSENT, manager)}
+             ? new ProblemDescriptor[]{createDescriptor(elementToHighlight, REQUIRED_JAVADOC_IS_ABSENT, manager, isOnTheFly)}
              : null;
     }
 
@@ -393,27 +396,27 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
     for (int i = 0; i < tagsToCheck.length; i++) {
       final String tagToCheck = tagsToCheck[i];
       if (isTagRequired[i] && !isTagPresent[i]) {
-        problems.add(createMissingTagDescriptor(elementToHighlight, tagToCheck, manager));
+        problems.add(createMissingTagDescriptor(elementToHighlight, tagToCheck, manager, isOnTheFly));
       }
     }
-    ArrayList<ProblemDescriptor> tagProblems = getTagValuesProblems(psiClass, tags, manager);
+    ArrayList<ProblemDescriptor> tagProblems = getTagValuesProblems(psiClass, tags, manager, isOnTheFly);
     if (tagProblems != null) {
       problems.addAll(tagProblems);
     }
-    checkForPeriodInDoc(docComment, problems, manager);
+    checkForPeriodInDoc(docComment, problems, manager, isOnTheFly);
     checkInlineTags(manager, problems, docComment.getDescriptionElements(),
-                    JavaPsiFacade.getInstance(docComment.getProject()).getJavadocManager());
+                    JavaPsiFacade.getInstance(docComment.getProject()).getJavadocManager(), isOnTheFly);
 
     for (PsiDocTag tag : tags) {
       for (int i = 0; i < tagsToCheck.length; i++) {
         final String tagToCheck = tagsToCheck[i];
         if (tagToCheck.equals(tag.getName()) && extractTagDescription(tag).length() == 0) {
-          problems.add(createDescriptor(elementToHighlight, InspectionsBundle.message(absentDescriptionKeys[i]), manager));
+          problems.add(createDescriptor(elementToHighlight, InspectionsBundle.message(absentDescriptionKeys[i]), manager, isOnTheFly));
         }
       }
     }
 
-    checkDuplicateTags(tags, problems, manager);
+    checkDuplicateTags(tags, problems, manager, isOnTheFly);
 
     if (isTagRequired(psiClass, "param") && psiClass.hasTypeParameters() && nameIdentifier != null) {
       ArrayList<PsiTypeParameter> absentParameters = null;
@@ -426,7 +429,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
       }
       if (absentParameters != null) {
         for (PsiTypeParameter psiTypeParameter : absentParameters) {
-          problems.add(createMissingParamTagDescriptor(nameIdentifier, psiTypeParameter, manager));
+          problems.add(createMissingParamTagDescriptor(nameIdentifier, psiTypeParameter, manager, isOnTheFly));
         }
       }
     }
@@ -438,9 +441,10 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
 
   private static ProblemDescriptor createMissingParamTagDescriptor(final PsiIdentifier nameIdentifier,
                                                                    final PsiTypeParameter psiTypeParameter,
-                                                                   final InspectionManager manager) {
+                                                                   final InspectionManager manager, boolean isOnTheFly) {
     String message = InspectionsBundle.message("inspection.javadoc.problem.missing.tag", "<code>@param</code>");
-    return createDescriptor(nameIdentifier, message, new AddMissingTagFix("param", "<" + psiTypeParameter.getName() + ">"), manager);
+    return createDescriptor(nameIdentifier, message, new AddMissingTagFix("param", "<" + psiTypeParameter.getName() + ">"), manager,
+                            isOnTheFly);
   }
 
   @Nullable
@@ -452,19 +456,19 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
     PsiDocComment docComment = psiField.getDocComment();
     if (docComment == null) {
       return isJavaDocRequired(psiField)
-             ? new ProblemDescriptor[]{createDescriptor(psiField.getNameIdentifier(), REQUIRED_JAVADOC_IS_ABSENT, manager)}
+             ? new ProblemDescriptor[]{createDescriptor(psiField.getNameIdentifier(), REQUIRED_JAVADOC_IS_ABSENT, manager, isOnTheFly)}
              : null;
     }
 
     final ArrayList<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>(2);
-    ArrayList<ProblemDescriptor> tagProblems = getTagValuesProblems(psiField, docComment.getTags(), manager);
+    ArrayList<ProblemDescriptor> tagProblems = getTagValuesProblems(psiField, docComment.getTags(), manager, isOnTheFly);
     if (tagProblems != null) {
       problems.addAll(tagProblems);
     }
     checkInlineTags(manager, problems, docComment.getDescriptionElements(),
-                    JavaPsiFacade.getInstance(docComment.getProject()).getJavadocManager());
-    checkForPeriodInDoc(docComment, problems, manager);
-    checkDuplicateTags(docComment.getTags(), problems, manager);
+                    JavaPsiFacade.getInstance(docComment.getProject()).getJavadocManager(), isOnTheFly);
+    checkForPeriodInDoc(docComment, problems, manager, isOnTheFly);
+    checkDuplicateTags(docComment.getTags(), problems, manager, isOnTheFly);
     return problems.isEmpty()
            ? null
            : problems.toArray(new ProblemDescriptor[problems.size()]);
@@ -488,7 +492,8 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
         }
         if (superMethods.length == 0) {
           final PsiIdentifier nameIdentifier = psiMethod.getNameIdentifier();
-          return nameIdentifier != null ? new ProblemDescriptor[] { createDescriptor(nameIdentifier, REQUIRED_JAVADOC_IS_ABSENT, manager)} : null;
+          return nameIdentifier != null ? new ProblemDescriptor[] { createDescriptor(nameIdentifier, REQUIRED_JAVADOC_IS_ABSENT, manager,
+                                                                                     isOnTheFly)} : null;
         }
         else {
           return null;
@@ -509,7 +514,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
     final ArrayList<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>(2);
 
     checkInlineTags(manager, problems, descriptionElements,
-                    JavaPsiFacade.getInstance(docComment.getProject()).getJavadocManager());
+                    JavaPsiFacade.getInstance(docComment.getProject()).getJavadocManager(), isOnTheFly);
 
     final PsiDocTag tagByName = docComment.findTagByName("inheritDoc");
     if (tagByName != null) {
@@ -550,7 +555,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
     if (isReturnRequired && isReturnAbsent) {
       final PsiIdentifier psiIdentifier = psiMethod.getNameIdentifier();
       if (psiIdentifier != null) {
-        problems.add(createMissingTagDescriptor(psiIdentifier, "return", manager));
+        problems.add(createMissingTagDescriptor(psiIdentifier, "return", manager, isOnTheFly));
       }
     }
 
@@ -558,7 +563,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
       for (PsiParameter psiParameter : absentParameters) {
         final PsiIdentifier nameIdentifier = psiMethod.getNameIdentifier();
         if (nameIdentifier != null) {
-          problems.add(createMissingParamTagDescriptor(nameIdentifier, psiParameter, manager));
+          problems.add(createMissingParamTagDescriptor(nameIdentifier, psiParameter, manager, isOnTheFly));
         }
       }
     }
@@ -581,7 +586,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
           if (valueElement != null) {
             problems.add(createDescriptor(valueElement,
                                           InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "<code>@param " + valueElement.getText() + "</code>"),
-                                          manager));
+                                          manager, isOnTheFly));
           }
 
         }
@@ -597,20 +602,20 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
           declaredExceptions.put(classType, psiClass);
         }
       }
-      processThrowsTags(tags, declaredExceptions, manager, problems);
+      processThrowsTags(tags, declaredExceptions, manager, problems, isOnTheFly);
       if (!declaredExceptions.isEmpty()) {
         for (PsiClassType declaredException : declaredExceptions.keySet()) {
-          problems.add(createMissingThrowsTagDescriptor(psiMethod, manager, declaredException));
+          problems.add(createMissingThrowsTagDescriptor(psiMethod, manager, declaredException, isOnTheFly));
         }
       }
     }
 
-    ArrayList<ProblemDescriptor> tagProblems = getTagValuesProblems(psiMethod, tags, manager);
+    ArrayList<ProblemDescriptor> tagProblems = getTagValuesProblems(psiMethod, tags, manager, isOnTheFly);
     if (tagProblems != null) {
       problems.addAll(tagProblems);
     }
 
-    checkForPeriodInDoc(docComment, problems, manager);
+    checkForPeriodInDoc(docComment, problems, manager, isOnTheFly);
 
     for (PsiDocTag tag : tags) {
       if ("param".equals(tag.getName())) {
@@ -623,7 +628,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
               if (paramRef.getReference().isReferenceTo(param)) {
                 problems.add(createDescriptor(value,
                                               InspectionsBundle.message("inspection.javadoc.method.problem.descriptor", "<code>@param</code>", "<code>" + param.getName() + "</code>"),
-                                              manager));
+                                              manager, isOnTheFly));
               }
             }
           }
@@ -633,13 +638,14 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
         if ("return".equals(tag.getName())) {
           if (extractTagDescription(tag).length() == 0) {
             String message = InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "<code>@return</code>");
-            ProblemDescriptor descriptor = manager.createProblemDescriptor(tag.getNameElement(), message, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true);
+            ProblemDescriptor descriptor = manager.createProblemDescriptor(tag.getNameElement(), message, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                           isOnTheFly, true);
             problems.add(descriptor);
           }
         }
     }
 
-    checkDuplicateTags(tags, problems, manager);
+    checkDuplicateTags(tags, problems, manager, isOnTheFly);
 
     return problems.isEmpty()
            ? null
@@ -665,7 +671,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
   private static void processThrowsTags(final PsiDocTag[] tags,
                                         final Map<PsiClassType, PsiClass> declaredExceptions,
                                         final InspectionManager mananger,
-                                        @NotNull final ArrayList<ProblemDescriptor> problems) {
+                                        @NotNull final ArrayList<ProblemDescriptor> problems, boolean isOnTheFly) {
     for (PsiDocTag tag : tags) {
       if ("throws".equals(tag.getName()) || "exception".equals(tag.getName())) {
         final PsiDocTagValue value = tag.getValueElement();
@@ -683,7 +689,8 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
             final PsiClass psiClass = declaredExceptions.get(classType);
             if (InheritanceUtil.isInheritorOrSelf(exceptionClass, psiClass, true)) {
               if (extractThrowsTagDescription(tag).length() == 0) {
-                problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "<code>" + tag.getName() + "</code>"), mananger));
+                problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "<code>" + tag.getName() + "</code>"), mananger,
+                                              isOnTheFly));
               }
               it.remove();
             }
@@ -696,25 +703,26 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
   @Nullable
   private static ProblemDescriptor createMissingThrowsTagDescriptor(final PsiMethod method,
                                                                     final InspectionManager manager,
-                                                                    final PsiClassType exceptionClassType) {
+                                                                    final PsiClassType exceptionClassType, boolean isOnTheFly) {
     @NonNls String tag = "throws";
     String message = InspectionsBundle.message("inspection.javadoc.problem.missing.tag", "<code>@" + tag + "</code> " + exceptionClassType.getCanonicalText());
     final String firstDeclaredException = exceptionClassType.getCanonicalText();
     final PsiIdentifier nameIdentifier = method.getNameIdentifier();
-    return nameIdentifier != null ? createDescriptor(nameIdentifier, message,new AddMissingTagFix(tag, firstDeclaredException), manager) : null;    
+    return nameIdentifier != null ? createDescriptor(nameIdentifier, message,new AddMissingTagFix(tag, firstDeclaredException), manager,
+                                                     isOnTheFly) : null;
   }
 
   private static ProblemDescriptor createMissingTagDescriptor(PsiElement elementToHighlight,
                                                               @NonNls String tag,
-                                                              final InspectionManager manager) {
+                                                              final InspectionManager manager, boolean isOnTheFly) {
     String message = InspectionsBundle.message("inspection.javadoc.problem.missing.tag", "<code>@" + tag + "</code>");
-    return createDescriptor(elementToHighlight, message,new AddMissingTagFix(tag), manager);
+    return createDescriptor(elementToHighlight, message,new AddMissingTagFix(tag), manager, isOnTheFly);
   }
   private static ProblemDescriptor createMissingParamTagDescriptor(PsiElement elementToHighlight,
                                                                    PsiParameter param,
-                                                                   final InspectionManager manager) {
+                                                                   final InspectionManager manager, boolean isOnTheFly) {
     String message = InspectionsBundle.message("inspection.javadoc.method.problem.missing.param.tag", "<code>@param</code>", "<code>" + param.getName() + "</code>");
-    return createDescriptor(elementToHighlight, message, new AddMissingParamTagFix(param), manager);
+    return createDescriptor(elementToHighlight, message, new AddMissingParamTagFix(param), manager, isOnTheFly);
   }
 
   private static class AddMissingParamTagFix extends AddMissingTagFix {
@@ -809,7 +817,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
 
   private void checkForPeriodInDoc(PsiDocComment docComment,
                                    ArrayList<ProblemDescriptor> problems,
-                                   InspectionManager manager) {
+                                   InspectionManager manager, boolean onTheFly) {
     if (IGNORE_JAVADOC_PERIOD) return;
     PsiDocTag[] tags = docComment.getTags();
     int dotIndex = docComment.getText().indexOf('.');
@@ -830,13 +838,13 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
       problems.add(manager.createProblemDescriptor(docComment.getFirstChild(),
                                                    InspectionsBundle.message("inspection.javadoc.problem.descriptor1"),
                                                    null,
-                                                   ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                                   false));
+                                                   ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly, false));
     }
   }
 
   @Nullable
-  private ArrayList<ProblemDescriptor> getTagValuesProblems(PsiDocCommentOwner context, PsiDocTag[] tags, InspectionManager inspectionManager) {
+  private ArrayList<ProblemDescriptor> getTagValuesProblems(PsiDocCommentOwner context, PsiDocTag[] tags, InspectionManager inspectionManager,
+                                                            boolean isOnTheFly) {
     final ArrayList<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>(2);
     nextTag:
     for (PsiDocTag tag : tags) {
@@ -851,9 +859,11 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
         }
 
         if (tagInfo == null){
-          problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.wrong.tag", "<code>" + tagName + "</code>"), new AddUnknownTagToCustoms(tag), inspectionManager));
+          problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.wrong.tag", "<code>" + tagName + "</code>"), new AddUnknownTagToCustoms(tag), inspectionManager,
+                                        isOnTheFly));
         } else {
-          problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.disallowed.tag", "<code>" + tagName + "</code>"), new AddUnknownTagToCustoms(tag), inspectionManager));
+          problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.disallowed.tag", "<code>" + tagName + "</code>"), new AddUnknownTagToCustoms(tag), inspectionManager,
+                                        isOnTheFly));
         }
 
       }
@@ -870,7 +880,8 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
           final int textOffset = value.getTextOffset();
 
           if (textOffset == value.getTextRange().getEndOffset()) {
-            problems.add(inspectionManager.createProblemDescriptor(tag, InspectionsBundle.message("inspection.javadoc.problem.name.expected"), null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true));
+            problems.add(inspectionManager.createProblemDescriptor(tag, InspectionsBundle.message("inspection.javadoc.problem.name.expected"), null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                   isOnTheFly, true));
           }
         }
       }
@@ -878,12 +889,13 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
       if (message != null) {
         final PsiDocTagValue valueElement = tag.getValueElement();
         if (valueElement == null){
-          problems.add(inspectionManager.createProblemDescriptor(tag, InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "<code>" + tag.getName() + "</code>"), null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true));
+          problems.add(inspectionManager.createProblemDescriptor(tag, InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "<code>" + tag.getName() + "</code>"), null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                 isOnTheFly, true));
         } else {
-          problems.add(createDescriptor(valueElement, message, inspectionManager));
+          problems.add(createDescriptor(valueElement, message, inspectionManager, isOnTheFly));
         }
       }
-      checkInlineTags(inspectionManager, problems, tag.getDataElements(), manager);
+      checkInlineTags(inspectionManager, problems, tag.getDataElements(), manager, isOnTheFly);
     }
 
     return problems.isEmpty() ? null : problems;
@@ -892,14 +904,15 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
   private void checkInlineTags(final InspectionManager inspectionManager,
                                final ArrayList<ProblemDescriptor> problems,
                                final PsiElement[] dataElements,
-                               final JavadocManager manager) {
+                               final JavadocManager manager, boolean isOnTheFly) {
     for (PsiElement dataElement : dataElements) {
       if (dataElement instanceof PsiInlineDocTag) {
         final PsiInlineDocTag inlineDocTag = (PsiInlineDocTag)dataElement;
         final PsiElement nameElement = inlineDocTag.getNameElement();
         if (manager.getTagInfo(inlineDocTag.getName()) == null) {
           if (nameElement != null) {
-            problems.add(createDescriptor(nameElement, InspectionsBundle.message("inspection.javadoc.problem.wrong.tag", "<code>" + inlineDocTag.getName() + "</code>"), new AddUnknownTagToCustoms(inlineDocTag), inspectionManager));
+            problems.add(createDescriptor(nameElement, InspectionsBundle.message("inspection.javadoc.problem.wrong.tag", "<code>" + inlineDocTag.getName() + "</code>"), new AddUnknownTagToCustoms(inlineDocTag), inspectionManager,
+                                          isOnTheFly));
           }
         }
         final PsiDocTagValue value = inlineDocTag.getValueElement();
@@ -910,7 +923,8 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
             if (ref != null){
               if (PsiTreeUtil.getParentOfType(inlineDocTag, PsiDocCommentOwner.class) == PsiTreeUtil.getParentOfType(ref, PsiDocCommentOwner.class, false)) {
                 if (nameElement != null) {
-                  problems.add(createDescriptor(nameElement, InspectionsBundle.message("inspection.javadoc.problem.pointing.to.itself"), inspectionManager));
+                  problems.add(createDescriptor(nameElement, InspectionsBundle.message("inspection.javadoc.problem.pointing.to.itself"), inspectionManager,
+                                                isOnTheFly));
                 }
               }
             }
@@ -982,7 +996,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
 
   private static void checkDuplicateTags(final PsiDocTag[] tags,
                                          ArrayList<ProblemDescriptor> problems,
-                                         final InspectionManager manager) {
+                                         final InspectionManager manager, boolean isOnTheFly) {
     Set<String> documentedParamNames = null;
     Set<String> documentedExceptions = null;
     Set<String> uniqueTags = null;
@@ -998,7 +1012,8 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
               documentedParamNames = new HashSet<String>();
             }
             if (documentedParamNames.contains(paramName)) {
-              problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.duplicate.param", paramName), manager));
+              problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.duplicate.param", paramName), manager,
+                                            isOnTheFly));
             }
             documentedParamNames.add(paramName);
           }
@@ -1020,7 +1035,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
                 if (documentedExceptions.contains(fqName)) {
                   problems.add(createDescriptor(tag.getNameElement(),
                                                 InspectionsBundle.message("inspection.javadoc.problem.duplicate.throws", fqName),
-                                                manager));
+                                                manager, isOnTheFly));
                 }
                 documentedExceptions.add(fqName);
               }
@@ -1033,7 +1048,8 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
           uniqueTags = new HashSet<String>();
         }
         if (uniqueTags.contains(tag.getName())) {
-          problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.duplicate.tag", tag.getName()), manager));
+          problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.duplicate.tag", tag.getName()), manager,
+                                        isOnTheFly));
         }
         uniqueTags.add(tag.getName());
       }
index 2032924f7a07f55aa363f8b5b8785c079b2e6bbc..032c4f1f253d53f47343491141cb438249596c27 100644 (file)
@@ -43,8 +43,9 @@ public class JavaDocReferenceInspection extends BaseLocalInspectionTool {
   public static final String DISPLAY_NAME = InspectionsBundle.message("inspection.javadoc.ref.display.name");
 
 
-  private static ProblemDescriptor createDescriptor(@NotNull PsiElement element, String template, InspectionManager manager) {
-    return manager.createProblemDescriptor(element, template, (LocalQuickFix [])null, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
+  private static ProblemDescriptor createDescriptor(@NotNull PsiElement element, String template, InspectionManager manager,
+                                                    boolean onTheFly) {
+    return manager.createProblemDescriptor(element, template, (LocalQuickFix [])null, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, onTheFly);
   }
 
   @Nullable
@@ -64,12 +65,13 @@ public class JavaDocReferenceInspection extends BaseLocalInspectionTool {
     if (docComment == null) return null;
 
     final Set<PsiJavaCodeReferenceElement> references = new HashSet<PsiJavaCodeReferenceElement>();
-    docComment.accept(getVisitor(references, docCommentOwner, problems, manager));
+    docComment.accept(getVisitor(references, docCommentOwner, problems, manager, isOnTheFly));
     for (PsiJavaCodeReferenceElement reference : references) {
       final List<PsiClass> classesToImport = new ImportClassFix(reference).getClassesToImport();
       problems.add(manager.createProblemDescriptor(reference, InspectionsBundle.message("inspection.javadoc.problem.cannot.resolve",
                                                                                         "<code>" + reference.getText() + "</code>"),
-                                                   !isOnTheFly || classesToImport.isEmpty() ? null : new AddImportFix(classesToImport), ProblemHighlightType.LIKE_UNKNOWN_SYMBOL));
+                                                   !isOnTheFly || classesToImport.isEmpty() ? null : new AddImportFix(classesToImport), ProblemHighlightType.LIKE_UNKNOWN_SYMBOL,
+                                                   isOnTheFly));
     }
 
     return problems.isEmpty()
@@ -86,7 +88,7 @@ public class JavaDocReferenceInspection extends BaseLocalInspectionTool {
   private PsiElementVisitor getVisitor(final Set<PsiJavaCodeReferenceElement> references,
                                        final PsiElement context,
                                        final ArrayList<ProblemDescriptor> problems,
-                                       final InspectionManager manager) {
+                                       final InspectionManager manager, final boolean onTheFly) {
     return new JavaElementVisitor() {
       @Override public void visitReferenceExpression(PsiReferenceExpression expression) {
         visitElement(expression);
@@ -105,14 +107,14 @@ public class JavaDocReferenceInspection extends BaseLocalInspectionTool {
         final JavadocManager javadocManager = JavaPsiFacade.getInstance(tag.getProject()).getJavadocManager();
         final JavadocTagInfo info = javadocManager.getTagInfo(tag.getName());
         if (info == null || !info.isInline()) {
-          visitRefInDocTag(tag, javadocManager, context, problems, manager);
+          visitRefInDocTag(tag, javadocManager, context, problems, manager, onTheFly);
         }
       }
 
       @Override public void visitInlineDocTag(PsiInlineDocTag tag) {
         super.visitInlineDocTag(tag);
         final JavadocManager javadocManager = JavaPsiFacade.getInstance(tag.getProject()).getJavadocManager();
-        visitRefInDocTag(tag, javadocManager, context, problems, manager);
+        visitRefInDocTag(tag, javadocManager, context, problems, manager, onTheFly);
       }
 
       @Override public void visitElement(PsiElement element) {
@@ -127,11 +129,9 @@ public class JavaDocReferenceInspection extends BaseLocalInspectionTool {
     };
   }
 
-  public static void visitRefInDocTag(final PsiDocTag tag,
-                                  final JavadocManager manager,
-                                  final PsiElement context,
-                                  ArrayList<ProblemDescriptor> problems,
-                                  InspectionManager inspectionManager) {
+  public static void visitRefInDocTag(final PsiDocTag tag, final JavadocManager manager, final PsiElement context, ArrayList<ProblemDescriptor> problems,
+                                      InspectionManager inspectionManager,
+                                      boolean onTheFly) {
     String tagName = tag.getName();
     PsiDocTagValue value = tag.getValueElement();
     if (value == null) return;
@@ -139,7 +139,7 @@ public class JavaDocReferenceInspection extends BaseLocalInspectionTool {
     if (info != null && !info.isValidInContext(context)) return;
     String message = info == null || !info.isInline() ? null : info.checkTagValue(value);
     if (message != null){
-      problems.add(createDescriptor(value, message, inspectionManager));
+      problems.add(createDescriptor(value, message, inspectionManager, onTheFly));
     }
     final PsiReference reference = value.getReference();
     if (reference != null) {
@@ -151,7 +151,8 @@ public class JavaDocReferenceInspection extends BaseLocalInspectionTool {
           final PsiDocTagValue valueElement = tag.getValueElement();
           if (valueElement != null) {
             @NonNls String params = "<code>" + value.getContainingFile().getViewProvider().getContents().subSequence(textOffset, value.getTextRange().getEndOffset()) + "</code>";
-            problems.add(createDescriptor(valueElement, InspectionsBundle.message("inspection.javadoc.problem.cannot.resolve", params), inspectionManager));
+            problems.add(createDescriptor(valueElement, InspectionsBundle.message("inspection.javadoc.problem.cannot.resolve", params), inspectionManager,
+                                          onTheFly));
           }
         }
       }
index 88582e71e8d501a7a6401b065e016bb103bc73f0..0ee44048a971b690aeb5f828095706c352888a52 100644 (file)
@@ -24,8 +24,8 @@ import com.intellij.openapi.vfs.ReadonlyStatusHandler;
 import com.intellij.psi.*;
 import com.intellij.psi.controlFlow.*;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtilBase;
 import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.PsiUtilBase;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -35,7 +35,9 @@ import javax.swing.*;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import java.awt.*;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -55,7 +57,7 @@ public class LocalCanBeFinal extends BaseLocalInspectionTool {
   }
 
   public ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    List<ProblemDescriptor> list = checkCodeBlock(method.getBody(), manager);
+    List<ProblemDescriptor> list = checkCodeBlock(method.getBody(), manager, isOnTheFly);
     return list == null ? null : list.toArray(new ProblemDescriptor[list.size()]);
   }
 
@@ -63,7 +65,7 @@ public class LocalCanBeFinal extends BaseLocalInspectionTool {
     List<ProblemDescriptor> allProblems = null;
     final PsiClassInitializer[] initializers = aClass.getInitializers();
     for (PsiClassInitializer initializer : initializers) {
-      final List<ProblemDescriptor> problems = checkCodeBlock(initializer.getBody(), manager);
+      final List<ProblemDescriptor> problems = checkCodeBlock(initializer.getBody(), manager, isOnTheFly);
       if (problems != null) {
         if (allProblems == null) {
           allProblems = new ArrayList<ProblemDescriptor>(1);
@@ -75,7 +77,7 @@ public class LocalCanBeFinal extends BaseLocalInspectionTool {
   }
 
   @Nullable
-  private List<ProblemDescriptor> checkCodeBlock(final PsiCodeBlock body, InspectionManager manager) {
+  private List<ProblemDescriptor> checkCodeBlock(final PsiCodeBlock body, InspectionManager manager, boolean onTheFly) {
     if (body == null) return null;
     final ControlFlow flow;
     try {
@@ -216,12 +218,12 @@ public class LocalCanBeFinal extends BaseLocalInspectionTool {
       if (variable instanceof PsiParameter && !(((PsiParameter)variable).getDeclarationScope() instanceof PsiForeachStatement)) {
         problems.add(manager.createProblemDescriptor(problemElement,
                                                      InspectionsBundle.message("inspection.can.be.local.parameter.problem.descriptor"),
-                                                     myQuickFix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                                     myQuickFix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly));
       }
       else {
         problems.add(manager.createProblemDescriptor(problemElement,
                                                      InspectionsBundle.message("inspection.can.be.local.variable.problem.descriptor"),
-                                                     myQuickFix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                                     myQuickFix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly));
       }
     }
 
index 1af783871799ec3b7c2c8c9b23d09807348395f3..d17847b123531c3107e5091ac3828dad76863b6a 100644 (file)
@@ -34,7 +34,7 @@ public abstract class GenericsInspectionToolBase extends BaseLocalInspectionTool
     if (initializers.length == 0) return null;
     List<ProblemDescriptor> descriptors = new ArrayList<ProblemDescriptor>();
     for (PsiClassInitializer initializer : initializers) {
-      final ProblemDescriptor[] localDescriptions = getDescriptions(initializer, manager);
+      final ProblemDescriptor[] localDescriptions = getDescriptions(initializer, manager, isOnTheFly);
       if (localDescriptions != null) {
         descriptors.addAll(Arrays.asList(localDescriptions));
       }
@@ -46,7 +46,7 @@ public abstract class GenericsInspectionToolBase extends BaseLocalInspectionTool
   public ProblemDescriptor[] checkField(@NotNull PsiField field, @NotNull InspectionManager manager, boolean isOnTheFly) {
     final PsiExpression initializer = field.getInitializer();
     if (initializer != null) {
-      return getDescriptions(initializer, manager);
+      return getDescriptions(initializer, manager, isOnTheFly);
     }
     return null;
   }
@@ -54,10 +54,10 @@ public abstract class GenericsInspectionToolBase extends BaseLocalInspectionTool
   public ProblemDescriptor[] checkMethod(@NotNull PsiMethod psiMethod, @NotNull InspectionManager manager, boolean isOnTheFly) {
     final PsiCodeBlock body = psiMethod.getBody();
     if (body != null) {
-      return getDescriptions(body, manager);
+      return getDescriptions(body, manager, isOnTheFly);
     }
     return null;
   }
 
-  public abstract ProblemDescriptor[] getDescriptions(PsiElement place, InspectionManager manager);
+  public abstract ProblemDescriptor[] getDescriptions(PsiElement place, InspectionManager manager, boolean isOnTheFly);
 }
index 7650b7a4f3ceadf08dfe0350d3331af0b921c41d..18496c684a7e699939863402e7c5e10d031357d6 100644 (file)
@@ -57,7 +57,7 @@ public class RedundantArrayForVarargsCallInspection extends GenericsInspectionTo
     }
   }
 
-  public ProblemDescriptor[] getDescriptions(PsiElement place, final InspectionManager manager) {
+  public ProblemDescriptor[] getDescriptions(PsiElement place, final InspectionManager manager, final boolean isOnTheFly) {
     if (!PsiUtil.isLanguageLevel5OrHigher(place)) return null;
     final List<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>();
     place.accept(new JavaRecursiveElementWalkingVisitor() {
@@ -98,7 +98,8 @@ public class RedundantArrayForVarargsCallInspection extends GenericsInspectionTo
                     final ProblemDescriptor descriptor = manager.createProblemDescriptor(lastArg,
                                                                                          InspectionsBundle.message("inspection.redundant.array.creation.for.varargs.call.descriptor"),
                                                                                          myQuickFixAction,
-                                                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                                         isOnTheFly);
 
                     problems.add(descriptor);
                   }
index 6d4553327d6b330919ff0c4bdb51d2af8a6abc5c..37df723c47fbfe6db8b8d745f35ea68356ef0c4d 100644 (file)
@@ -58,12 +58,12 @@ public class RedundantTypeArgsInspection extends GenericsInspectionToolBase {
   public ProblemDescriptor[] checkMethod(@NotNull PsiMethod psiMethod, @NotNull InspectionManager manager, boolean isOnTheFly) {
     final PsiCodeBlock body = psiMethod.getBody();
     if (body != null) {
-      return getDescriptions(body, manager);
+      return getDescriptions(body, manager, isOnTheFly);
     }
     return null;
   }
 
-  public ProblemDescriptor[] getDescriptions(PsiElement place, final InspectionManager inspectionManager) {
+  public ProblemDescriptor[] getDescriptions(PsiElement place, final InspectionManager inspectionManager, boolean isOnTheFly) {
     final List<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>();
     place.accept(new JavaRecursiveElementWalkingVisitor() {
       @Override public void visitMethodCallExpression(PsiMethodCallExpression expression) {
@@ -120,7 +120,7 @@ public class RedundantTypeArgsInspection extends GenericsInspectionToolBase {
             final ProblemDescriptor descriptor = inspectionManager.createProblemDescriptor(expression.getTypeArgumentList(),
                                                                                            InspectionsBundle.message("inspection.redundant.type.problem.descriptor"),
                                                                                            myQuickFixAction,
-                                                                                           ProblemHighlightType.LIKE_UNUSED_SYMBOL);
+                                                                                           ProblemHighlightType.LIKE_UNUSED_SYMBOL, false);
             problems.add(descriptor);
           }
         }
index dc74c466260172a03394242fdafa81f6a83bbd61..ce8d2be492a64f40f073e231ed0bb67c8211e83d 100644 (file)
@@ -52,20 +52,20 @@ public class RedundantCastInspection extends GenericsInspectionToolBase {
     myQuickFixAction = new AcceptSuggested();
   }
 
-  public ProblemDescriptor[] getDescriptions(PsiElement where, InspectionManager manager) {
+  public ProblemDescriptor[] getDescriptions(PsiElement where, InspectionManager manager, boolean isOnTheFly) {
     List<PsiTypeCastExpression> redundantCasts = RedundantCastUtil.getRedundantCastsInside(where);
     if (redundantCasts.isEmpty()) return null;
     ProblemDescriptor[] descriptions = new ProblemDescriptor[redundantCasts.size()];
     for (int i = 0; i < redundantCasts.size(); i++) {
-      descriptions[i] = createDescription(redundantCasts.get(i), manager);
+      descriptions[i] = createDescription(redundantCasts.get(i), manager, isOnTheFly);
     }
     return descriptions;
   }
 
-  private ProblemDescriptor createDescription(PsiTypeCastExpression cast, InspectionManager manager) {
+  private ProblemDescriptor createDescription(PsiTypeCastExpression cast, InspectionManager manager, boolean onTheFly) {
     String message = InspectionsBundle.message("inspection.redundant.cast.problem.descriptor",
                                                "<code>" + cast.getOperand().getText() + "</code>", "<code>#ref</code> #loc");
-    return manager.createProblemDescriptor(cast.getCastType(), message, myQuickFixAction, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
+    return manager.createProblemDescriptor(cast.getCastType(), message, myQuickFixAction, ProblemHighlightType.LIKE_UNUSED_SYMBOL, onTheFly);
   }
 
 
index 2beb28ebe9fa9508ed4f5ba15d8732500e11f994..68ce05a0b3e07610eb297f4f182b100190734926 100644 (file)
@@ -64,7 +64,7 @@ public class SameParameterValueInspection extends GlobalJavaInspectionTool {
           problems.add(manager.createProblemDescriptor(refParameter.getElement(), InspectionsBundle.message(
             "inspection.same.parameter.problem.descriptor", "<code>" + paramName + "</code>", "<code>" + value + "</code>"),
                                                        new InlineParameterValueFix(paramName, value),
-                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false));
         }
       }
     }
index c62a409107a2e1d34c57d6d1d4db7aa64d9dae92..999543d1f860b12dcccf53afaba06eded85d00e4 100644 (file)
@@ -47,7 +47,8 @@ public class SameReturnValueInspection extends GlobalJavaInspectionTool {
           message = InspectionsBundle.message("inspection.same.return.value.problem.descriptor2", "<code>" + returnValue + "</code>");
         }
 
-        return new ProblemDescriptor[] {manager.createProblemDescriptor(refMethod.getElement().getNavigationElement(), message, (LocalQuickFix [])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
+        return new ProblemDescriptor[] {manager.createProblemDescriptor(refMethod.getElement().getNavigationElement(), message, (LocalQuickFix [])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                        false)};
       }
     }
 
index 690b73ce598743c5826f3f6ab10d65ae0ee5184d..3bf4a4a8f1133fb80e8d5d8496925cc49a4361c5 100644 (file)
@@ -86,15 +86,18 @@ public class RedundantThrows extends GlobalJavaInspectionTool {
 
             if (refMethod.isAbstract() || refMethod.getOwnerClass().isInterface()) {
               problems.add(manager.createProblemDescriptor(throwsRef, InspectionsBundle.message(
-                "inspection.redundant.throws.problem.descriptor", "<code>#ref</code>"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL));
+                "inspection.redundant.throws.problem.descriptor", "<code>#ref</code>"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+                                                           false));
             }
             else if (!refMethod.getDerivedMethods().isEmpty()) {
               problems.add(manager.createProblemDescriptor(throwsRef, InspectionsBundle.message(
-                "inspection.redundant.throws.problem.descriptor1", "<code>#ref</code>"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL));
+                "inspection.redundant.throws.problem.descriptor1", "<code>#ref</code>"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+                                                           false));
             }
             else {
               problems.add(manager.createProblemDescriptor(throwsRef, InspectionsBundle.message(
-                "inspection.redundant.throws.problem.descriptor2", "<code>#ref</code>"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL));
+                "inspection.redundant.throws.problem.descriptor2", "<code>#ref</code>"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+                                                           false));
             }
           }
         }
index 435090ee3162eef105205f0c322c3f7b1e755042..daf3868dd72865823719a58db5609171b0dfbf41 100644 (file)
@@ -52,11 +52,11 @@ public class RedundantThrowsDeclaration extends BaseJavaLocalInspectionTool {
   }
 
   @Nullable
-  public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, boolean isOnTheFly) {
+  public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
     final Set<ProblemDescriptor> problems = new HashSet<ProblemDescriptor>();
     file.accept(new JavaRecursiveElementWalkingVisitor() {
       @Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
-        final ProblemDescriptor descriptor = checkExceptionsNeverThrown(reference, manager);
+        final ProblemDescriptor descriptor = checkExceptionsNeverThrown(reference, manager, isOnTheFly);
         if (descriptor != null) {
           problems.add(descriptor);
         }
@@ -69,7 +69,8 @@ public class RedundantThrowsDeclaration extends BaseJavaLocalInspectionTool {
 
 
   //@top
-  private static ProblemDescriptor checkExceptionsNeverThrown(PsiJavaCodeReferenceElement referenceElement, InspectionManager inspectionManager) {
+  private static ProblemDescriptor checkExceptionsNeverThrown(PsiJavaCodeReferenceElement referenceElement, InspectionManager inspectionManager,
+                                                              boolean onTheFly) {
     if (!(referenceElement.getParent() instanceof PsiReferenceList)) return null;
     PsiReferenceList referenceList = (PsiReferenceList)referenceElement.getParent();
     if (!(referenceList.getParent() instanceof PsiMethod)) return null;
@@ -121,7 +122,8 @@ public class RedundantThrowsDeclaration extends BaseJavaLocalInspectionTool {
     String description = JavaErrorMessages.message("exception.is.never.thrown", HighlightUtil.formatType(exceptionType));
 
     final LocalQuickFix quickFixes = new DeleteThrowsFix(method, exceptionType);
-    return inspectionManager.createProblemDescriptor(referenceElement, description, quickFixes, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
+    return inspectionManager.createProblemDescriptor(referenceElement, description, quickFixes, ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+                                                     onTheFly);
   }
 
 }
index bcaa3740a8c98e4684246e4450d9b9e02fdf1947..54be3627bd9ad2aeb839a831a4fe993d179a9b3b 100644 (file)
@@ -83,7 +83,7 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool {
                                                      ? InspectionsBundle.message("inspection.unused.parameter.composer")
                                                      : InspectionsBundle.message("inspection.unused.parameter.composer1"),
                                                      new AcceptSuggested(globalContext.getRefManager(), processor, refParameter.toString()),
-                                                     ProblemHighlightType.LIKE_UNUSED_SYMBOL));
+                                                     ProblemHighlightType.LIKE_UNUSED_SYMBOL, false));
         }
       }
       return result.toArray(new CommonProblemDescriptor[result.size()]);
index 58a4ae1f631f287b51beb74cee72dac9191d25fb..95c740818a3bacdcc8ec11bdb418329a8103c64b 100644 (file)
@@ -55,7 +55,8 @@ public class UnusedReturnValue extends GlobalJavaInspectionTool{
       if (!refMethod.isReturnValueUsed()) {
         return new ProblemDescriptor[]{manager.createProblemDescriptor(refMethod.getElement().getNavigationElement(),
                                                                        InspectionsBundle.message("inspection.unused.return.value.problem.descriptor"),
-                                                                       getFix(processor), ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
+                                                                       getFix(processor), ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                       false)};
       }
     }
 
index 740b41d6b572a8244529e8d0b64910a5a084a9a0..2f60d21f4dbc97f69b3f1e458d5cb2685c5e12e9 100644 (file)
@@ -32,8 +32,8 @@ import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.ex.EntryPointsManager;
 import com.intellij.codeInspection.reference.*;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.extensions.ExtensionPoint;
+import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.ReadonlyStatusHandler;
 import com.intellij.psi.*;
@@ -42,8 +42,8 @@ import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.psi.util.PsiUtilBase;
-import com.intellij.util.VisibilityUtil;
 import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.VisibilityUtil;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -181,7 +181,7 @@ public class VisibilityInspection extends GlobalJavaInspectionTool {
           return new ProblemDescriptor[]{manager.createProblemDescriptor(psiElement,
                                                                          InspectionsBundle.message("inspection.visibility.compose.suggestion", VisibilityUtil.toPresentableText(access)),
                                                                          new AcceptSuggestedAccess(globalContext.getRefManager(), access),
-                                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
+                                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false)};
         }
       }
     }
index a0ed44123afe5c9bd0254a2f4c67d9c4cbb9216f..50ae74ec551cd99e2fcb023537bb8ae74f5dc460 100644 (file)
@@ -55,7 +55,7 @@ public class WrongPackageStatementInspection extends BaseJavaLocalInspectionTool
 
         return new ProblemDescriptor[]{manager.createProblemDescriptor(classes[0].getNameIdentifier(), description,
                                                                        new AdjustPackageNameFix(javaFile, null, dirPackage),
-                                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
+                                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly)};
       }
       if (packageStatement != null) {
         final PsiJavaCodeReferenceElement packageReference = packageStatement.getPackageReference();
@@ -75,7 +75,8 @@ public class WrongPackageStatementInspection extends BaseJavaLocalInspectionTool
           String description = JavaErrorMessages.message("package.name.file.path.mismatch",
                                                          packageReference.getText(),
                                                          dirPackage.getQualifiedName());
-          return new ProblemDescriptor[]{manager.createProblemDescriptor(packageStatement, description, availableFixes.toArray(new LocalQuickFix[availableFixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
+          return new ProblemDescriptor[]{manager.createProblemDescriptor(packageStatement, description, availableFixes.toArray(new LocalQuickFix[availableFixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                         isOnTheFly)};
 
         }
       }
index c2c326d77c72edd52e10aa75726fabde629097f8..d2e1ef9aa180e13fcea72b11846a85eb61aa55b2 100644 (file)
@@ -28,7 +28,7 @@ public class InlineSameParameterValueTest extends LightQuickFixTestCase {
     final PsiElement psiElement = getFile().findElementAt(offset);
     assert psiElement != null;
     final ProblemDescriptor descriptor = InspectionManager.getInstance(getProject())
-      .createProblemDescriptor(psiElement, "", fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+      .createProblemDescriptor(psiElement, "", fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true);
     fix.applyFix(getProject(), descriptor);
     final String expectedFilePath = getBasePath() + "/after" + testName;
     checkResultByFile("In file :" + expectedFilePath, expectedFilePath, false);
@@ -39,4 +39,4 @@ public class InlineSameParameterValueTest extends LightQuickFixTestCase {
   protected String getBasePath() {
     return "/quickFix/SameParameterValue";
   }
-}
\ No newline at end of file
+}
index 4570459478fa3eec5a1f5e8b44545b10f2ab7324..83a3993f8dd3f53454aa12a3cab6d606e9ac7e3c 100644 (file)
@@ -37,19 +37,23 @@ public abstract class InspectionManager {
    * @param psiElement problem is reported against
    * @param descriptionTemplate problem message. Use <code>#ref</code> for a link to problem piece of code and <code>#loc</code> for location in source code.
    * @param fix should be null if no fix is provided.
+   * @param onTheFly for local tools on batch run
    */
-  @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate, LocalQuickFix fix, ProblemHighlightType highlightType);
+  @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate,
+                                                                     LocalQuickFix fix, ProblemHighlightType highlightType, boolean onTheFly);
 
-  @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate, LocalQuickFix[] fixes, ProblemHighlightType highlightType);
+  @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate,
+                                                                     LocalQuickFix[] fixes, ProblemHighlightType highlightType,
+                                                                     boolean onTheFly);
 
-  @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate, LocalQuickFix[] fixes, ProblemHighlightType highlightType, boolean isAfterEndOfLine);
+  @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate,
+                                                                     LocalQuickFix[] fixes, ProblemHighlightType highlightType,
+                                                                     boolean onTheFly, boolean isAfterEndOfLine);
 
   @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement startElement,
                                                                      @NotNull PsiElement endElement,
                                                                      @NotNull String descriptionTemplate,
-                                                                     ProblemHighlightType highlightType,
-                                                                     LocalQuickFix... fixes
-  );
+                                                                     ProblemHighlightType highlightType, boolean onTheFly, LocalQuickFix... fixes);
 
   
   @NotNull public abstract Project getProject();
@@ -57,17 +61,15 @@ public abstract class InspectionManager {
   public abstract ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement,
                                                             final TextRange rangeInElement,
                                                             @NotNull final String descriptionTemplate,
-                                                            final ProblemHighlightType highlightType,
-                                                            final LocalQuickFix... fixes);
+                                                            final ProblemHighlightType highlightType, boolean onTheFly, final LocalQuickFix... fixes);
 
   public abstract ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement,
                                                             @NotNull final String descriptionTemplate,
                                                             final ProblemHighlightType highlightType,
-                                                            @Nullable final HintAction hintAction,
-                                                            final LocalQuickFix... fixes);
+                                                            @Nullable final HintAction hintAction, boolean onTheFly, final LocalQuickFix... fixes);
 
   public abstract ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement,
                                                             @NotNull final String descriptionTemplate,
                                                             final boolean showTooltip,
-                                                            final ProblemHighlightType highlightType, final LocalQuickFix... fixes);
+                                                            final ProblemHighlightType highlightType, boolean onTheFly, final LocalQuickFix... fixes);
 }
index 3ddf3b152c110019e0ac0e7f706ac06f12b474ea..2eb72817a8d500d93f7c9f0907828af025334cf5 100644 (file)
@@ -19,7 +19,7 @@ import com.intellij.openapi.editor.colors.TextAttributesKey;
 import com.intellij.psi.PsiElement;
 
 /**
- * See {@link InspectionManager#createProblemDescriptor(PsiElement, String, LocalQuickFix, ProblemHighlightType) } for method descriptions.
+ * See {@link InspectionManager#createProblemDescriptor(com.intellij.psi.PsiElement, String, LocalQuickFix, ProblemHighlightType,boolean) } for method descriptions.
  */
 public interface ProblemDescriptor extends CommonProblemDescriptor{
   PsiElement getPsiElement();
index 4c7a3a80f861ef6506eb1532fcb9435d201a85b3..710466cd8912f9e8ceee1713dd28d6cf290d4e65 100644 (file)
@@ -37,11 +37,13 @@ public class ProblemsHolder {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ProblemsHolder");
   private final InspectionManager myManager;
   private final PsiFile myFile;
+  private boolean myOnTheFly;
   private List<ProblemDescriptor> myProblems = null;
 
-  public ProblemsHolder(@NotNull InspectionManager manager, @NotNull PsiFile file) {
+  public ProblemsHolder(@NotNull InspectionManager manager, @NotNull PsiFile file, boolean onTheFly) {
     myManager = manager;
     myFile = file;
+    myOnTheFly = onTheFly;
   }
 
   public void registerProblem(PsiElement psiElement, @Nls String descriptionTemplate, LocalQuickFix... fixes) {
@@ -52,7 +54,7 @@ public class ProblemsHolder {
                               String descriptionTemplate,
                               ProblemHighlightType highlightType,
                               LocalQuickFix... fixes) {
-    registerProblem(myManager.createProblemDescriptor(psiElement, descriptionTemplate, fixes, highlightType));
+    registerProblem(myManager.createProblemDescriptor(psiElement, descriptionTemplate, fixes, highlightType, myOnTheFly));
   }
 
   public void registerProblem(ProblemDescriptor problemDescriptor) {
@@ -77,7 +79,8 @@ public class ProblemsHolder {
       fixes = ((LocalQuickFixProvider)reference).getQuickFixes();
     }
 
-    registerProblem(myManager.createProblemDescriptor(reference.getElement(), reference.getRangeInElement(), descriptionTemplate, highlightType, fixes));
+    registerProblem(myManager.createProblemDescriptor(reference.getElement(), reference.getRangeInElement(), descriptionTemplate, highlightType,
+                                                      myOnTheFly, fixes));
   }
 
   public void registerProblem(PsiReference reference) {
@@ -91,7 +94,8 @@ public class ProblemsHolder {
                               final TextRange rangeInElement,
                               final LocalQuickFix... fixes) {
 
-    final ProblemDescriptor descriptor = myManager.createProblemDescriptor(psiElement, rangeInElement, message, highlightType, fixes);
+    final ProblemDescriptor descriptor = myManager.createProblemDescriptor(psiElement, rangeInElement, message, highlightType, myOnTheFly,
+                                                                           fixes);
     registerProblem(descriptor);
   }
 
@@ -100,7 +104,7 @@ public class ProblemsHolder {
                               @NotNull final String message,
                               final LocalQuickFix... fixes) {
 
-    final ProblemDescriptor descriptor = myManager.createProblemDescriptor(psiElement, rangeInElement, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fixes);
+    final ProblemDescriptor descriptor = myManager.createProblemDescriptor(psiElement, rangeInElement, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly, fixes);
     registerProblem(descriptor);
   }
 
@@ -124,4 +128,8 @@ public class ProblemsHolder {
   public boolean hasResults() {
     return myProblems != null && !myProblems.isEmpty();
   }
+
+  public boolean isOnTheFly() {
+    return myOnTheFly;
+  }
 }
index a943ec93fe9779afdc188e92a9382032a70eef89..c74efd2d06b18b425cb7a5d039b528c58a5ebd6f 100644 (file)
@@ -175,8 +175,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
             }
           }
           ProblemDescriptor patchedDescriptor = iManager.createProblemDescriptor(myFile, hostRange, descriptor.getDescriptionTemplate(),
-                                                                                 descriptor.getHighlightType(),
-                                                                                 localFixes);
+                                                                                 descriptor.getHighlightType(), true, localFixes);
           LocalInspectionToolWrapper toolWrapper = tool2Wrapper.get(tool);
           toolWrapper.addProblemDescriptors(Collections.singletonList(patchedDescriptor), true);
         }
@@ -204,7 +203,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
 
         ApplicationManager.getApplication().assertReadAccessAllowed();
 
-        ProblemsHolder holder = new ProblemsHolder(iManager, myFile);
+        ProblemsHolder holder = new ProblemsHolder(iManager, myFile, isOnTheFly);
         PsiElementVisitor elementVisitor = tool.buildVisitor(holder, isOnTheFly);
         //noinspection ConstantConditions
         if(elementVisitor == null) {
@@ -471,7 +470,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
 
   private static void inspectInjectedPsi(PsiFile injectedPsi, List<InjectedPsiInspectionResult> result, List<LocalInspectionTool> tools) {
     InspectionManager inspectionManager = InspectionManager.getInstance(injectedPsi.getProject());
-    final ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, injectedPsi);
+    final ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, injectedPsi, true);
     final PsiElement host = injectedPsi.getContext();
 
     final PsiElement[] elements = getElementsIntersectingRange(injectedPsi, 0, injectedPsi.getTextLength());
index 75c129695ced732319ac10acc3de35f558759b85..b5b0a077e8edc69214bee52485b9bbdc887aa076 100644 (file)
@@ -17,9 +17,9 @@
 package com.intellij.codeInspection;
 
 import com.intellij.codeInspection.reference.RefElement;
+import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
-import com.intellij.openapi.util.TextRange;
 
 /**
  * User: Maxim.Mossienko
@@ -50,8 +50,7 @@ public class GlobalInspectionUtil {
         elt,
         range,
         createInspectionMessage(message),
-        problemHighlightType
-    );
+        problemHighlightType, false);
     problemDescriptionsProcessor.addProblemElement(
       retrieveRefElement(elt, globalContext),
       descriptor
index 38b18ffb4e22cfade1827f8263ac0cfacf5d4abd..a39140be981d6373cdf850878cc3b4e1c1410cac 100644 (file)
@@ -18,11 +18,11 @@ package com.intellij.codeInspection;
 
 import com.intellij.analysis.AnalysisScope;
 import com.intellij.codeHighlighting.HighlightDisplayLevel;
-import com.intellij.openapi.util.TextRange;
+import com.intellij.codeInsight.daemon.impl.analysis.DefaultHighlightVisitor;
+import com.intellij.codeInsight.highlighting.HighlightErrorFilter;
 import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
-import com.intellij.codeInsight.highlighting.HighlightErrorFilter;
-import com.intellij.codeInsight.daemon.impl.analysis.DefaultHighlightVisitor;
 import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NotNull;
 
@@ -107,8 +107,7 @@ public class SyntaxErrorInspection extends GlobalInspectionTool {
           element,
           GlobalInspectionUtil.createInspectionMessage(element.getErrorDescription()),
           ProblemHighlightType.ERROR,
-          null
-        );
+          null, false);
       }
       else {
         PsiElement parent = element;
@@ -126,7 +125,7 @@ public class SyntaxErrorInspection extends GlobalInspectionTool {
         descriptor = manager.createProblemDescriptor(parent,
                                                      new TextRange(offset, offset+1),
                                                      GlobalInspectionUtil.createInspectionMessage(element.getErrorDescription()),
-                                                     ProblemHighlightType.ERROR);
+                                                     ProblemHighlightType.ERROR, false);
       }
 
       problemDescriptionsProcessor.addProblemElement(GlobalInspectionUtil.retrieveRefElement(element, globalContext), descriptor);
index 07b9960af0544c2d4134de72d690e97a0c60247c..8a1113e73c1550982cbf17cbe29a16f87a8a8a41 100644 (file)
@@ -146,7 +146,7 @@ public class GlobalInspectionToolWrapper extends DescriptorProviderInspection {
                                                                        ((ProblemDescriptor)problemDescriptor).getEndElement(),
                                                                        problemDescriptor.getDescriptionTemplate(),
                                                                        new LocalQuickFix[]{(LocalQuickFix)fix},
-                                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null);
+                                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null, false);
         return QuickFixWrapper.wrap(descriptor, 0);
       }
       else {
index 2999778704f8e7cf5a4138e4e68e296949fe81f7..bff59cc2ab2c5c2d01ae4bd45278831dc86c9322 100644 (file)
@@ -98,58 +98,57 @@ public class InspectionManagerEx extends InspectionManager {
   public ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement,
                                                    @NotNull String descriptionTemplate,
                                                    LocalQuickFix fix,
-                                                   ProblemHighlightType highlightType) {
+                                                   ProblemHighlightType highlightType, boolean onTheFly) {
     LocalQuickFix[] quickFixes = fix != null ? new LocalQuickFix[]{fix} : null;
-    return createProblemDescriptor(psiElement, descriptionTemplate, quickFixes, highlightType);
+    return createProblemDescriptor(psiElement, descriptionTemplate, quickFixes, highlightType, onTheFly);
   }
 
   @NotNull
   public ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement,
                                                    @NotNull String descriptionTemplate,
                                                    LocalQuickFix[] fixes,
-                                                   ProblemHighlightType highlightType) {
-    return createProblemDescriptor(psiElement, descriptionTemplate, fixes, highlightType, false);
+                                                   ProblemHighlightType highlightType, boolean onTheFly) {
+    return createProblemDescriptor(psiElement, descriptionTemplate, fixes, highlightType, onTheFly, false);
   }
 
   @NotNull
   public ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement,
                                                    @NotNull String descriptionTemplate,
                                                    LocalQuickFix[] fixes,
-                                                   ProblemHighlightType highlightType,
-                                                   boolean isAfterEndOfLine) {
-    return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, isAfterEndOfLine, null);
+                                                   ProblemHighlightType highlightType, boolean onTheFly, boolean isAfterEndOfLine) {
+    return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, isAfterEndOfLine, null, onTheFly);
   }
 
   @NotNull
   public ProblemDescriptor createProblemDescriptor(@NotNull PsiElement startElement,
                                                    @NotNull PsiElement endElement,
                                                    @NotNull String descriptionTemplate,
-                                                   ProblemHighlightType highlightType,
-                                                   LocalQuickFix... fixes) {
-    return new ProblemDescriptorImpl(startElement, endElement, descriptionTemplate, fixes, highlightType, false, null);
+                                                   ProblemHighlightType highlightType, boolean onTheFly, LocalQuickFix... fixes) {
+    return new ProblemDescriptorImpl(startElement, endElement, descriptionTemplate, fixes, highlightType, false, null, onTheFly);
   }
 
   public ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement,
                                                    final TextRange rangeInElement,
                                                    @NotNull final String descriptionTemplate,
-                                                   final ProblemHighlightType highlightType,
-                                                   final LocalQuickFix... fixes) {
-    return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, rangeInElement);
+                                                   final ProblemHighlightType highlightType, boolean onTheFly, final LocalQuickFix... fixes) {
+    return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, rangeInElement, onTheFly);
   }
 
   public ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement, @NotNull final String descriptionTemplate, final ProblemHighlightType highlightType,
                                                    @Nullable final HintAction hintAction,
+                                                   boolean onTheFly,
                                                    final LocalQuickFix... fixes) {
 
-    return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, null, hintAction);
+    return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, null, hintAction, onTheFly);
   }
 
   @Override
   public ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement,
                                                    @NotNull String descriptionTemplate,
                                                    boolean showTooltip,
-                                                   ProblemHighlightType highlightType, LocalQuickFix... fixes) {
-    return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, null, showTooltip, null);
+                                                   ProblemHighlightType highlightType, boolean onTheFly, LocalQuickFix... fixes) {
+    return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, null, showTooltip, null,
+                                     onTheFly);
   }
 
   public GlobalInspectionContextImpl createNewGlobalContext(boolean reuse) {
index 675f231ed034e37413525d42efdd895e9ad9aaf4..ba6e0964e4cffd88cb4d040f3c770d5113f3d04f 100644 (file)
@@ -59,7 +59,7 @@ public final class LocalInspectionToolWrapper extends DescriptorProviderInspecti
   }
 
   public void processFile(final PsiFile file, final boolean filterSuppressed, final InspectionManager manager, final boolean isOnTheFly) {
-    final ProblemsHolder holder = new ProblemsHolder(manager, file);
+    final ProblemsHolder holder = new ProblemsHolder(manager, file, isOnTheFly);
     final PsiElementVisitor customVisitor = myTool.buildVisitor(holder, isOnTheFly);
     LOG.assertTrue(!(customVisitor instanceof PsiRecursiveElementVisitor), "The visitor returned from LocalInspectionTool.buildVisitor() must not be recursive");
 
index 5e8475a520da0a7e29f4669ce042766468695e8f..6a04b2ebb44d44969e5e6d11b6f3c981b52bda95 100644 (file)
@@ -49,14 +49,20 @@ public class ProblemDescriptorImpl extends CommonProblemDescriptorImpl implement
   private TextAttributesKey myEnforcedTextAttributes;
 
   public ProblemDescriptorImpl(@NotNull PsiElement startElement, @NotNull PsiElement endElement, String descriptionTemplate, LocalQuickFix[] fixes,
-                               ProblemHighlightType highlightType, boolean isAfterEndOfLine, final TextRange rangeInElement) {
-    this(startElement, endElement, descriptionTemplate, fixes, highlightType, isAfterEndOfLine, rangeInElement, null);
+                               ProblemHighlightType highlightType,
+                               boolean isAfterEndOfLine,
+                               final TextRange rangeInElement,
+                               boolean onTheFly) {
+    this(startElement, endElement, descriptionTemplate, fixes, highlightType, isAfterEndOfLine, rangeInElement, null, onTheFly);
   }
 
   public ProblemDescriptorImpl(@NotNull PsiElement startElement, @NotNull PsiElement endElement, String descriptionTemplate, LocalQuickFix[] fixes,
-                               ProblemHighlightType highlightType, boolean isAfterEndOfLine, final TextRange rangeInElement,
-                               @Nullable HintAction hintAction) {
-    this(startElement, endElement, descriptionTemplate, fixes, highlightType, isAfterEndOfLine, rangeInElement, true, hintAction);
+                               ProblemHighlightType highlightType,
+                               boolean isAfterEndOfLine,
+                               final TextRange rangeInElement,
+                               @Nullable HintAction hintAction,
+                               boolean onTheFly) {
+    this(startElement, endElement, descriptionTemplate, fixes, highlightType, isAfterEndOfLine, rangeInElement, true, hintAction, onTheFly);
   }
 
   public ProblemDescriptorImpl(@NotNull PsiElement startElement, @NotNull PsiElement endElement, String descriptionTemplate, LocalQuickFix[] fixes,
@@ -64,7 +70,8 @@ public class ProblemDescriptorImpl extends CommonProblemDescriptorImpl implement
                                boolean isAfterEndOfLine,
                                final TextRange rangeInElement,
                                final boolean tooltip,
-                               @Nullable HintAction hintAction) {
+                               @Nullable HintAction hintAction,
+                               boolean onTheFly) {
 
     super(fixes, descriptionTemplate);
     myShowTooltip = tooltip;
@@ -82,7 +89,7 @@ public class ProblemDescriptorImpl extends CommonProblemDescriptorImpl implement
 
     myHighlightType = highlightType;
     final Project project = startElement.getProject();
-    final boolean useLazy = ApplicationManager.getApplication().isHeadlessEnvironment();
+    final boolean useLazy = !onTheFly || ApplicationManager.getApplication().isHeadlessEnvironment();
     final SmartPointerManager manager = SmartPointerManager.getInstance(project);
     myStartSmartPointer = useLazy? manager.createLazyPointer(startElement) : manager.createSmartPsiElementPointer(startElement);
     myEndSmartPointer = startElement == endElement ? null : useLazy ? manager.createLazyPointer(endElement) : manager.createSmartPsiElementPointer(endElement);
index 5c77b44053462d406e1c7a4657b49b5b3e2f832c..9d354c2f43e2f15100f6661a90345a3e15934bd8 100644 (file)
@@ -72,7 +72,7 @@ public class OfflineProblemDescriptorNode extends ProblemDescriptionNode {
         final PsiElement psiElement = ((RefElement)element).getElement();
         if (psiElement != null) {
           PsiFile containingFile = psiElement.getContainingFile();
-          final ProblemsHolder holder = new ProblemsHolder(inspectionManager, containingFile);
+          final ProblemsHolder holder = new ProblemsHolder(inspectionManager, containingFile, false);
           final LocalInspectionTool localInspectionTool = ((LocalInspectionToolWrapper)myTool).getTool();
           final PsiElementVisitor visitor = localInspectionTool.buildVisitor(holder, false);
           final PsiElement[] elementsInRange = LocalInspectionsPass.getElementsIntersectingRange(containingFile,
@@ -108,11 +108,11 @@ public class OfflineProblemDescriptorNode extends ProblemDescriptionNode {
       final PsiElement psiElement = ((RefElement)element).getElement();
       ProblemDescriptor descriptor = inspectionManager.createProblemDescriptor(psiElement, offlineProblemDescriptor.getDescription(),
                                                                                (LocalQuickFix)null,
-                                                                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
       final LocalQuickFix[] quickFixes = getFixes(descriptor, hints);
       if (quickFixes != null) {
         descriptor = inspectionManager.createProblemDescriptor(psiElement, offlineProblemDescriptor.getDescription(), quickFixes,
-                                                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
       }
       setUserObject(descriptor);
       return descriptor;
@@ -150,4 +150,4 @@ public class OfflineProblemDescriptorNode extends ProblemDescriptionNode {
   public boolean isValid() {
     return getDescriptor() != null && super.isValid();
   }
-}
\ No newline at end of file
+}
index 6b688bc5eba7943e09a9740ca6158f956757c787..6eb70208d301e54337994c72d7c278e01b5b1d12 100644 (file)
@@ -60,7 +60,7 @@ public class BooleanMethodIsAlwaysInvertedInspection extends GlobalJavaInspectio
         return new ProblemDescriptor[] { manager.createProblemDescriptor(psiIdentifier,
                                                                          InspectionsBundle.message("boolean.method.is.always.inverted.problem.descriptor"),
                                                                          new InvertMethodFix(),
-                                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
+                                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false)};
       }
     }
     return null;
index da4831b3015b5f96b7d9f364f3db17155e4906ab..0c32f4cfe09bf8ac624d2cad51739e1f995e8df9 100644 (file)
@@ -64,7 +64,7 @@ public class BooleanFieldAlwaysNegatedInspection extends BaseGlobalInspection {
         }
         return new ProblemDescriptor[]{manager.createProblemDescriptor(refField.getElement(), InspectionGadgetsBundle.message(
                 "boolean.field.always.negated.problem.descriptor"), (LocalQuickFix []) null,
-                ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
+                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false)};
     }
 
   protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext context,
index 83a729a268f7db6d7e05943a609b2aae68f2b683..3623b63f648c0e908d0af1c513e8a89cf4bbf71f 100644 (file)
@@ -85,7 +85,7 @@ public class MethodReturnAlwaysConstantInspection extends BaseGlobalInspection {
                     InspectionGadgetsBundle.message(
                             "method.return.always.constant.problem.descriptor"),
                     (LocalQuickFix[]) null,
-                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false));
             siblingRefMethod.putUserData(ALWAYS_CONSTANT,
                     Boolean.valueOf(true));
         }
@@ -110,4 +110,4 @@ public class MethodReturnAlwaysConstantInspection extends BaseGlobalInspection {
         final PsiExpression value = returnStatement.getReturnValue();
         return value != null && PsiUtil.isConstantExpression(value);
     }
-}
\ No newline at end of file
+}
index 02b3f26efa0d7ab5118e1d7dc40014c97d2c551f..f0b0832d85f556043aaec36f243f1350ddc8dfd5 100644 (file)
@@ -76,7 +76,7 @@ public class MethodReturnAlwaysIgnoredInspection extends BaseGlobalInspection {
         final ProblemDescriptor descriptor = manager.createProblemDescriptor(method,
                 InspectionGadgetsBundle.message("method.return.always.ignored.problem.descriptor"),
                 (LocalQuickFix []) null,
-                ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
         if (originalProblemDescriptors == null) {
             return new ProblemDescriptor[]{descriptor};
         } else {
index 3b0766b2bebda714233cd193d10fe88359af18df..cda679bdd7021662e58e575f8a1436498ffe6e39 100644 (file)
@@ -17,9 +17,9 @@ package com.intellij.lang.ant.validation;
 
 import com.intellij.codeHighlighting.HighlightDisplayLevel;
 import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.lang.ant.AntBundle;
 import com.intellij.lang.ant.psi.AntFile;
 import com.intellij.lang.ant.psi.AntProject;
@@ -70,7 +70,8 @@ public class AntDuplicateImportedTargetsInspection extends AntInspection {
               final String duplicatedMessage =
                 AntBundle.message("target.is.duplicated.in.imported.file", name, target.getAntFile().getName());
               problems
-                .add(manager.createProblemDescriptor(t, duplicatedMessage, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                .add(manager.createProblemDescriptor(t, duplicatedMessage, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                     isOnTheFly));
             }
           }
           final int prolemCount = problems.size();
index c5024eb797352f0330e0cd2e291ee39b93c72b80..46e98c26294ba914f6871e67f0b9b57c1fbb1ddd 100644 (file)
@@ -16,9 +16,9 @@
 package com.intellij.lang.ant.validation;
 
 import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.lang.ant.AntBundle;
 import com.intellij.lang.ant.psi.AntFile;
 import com.intellij.lang.ant.psi.AntProject;
@@ -64,9 +64,11 @@ public class AntDuplicateTargetsInspection extends AntInspection {
             if (t != null) {
               final String duplicatedMessage = AntBundle.message("target.is.duplicated", name);
               problems.add(
-                manager.createProblemDescriptor(target, duplicatedMessage, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                manager.createProblemDescriptor(target, duplicatedMessage, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                isOnTheFly));
               problems
-                .add(manager.createProblemDescriptor(t, duplicatedMessage, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                .add(manager.createProblemDescriptor(t, duplicatedMessage, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                     isOnTheFly));
             }
             name2Target.put(name, target);
           }
index fe320d431aedb3292527053cad562dd024e7e4a3..f569dcf893c88bcf6f35c5f8fe603896bcc653f7 100644 (file)
@@ -16,9 +16,9 @@
 package com.intellij.lang.ant.validation;
 
 import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.lang.ant.AntBundle;
 import com.intellij.lang.ant.psi.AntFile;
 import com.intellij.lang.ant.psi.AntProject;
@@ -57,7 +57,7 @@ public class AntMissingPropertiesFileInspection extends AntInspection {
       final AntProject project = ((AntFile)file).getAntProject();
       if (project != null) {
         final List<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>();
-        checkElement(project, manager, problems);
+        checkElement(project, manager, problems, isOnTheFly);
         final int problemCount = problems.size();
         if (problemCount > 0) {
           return problems.toArray(new ProblemDescriptor[problemCount]);
@@ -69,7 +69,7 @@ public class AntMissingPropertiesFileInspection extends AntInspection {
 
   private static void checkElement(final AntStructuredElement tag,
                                    @NotNull InspectionManager manager,
-                                   final List<ProblemDescriptor> problems) {
+                                   final List<ProblemDescriptor> problems, boolean isOnTheFly) {
     for (final PsiElement element : tag.getChildren()) {
       if (element instanceof AntProperty) {
         final AntProperty prop = (AntProperty)element;
@@ -77,12 +77,12 @@ public class AntMissingPropertiesFileInspection extends AntInspection {
           final String filename = prop.getFileName();
           if (filename != null && prop.getPropertiesFile() == null) {
             problems.add(manager.createProblemDescriptor(prop, AntBundle.message("file.doesnt.exist", filename), LocalQuickFix.EMPTY_ARRAY,
-                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly));
           }
         }
       }
       else if (element instanceof AntStructuredElement) {
-        checkElement((AntStructuredElement)element, manager, problems);
+        checkElement((AntStructuredElement)element, manager, problems, isOnTheFly);
       }
     }
   }
index 3ab0810098787b737317e75cbe95363a99dcfe20..a9ff3b9ec7283f279ead2ce766145954d0222ae9 100644 (file)
@@ -133,7 +133,7 @@ public class ComponentNotRegisteredInspection extends DevKitInspectionBase {
                     classIdentifier,
                     DevKitBundle.message("inspections.component.not.registered.message",
                                          DevKitBundle.message("new.menu.action.text")),
-                    fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                    fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
             return new ProblemDescriptor[]{problem};
           } else {
             // action IS registered, stop here
@@ -155,7 +155,7 @@ public class ComponentNotRegisteredInspection extends DevKitInspectionBase {
             final ProblemDescriptor problem = manager.createProblemDescriptor(classIdentifier,
                                                                               DevKitBundle.message("inspections.component.not.registered.message",
                                                                                                    DevKitBundle.message(type.myPropertyKey)),
-                                                                              fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                              fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
             return new ProblemDescriptor[]{problem};
           } else {
             // component IS registered, stop here
index cdefd284711f71128eb096b90c7d7c9a5478da4e..f7372cedb5d50968e6d7c2e593fd0f7aefb67c5c 100644 (file)
@@ -79,7 +79,7 @@ public class DescriptionNotFoundInspection extends DevKitInspectionBase{
       .createProblemDescriptor(problem == null ? nameIdentifier : problem,
                                "Inspection does not have a description",
                                new LocalQuickFix[]{new CreateHtmlDescriptionFix(filename, module)},
-                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
     return new ProblemDescriptor[]{problemDescriptor};    
   }
 
index 07b93eb427e00e696ccaba1c08e12eb9ae0bbaf0..ffeb28c9f93e35046749faeb00bb03b2dc1ae0b6 100644 (file)
@@ -142,7 +142,7 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
                                     DevKitBundle.message("keyword.extend"),
                             compClass.getQualifiedName()),
                     ImplementOrExtendFix.createFix(compClass, checkedClass, isOnTheFly),
-                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly));
           }
         }
         if (ActionType.ACTION.isOfType(checkedClass)) {
@@ -150,12 +150,13 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
             problems = addProblem(problems, manager.createProblemDescriptor(nameIdentifier,
                     DevKitBundle.message("inspections.registration.problems.missing.noarg.ctor"),
                     new CreateConstructorFix(checkedClass, isOnTheFly),
-                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly));
           }
         }
         if (isAbstract(checkedClass)) {
           problems = addProblem(problems, manager.createProblemDescriptor(nameIdentifier,
-                  DevKitBundle.message("inspections.registration.problems.abstract"), LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                  DevKitBundle.message("inspections.registration.problems.abstract"), LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                  isOnTheFly));
         }
         return problems != null ? problems.toArray(new ProblemDescriptor[problems.size()]) : null;
       }
@@ -197,10 +198,10 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
     private List<ProblemDescriptor> myList;
     private final InspectionManager myManager;
     private final XmlFile myXmlFile;
-    private final boolean myOnTheFly;
     private final PsiManager myPsiManager;
     private final GlobalSearchScope myScope;
     private final Set<String> myInterfaceClasses = new THashSet<String>();
+    private boolean myOnTheFly;
 
     public RegistrationChecker(InspectionManager manager, XmlFile xmlFile, boolean onTheFly) {
       myManager = manager;
@@ -214,7 +215,7 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
       if (impl == null) {
         addProblem(component,
                 DevKitBundle.message("inspections.registration.problems.missing.implementation.class"),
-                ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
       } else {
         String intfName = null;
         PsiClass intfClass = null;
@@ -228,21 +229,19 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
           addProblem(impl,
                   DevKitBundle.message("inspections.registration.problems.cannot.resolve.class",
                           DevKitBundle.message("class.implementation")),
-                  ProblemHighlightType.LIKE_UNKNOWN_SYMBOL,
-                  ((LocalQuickFix)QuickFixFactory.getInstance()
+                  ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, myOnTheFly, ((LocalQuickFix)QuickFixFactory.getInstance()
               .createCreateClassOrInterfaceFix(myXmlFile, implClassName, true, intfClass != null ? intfName : type.myClassName)));
         } else {
           final PsiClass componentClass = JavaPsiFacade.getInstance(myPsiManager.getProject()).findClass(type.myClassName, myScope);
           if (componentClass != null && !implClass.isInheritor(componentClass, true) && type != ComponentType.APPLICATION) {
             addProblem(impl,
                     DevKitBundle.message("inspections.registration.problems.component.should.implement", type.myClassName),
-                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                    ImplementOrExtendFix.createFix(componentClass, implClass, myOnTheFly));
+                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly, ImplementOrExtendFix.createFix(componentClass, implClass, myOnTheFly));
           }
           if (isAbstract(implClass)) {
             addProblem(impl,
                     DevKitBundle.message("inspections.registration.problems.abstract"),
-                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
           }
         }
         if (intfName != null) {
@@ -250,8 +249,7 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
             addProblem(intf,
                     DevKitBundle.message("inspections.registration.problems.cannot.resolve.class",
                             DevKitBundle.message("class.interface")),
-                    ProblemHighlightType.LIKE_UNKNOWN_SYMBOL,
-                    ((LocalQuickFix)QuickFixFactory.getInstance()
+                    ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, myOnTheFly, ((LocalQuickFix)QuickFixFactory.getInstance()
               .createCreateClassOrInterfaceFix(myXmlFile, intfName, false, type.myClassName)),
                     ((LocalQuickFix)QuickFixFactory.getInstance()
               .createCreateClassOrInterfaceFix(myXmlFile, intfName, true, type.myClassName)));
@@ -275,7 +273,7 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
             if (intfClass != implClass && !implClass.isInheritor(intfClass, true)) {
               addProblem(impl,
                   DevKitBundle.message("inspections.registration.problems.component.incompatible.interface", fqn),
-                      ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                      ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
             }
           }
         }
@@ -287,7 +285,7 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
       if (myInterfaceClasses.contains(fqn)) {
         addProblem(value,
             DevKitBundle.message("inspections.registration.problems.component.duplicate.interface", fqn),
-            ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+            ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
         return true;
       }
       return false;
@@ -322,7 +320,7 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
             addProblem(token,
                     DevKitBundle.message("inspections.registration.problems.cannot.resolve.class",
                             DevKitBundle.message("class.action")),
-                    ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, ((LocalQuickFix)QuickFixFactory.getInstance()
+                    ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, myOnTheFly, ((LocalQuickFix)QuickFixFactory.getInstance()
               .createCreateClassOrInterfaceFix(token, actionName, true, AnAction.class.getName())));
           } else {
             if (!type.isOfType(actionClass)) {
@@ -330,21 +328,19 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
               if (psiClass != null && !actionClass.isInheritor(psiClass, true)) {
                 addProblem(token,
                         DevKitBundle.message("inspections.registration.problems.action.incompatible.class", type.myClassName),
-                        ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                        ImplementOrExtendFix.createFix(psiClass, actionClass, myOnTheFly));
+                        ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly, ImplementOrExtendFix.createFix(psiClass, actionClass, myOnTheFly));
               }
             }
             final ConstructorType noArgCtor = ConstructorType.getNoArgCtor(actionClass);
             if (noArgCtor == null) {
               addProblem(token,
                       DevKitBundle.message("inspections.registration.problems.missing.noarg.ctor"),
-                      ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                      new CreateConstructorFix(actionClass, myOnTheFly));
+                      ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly, new CreateConstructorFix(actionClass, myOnTheFly));
             }
             if (isAbstract(actionClass)) {
               addProblem(token,
                       DevKitBundle.message("inspections.registration.problems.abstract"),
-                      ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                      ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
             }
           }
         }
@@ -352,18 +348,18 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase {
       return true;
     }
 
-    private void addProblem(XmlTagValue impl, String problem, ProblemHighlightType type, LocalQuickFix... fixes) {
+    private void addProblem(XmlTagValue impl, String problem, ProblemHighlightType type, boolean isOnTheFly, LocalQuickFix... fixes) {
       final XmlText[] textElements = impl.getTextElements();
       for (XmlText text : textElements) {
         if (text.getValue().trim().length() > 0) {
-          addProblem(text, problem, type, fixes);
+          addProblem(text, problem, type, isOnTheFly, fixes);
         }
       }
     }
 
-    private void addProblem(PsiElement element, String problem, ProblemHighlightType type, LocalQuickFix... fixes) {
+    private void addProblem(PsiElement element, String problem, ProblemHighlightType type, boolean onTheFly, LocalQuickFix... fixes) {
       if (myList == null) myList = new SmartList<ProblemDescriptor>();
-      myList.add(myManager.createProblemDescriptor(element, problem, fixes, type));
+      myList.add(myManager.createProblemDescriptor(element, problem, fixes, type, onTheFly));
     }
 
     @Nullable
index 277a17120c6a64f672b0417ddc5ee4aec7dcd518..435d7074b7dbd31c66a5f00d625374c6e666cec6 100644 (file)
@@ -16,7 +16,6 @@
 package org.jetbrains.plugins.groovy.codeInspection;
 
 import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.LocalInspectionTool;
 import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.ProblemsHolder;
 import com.intellij.psi.PsiElement;
@@ -90,14 +89,14 @@ public abstract class BaseInspection extends GroovySuppressableInspectionTool {
   }
 
   @Nullable
-  public ProblemDescriptor[] checkFile(@NotNull PsiFile psiFile, @NotNull InspectionManager inspectionManager, boolean onTheFly) {
+  public ProblemDescriptor[] checkFile(@NotNull PsiFile psiFile, @NotNull InspectionManager inspectionManager, boolean isOnTheFly) {
     if (!(psiFile instanceof GroovyFile)) {
-      return super.checkFile(psiFile, inspectionManager, onTheFly);
+      return super.checkFile(psiFile, inspectionManager, isOnTheFly);
     }
     final GroovyFile groovyFile = (GroovyFile) psiFile;
 
-    final ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, psiFile);
-    final BaseInspectionVisitor visitor = buildGroovyVisitor(problemsHolder, onTheFly);
+    final ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, psiFile, isOnTheFly);
+    final BaseInspectionVisitor visitor = buildGroovyVisitor(problemsHolder, isOnTheFly);
     groovyFile.accept(visitor);
     final List<ProblemDescriptor> problems = problemsHolder.getResults();
     if (problems == null) {
@@ -119,4 +118,4 @@ public abstract class BaseInspection extends GroovySuppressableInspectionTool {
   }
 
   protected abstract BaseInspectionVisitor buildVisitor();
-}
\ No newline at end of file
+}
index 2b813f2634e6f43281e9888089308c5097cfe69e..2e6cff0b8c1ade412ad9fd393806eee491bc6351 100644 (file)
@@ -30,8 +30,8 @@ import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
 import com.intellij.ide.util.TreeClassChooser;
 import com.intellij.ide.util.TreeClassChooserFactory;
 import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.extensions.ExtensionPoint;
+import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
 import com.intellij.openapi.ui.DialogWrapper;
@@ -286,7 +286,7 @@ public class I18nInspection extends BaseLocalInspectionTool {
     }
     final PsiCodeBlock body = method.getBody();
     if (body != null) {
-      return checkElement(body, manager);
+      return checkElement(body, manager, isOnTheFly);
     }
     return null;
   }
@@ -300,7 +300,7 @@ public class I18nInspection extends BaseLocalInspectionTool {
     final PsiClassInitializer[] initializers = aClass.getInitializers();
     List<ProblemDescriptor> result = new ArrayList<ProblemDescriptor>();
     for (PsiClassInitializer initializer : initializers) {
-      final ProblemDescriptor[] descriptors = checkElement(initializer, manager);
+      final ProblemDescriptor[] descriptors = checkElement(initializer, manager, isOnTheFly);
       if (descriptors != null) {
         result.addAll(Arrays.asList(descriptors));
       }
@@ -319,10 +319,10 @@ public class I18nInspection extends BaseLocalInspectionTool {
       return null;
     }
     final PsiExpression initializer = field.getInitializer();
-    if (initializer != null) return checkElement(initializer, manager);
+    if (initializer != null) return checkElement(initializer, manager, isOnTheFly);
 
     if (field instanceof PsiEnumConstant) {
-      return checkElement(((PsiEnumConstant)field).getArgumentList(), manager);
+      return checkElement(((PsiEnumConstant)field).getArgumentList(), manager, isOnTheFly);
     }
     return null;
   }
@@ -342,8 +342,8 @@ public class I18nInspection extends BaseLocalInspectionTool {
     return null;
   }
 
-  private ProblemDescriptor[] checkElement(final PsiElement element, InspectionManager manager) {
-    StringI18nVisitor visitor = new StringI18nVisitor(manager);
+  private ProblemDescriptor[] checkElement(final PsiElement element, InspectionManager manager, boolean isOnTheFly) {
+    StringI18nVisitor visitor = new StringI18nVisitor(manager, isOnTheFly);
     element.accept(visitor);
     List<ProblemDescriptor> problems = visitor.getProblems();
     return problems.isEmpty() ? null : problems.toArray(new ProblemDescriptor[problems.size()]);
@@ -382,9 +382,11 @@ public class I18nInspection extends BaseLocalInspectionTool {
   private class StringI18nVisitor extends JavaRecursiveElementVisitor {
     private final List<ProblemDescriptor> myProblems = new ArrayList<ProblemDescriptor>();
     private final InspectionManager myManager;
+    private boolean myOnTheFly;
 
-    public StringI18nVisitor(final InspectionManager manager) {
+    public StringI18nVisitor(final InspectionManager manager, boolean onTheFly) {
       myManager = manager;
+      myOnTheFly = onTheFly;
     }
 
     @Override public void visitAnonymousClass(PsiAnonymousClass aClass) {
@@ -436,7 +438,7 @@ public class I18nInspection extends BaseLocalInspectionTool {
         final ProblemDescriptor problem = myManager
           .createProblemDescriptor(expression,
                                    description,
-                                   fixes.toArray(new LocalQuickFix[fixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                   fixes.toArray(new LocalQuickFix[fixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
         myProblems.add(problem);
       }
     }
index 2c4c8550dafd93f82b664b94b66c55b8ca485cd6..9a64abdf57ce1ee5592edfc3b47a68f0486336f5 100644 (file)
@@ -167,7 +167,7 @@ public class InconsistentResourceBundleInspection extends DescriptorProviderInsp
             String message = InspectionsBundle.message("inconsistent.bundle.property.inherited.with.the.same.value", parent.getName());
             ProblemDescriptor descriptor = manager.createProblemDescriptor(property, message,
                                                                            RemovePropertyLocalFix.INSTANCE,
-                                                                           ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                           ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
             addProblemElement(getRefManager().getReference(file), descriptor);
           }
           parent = parents.get(parent);
@@ -199,7 +199,7 @@ public class InconsistentResourceBundleInspection extends DescriptorProviderInsp
         String message = InspectionsBundle.message("inconsistent.bundle.property.error", inconsistentKey, parent.getName());
         ProblemDescriptor descriptor = manager.createProblemDescriptor(property, message,
                                                                        LocalQuickFix.EMPTY_ARRAY,
-                                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
         addProblemElement(getRefManager().getReference(file), descriptor);
       }
     }
@@ -236,7 +236,7 @@ public class InconsistentResourceBundleInspection extends DescriptorProviderInsp
         String message = InspectionsBundle.message("inconsistent.bundle.untranslated.property.error", untranslatedKey, file.getName());
         ProblemDescriptor descriptor = manager.createProblemDescriptor(untranslatedProperty, message,
                                                                        LocalQuickFix.EMPTY_ARRAY,
-                                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                       ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
         addProblemElement(getRefManager().getReference(untranslatedFile), descriptor);
       }
     }
index 0fbb62afa5083144ad4188565998fe7718bffc2f..0894e454a498e3b5f0145e6fc7ea9c97d9ee5975 100644 (file)
@@ -68,7 +68,7 @@ public class InvalidPropertyKeyInspection extends BaseJavaLocalInspectionTool {
   @Override
   @Nullable
   public ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    return checkElement(method, manager);
+    return checkElement(method, manager, isOnTheFly);
   }
 
   @Override
@@ -77,7 +77,7 @@ public class InvalidPropertyKeyInspection extends BaseJavaLocalInspectionTool {
     final PsiClassInitializer[] initializers = aClass.getInitializers();
     List<ProblemDescriptor> result = new ArrayList<ProblemDescriptor>();
     for (PsiClassInitializer initializer : initializers) {
-      final ProblemDescriptor[] descriptors = checkElement(initializer, manager);
+      final ProblemDescriptor[] descriptors = checkElement(initializer, manager, isOnTheFly);
       if (descriptors != null) {
         result.addAll(Arrays.asList(descriptors));
       }
@@ -90,16 +90,16 @@ public class InvalidPropertyKeyInspection extends BaseJavaLocalInspectionTool {
   @Nullable
   public ProblemDescriptor[] checkField(@NotNull PsiField field, @NotNull InspectionManager manager, boolean isOnTheFly) {
     final PsiExpression initializer = field.getInitializer();
-    if (initializer != null) return checkElement(initializer, manager);
+    if (initializer != null) return checkElement(initializer, manager, isOnTheFly);
 
     if (field instanceof PsiEnumConstant) {
-      return checkElement(((PsiEnumConstant)field).getArgumentList(), manager);
+      return checkElement(((PsiEnumConstant)field).getArgumentList(), manager, isOnTheFly);
     }
     return null;
   }
 
-  @Nullable private static ProblemDescriptor[] checkElement(PsiElement element, final InspectionManager manager) {
-    UnresolvedPropertyVisitor visitor = new UnresolvedPropertyVisitor(manager);
+  @Nullable private static ProblemDescriptor[] checkElement(PsiElement element, final InspectionManager manager, boolean onTheFly) {
+    UnresolvedPropertyVisitor visitor = new UnresolvedPropertyVisitor(manager, onTheFly);
     element.accept(visitor);
     List<ProblemDescriptor> problems = visitor.getProblems();
     return problems.isEmpty() ? null : problems.toArray(new ProblemDescriptor[problems.size()]);
@@ -123,10 +123,12 @@ public class InvalidPropertyKeyInspection extends BaseJavaLocalInspectionTool {
   private static class UnresolvedPropertyVisitor extends JavaRecursiveElementWalkingVisitor {
     private final InspectionManager myManager;
     private final List<ProblemDescriptor> myProblems = new ArrayList<ProblemDescriptor>();
+    private boolean onTheFly;
 
 
-    public UnresolvedPropertyVisitor(final InspectionManager manager) {
+    public UnresolvedPropertyVisitor(final InspectionManager manager, boolean onTheFly) {
       myManager = manager;
+      this.onTheFly = onTheFly;
     }
 
     @Override public void visitAnonymousClass(PsiAnonymousClass aClass) {
@@ -153,7 +155,7 @@ public class InvalidPropertyKeyInspection extends BaseJavaLocalInspectionTool {
         final ProblemDescriptor problem = myManager.createProblemDescriptor(expression,
                                                                             description,
                                                                             new JavaCreatePropertyFix(expression, key, propertiesFiles),
-                                                                            ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
+                                                                            ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, onTheFly);
         myProblems.add(problem);
       } else
       if (expression.getParent() instanceof PsiNameValuePair) {
@@ -168,7 +170,7 @@ public class InvalidPropertyKeyInspection extends BaseJavaLocalInspectionTool {
               final ProblemDescriptor problem = myManager.createProblemDescriptor(expression,
                                                                                   description,
                                                                                   (LocalQuickFix)null,
-                                                                                   ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
+                                                                                   ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, onTheFly);
               myProblems.add(problem);
             }
           }
@@ -196,7 +198,7 @@ public class InvalidPropertyKeyInspection extends BaseJavaLocalInspectionTool {
               myProblems.add(myManager.createProblemDescriptor(methodCall,
                                                                CodeInsightBundle.message("property.has.more.parameters.than.passed", key, paramsCount, args.length-i-1),
                                                                new LocalQuickFix[0], 
-                                                               ProblemHighlightType.GENERIC_ERROR));
+                                                               ProblemHighlightType.GENERIC_ERROR, onTheFly));
             }
             break;
           }
index c5217e696a6661d13e91dafd0bd84e301bda8943..87d0208c59614c65c8f4f2d2aea4aa5046bef894 100644 (file)
  */
 package com.intellij.lang.properties;
 
-import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
-import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.InspectionManager;
 import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiElement;
+import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
+import com.intellij.lang.ASTNode;
 import com.intellij.lang.properties.psi.PropertiesFile;
 import com.intellij.lang.properties.psi.Property;
-import com.intellij.lang.ASTNode;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
 import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.Nullable;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
-import java.util.List;
 import java.util.ArrayList;
-import java.util.Set;
 import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * User: anna
@@ -94,7 +94,8 @@ public class UnusedMessageFormatParameterInspection extends BaseLocalInspectionT
               PsiElement valElement = nodes.length < 3 ? property : nodes[2].getPsi();
               problemDescriptors.add(manager.createProblemDescriptor(valElement, PropertiesBundle.message(
                 "unused.message.format.parameter.problem.descriptor", integer.toString(), Integer.toString(i)),
-                                                                     (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                                                     (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                                     isOnTheFly));
               break;
             }
           }
index b71dad412145a6610fd1f2c0f16d0cdc81e6d1d3..2e4cdadf83573bcb6c9d1cd1fc8e7021246425a3 100644 (file)
@@ -263,7 +263,8 @@ public class DuplicatePropertyInspection extends DescriptorProviderInspection {
       }
       if (duplicatesCount > 1) {
         problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(),
-                                                               (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                                               (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                               false));
       }
     }
 
@@ -305,7 +306,8 @@ public class DuplicatePropertyInspection extends DescriptorProviderInspection {
       }
       if (duplicatesCount > 1 && CHECK_DUPLICATE_KEYS) {
         problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(),
-                                                               (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                                               (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                               false));
       }
     }
 
@@ -343,7 +345,8 @@ public class DuplicatePropertyInspection extends DescriptorProviderInspection {
           }
         }
         problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(),
-                                                               (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                                               (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
+                                                               false));
       }
     }
   }
index 87047193e5cccf8d08f38da611572fe2df7f6e06..e2b0b02a06a27ed8a1a902826b0d9e8047c5fc0d 100644 (file)
@@ -18,9 +18,9 @@ package com.intellij.lang.properties;
 import com.intellij.codeInsight.CodeInsightUtilBase;
 import com.intellij.codeInspection.*;
 import com.intellij.concurrency.JobUtil;
+import com.intellij.lang.ASTNode;
 import com.intellij.lang.properties.psi.PropertiesFile;
 import com.intellij.lang.properties.psi.Property;
-import com.intellij.lang.ASTNode;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
@@ -62,7 +62,7 @@ public class UnusedPropertyInspection extends LocalInspectionTool implements Cus
     return "UnusedProperty";
   }
 
-  public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, boolean isOnTheFly) {
+  public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
     if (!(file instanceof PropertiesFile)) return null;
     final List<Property> properties = ((PropertiesFile)file).getProperties();
     Module module = ModuleUtil.findModuleForPsiElement(file);
@@ -86,7 +86,8 @@ public class UnusedPropertyInspection extends LocalInspectionTool implements Cus
           ASTNode[] nodes = propertyNode.getChildren(null);
           PsiElement key = nodes.length == 0 ? property : nodes[0].getPsi();
           String description = PropertiesBundle.message("unused.property.problem.descriptor.name");
-          ProblemDescriptor descriptor = manager.createProblemDescriptor(key, description, RemovePropertyLocalFix.INSTANCE, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
+          ProblemDescriptor descriptor = manager.createProblemDescriptor(key, description, RemovePropertyLocalFix.INSTANCE, ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+                                                                         isOnTheFly);
           synchronized (descriptors) {
             descriptors.add(descriptor);
           }
index fe3094d2390beeeb9fdf4c7b1c33f9cbc95a5530..081366965736a06208cd2f9a8d77fa6c34fd70d3 100644 (file)
@@ -209,7 +209,8 @@ public class SpellCheckingInspection extends LocalInspectionTool {
     final LocalQuickFix[] quickFixes = fixes.size() > 0 ? fixes.toArray(new LocalQuickFix[fixes.size()]) : null;
 
     final ProblemDescriptor problemDescriptor = holder.getManager()
-      .createProblemDescriptor(token.getElement(), highlightRange, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, quickFixes);
+      .createProblemDescriptor(token.getElement(), highlightRange, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, holder.isOnTheFly(),
+                               quickFixes);
     for (SpellCheckerQuickFix fix : fixes) {
       fix.setDescriptor(problemDescriptor);
     }
index 985b3c49729eec627614dc8a18e951b1c888cfb8..e4eb7986a54bede16e3f59a8fbe0cc3d09f3d589 100644 (file)
@@ -125,7 +125,7 @@ public class DependsOnGroupsInspection extends BaseJavaLocalInspectionTool {
               LOGGER.info("group doesn't exist:" + methodName);
               ProblemDescriptor descriptor = manager.createProblemDescriptor(annotation, "Group '" + methodName + "' is undefined.",
                                                                              new GroupNameQuickFix(methodName),
-                                                                             ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                             ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
               problemDescriptors.add(descriptor);
 
             }
@@ -172,4 +172,4 @@ public class DependsOnGroupsInspection extends BaseJavaLocalInspectionTool {
       */
     }
   }
-}
\ No newline at end of file
+}
index 56f3f6227f27a1d1c20f4657544e507c1a9156e6..be2e622ebc70d6d9a24a6a295ed9e4cf193663a5 100644 (file)
@@ -88,7 +88,7 @@ public class DependsOnMethodInspection extends BaseJavaLocalInspectionTool
                     Matcher matcher = PATTERN.matcher(dep.getValue().getText());
                     while (matcher.find()) {
                         String methodName = matcher.group(1);
-                        checkMethodNameDependency(manager, psiClass, methodName, dep, problemDescriptors);
+                        checkMethodNameDependency(manager, psiClass, methodName, dep, problemDescriptors, isOnTheFly);
                     }
                 }
             }
@@ -97,7 +97,8 @@ public class DependsOnMethodInspection extends BaseJavaLocalInspectionTool
         return problemDescriptors.toArray(new ProblemDescriptor[] {} );
     }
 
-    private static void checkMethodNameDependency(InspectionManager manager, PsiClass psiClass, String methodName, PsiNameValuePair dep, List<ProblemDescriptor> problemDescriptors) {
+    private static void checkMethodNameDependency(InspectionManager manager, PsiClass psiClass, String methodName, PsiNameValuePair dep,
+                                                  List<ProblemDescriptor> problemDescriptors, boolean onTheFly) {
         LOGGER.debug("Found dependsOnMethods with text: " + methodName);
         if (methodName.length() > 0 && methodName.charAt(methodName.length() - 1) == ')') {
 
@@ -106,7 +107,7 @@ public class DependsOnMethodInspection extends BaseJavaLocalInspectionTool
             ProblemDescriptor descriptor = manager.createProblemDescriptor(dep,
                                                                "Method '" + methodName + "' should not include () characters.",
                                                                (LocalQuickFix) null,
-                                                               ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
+                                                               ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, onTheFly);
 
             problemDescriptors.add(descriptor);
 
@@ -118,7 +119,7 @@ public class DependsOnMethodInspection extends BaseJavaLocalInspectionTool
                 ProblemDescriptor descriptor = manager.createProblemDescriptor(dep,
                                                                    "Method '" + methodName + "' unknown.",
                                                                    (LocalQuickFix) null,
-                                                                   ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
+                                                                   ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, onTheFly);
                 problemDescriptors.add(descriptor);
 
             } else {
@@ -130,11 +131,11 @@ public class DependsOnMethodInspection extends BaseJavaLocalInspectionTool
                 ProblemDescriptor descriptor = manager.createProblemDescriptor(dep,
                                                                      "Method '" + methodName + "' is not a test or configuration method.",
                                                                      (LocalQuickFix) null,
-                                                                     ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
+                                                                     ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, onTheFly);
                 problemDescriptors.add(descriptor);
               }
             }
         }
     }
 
-}
\ No newline at end of file
+}
index 4e561ceda7e591c0e183b74f4a4c5c00456de232..d27017aba35fb9c3c28b35cde5183890aebda651 100644 (file)
@@ -65,7 +65,7 @@ public class JUnitConvertTool extends BaseJavaLocalInspectionTool {
       final PsiIdentifier nameIdentifier = psiClass.getNameIdentifier();
       ProblemDescriptor descriptor = manager.createProblemDescriptor(nameIdentifier != null ? nameIdentifier : psiClass, "TestCase can be converted to TestNG",
                                                                      new JUnitConverterQuickFix(),
-                                                                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
       return new ProblemDescriptor[]{descriptor};
     }
     return null;
index 8df2e132281e9d57453e35e9a41d15dc8e8bf513..974f4dd07a3f3635286f025d31a729d81e93f266 100644 (file)
@@ -103,7 +103,7 @@ public class UndeclaredTestInspection extends BaseJavaLocalInspectionTool {
       return new ProblemDescriptor[]{manager.createProblemDescriptor(nameIdentifier, "Undeclared test \'" + aClass.getName() + "\'",
                                                                      new LocalQuickFix[]{new RegisterClassFix(aClass),
                                                                        new CreateTestngFix()},
-                                                                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
+                                                                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly)};
     }
     return null;
   }
index 6c865ba1ed3b84647ce68459b52ee1c4692afb5a..14235ed1200d6a4897de75ca448922e822affe08 100644 (file)
@@ -96,7 +96,7 @@ public abstract class BaseFormInspection extends BaseJavaLocalInspectionTool imp
       if (rootContainer.isInspectionSuppressed(getShortName(), null)) {
         return null;
       }
-      final FormFileErrorCollector collector = new FormFileErrorCollector(file, manager);
+      final FormFileErrorCollector collector = new FormFileErrorCollector(file, manager, isOnTheFly);
       startCheckForm(rootContainer);
       FormEditingUtil.iterate(rootContainer, new FormEditingUtil.ComponentVisitor() {
         public boolean visit(final IComponent component) {
index c0a1fd072519efc597083bf52a11655250f61f37..4adf77d8faf32692d4e2cba95ebe665511373078 100644 (file)
  */
 package com.intellij.uiDesigner.inspections;
 
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.NotNull;
-import com.intellij.uiDesigner.lw.IProperty;
-import com.intellij.uiDesigner.lw.IComponent;
-import com.intellij.uiDesigner.make.FormElementNavigatable;
-import com.intellij.codeInspection.*;
+import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.ProblemHighlightType;
 import com.intellij.codeInspection.ex.ProblemDescriptorImpl;
-import com.intellij.psi.PsiFile;
 import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.psi.PsiFile;
+import com.intellij.uiDesigner.lw.IComponent;
+import com.intellij.uiDesigner.lw.IProperty;
+import com.intellij.uiDesigner.make.FormElementNavigatable;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author yole
@@ -34,11 +37,13 @@ import java.util.ArrayList;
 public class FormFileErrorCollector extends FormErrorCollector {
   private final InspectionManager myManager;
   private final PsiFile myFile;
+  private boolean myOnTheFly;
   private final List<ProblemDescriptor> myProblems = new ArrayList<ProblemDescriptor>();
 
-  public FormFileErrorCollector(final PsiFile file, final InspectionManager manager) {
+  public FormFileErrorCollector(final PsiFile file, final InspectionManager manager, boolean onTheFly) {
     myManager = manager;
     myFile = file;
+    myOnTheFly = onTheFly;
   }
 
   public void addError(final String inspectionId, final IComponent component, @Nullable IProperty prop,
@@ -46,7 +51,7 @@ public class FormFileErrorCollector extends FormErrorCollector {
                        @Nullable EditorQuickFixProvider editorQuickFixProvider) {
     final ProblemDescriptor problemDescriptor = myManager.createProblemDescriptor(myFile, JDOMUtil.escapeText(errorMessage),
                                                                                   (LocalQuickFix)null,
-                                                                                  ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                                                                  ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
     if (problemDescriptor instanceof ProblemDescriptorImpl && component != null) {
       FormElementNavigatable navigatable = new FormElementNavigatable(myFile.getProject(), myFile.getVirtualFile(),
                                                                       component.getId());
index 94e6ca3f2194f292470dedded0b3974f9da7cd2b..4b2d51168a0c1e222c8a1d20513a2f52cde0162f 100644 (file)
  */
 package org.intellij.lang.xpath.validation.inspections;
 
-import org.intellij.lang.xpath.context.ContextProvider;
-import org.intellij.lang.xpath.context.NamespaceContext;
-import org.intellij.lang.xpath.psi.PrefixedName;
-import org.intellij.lang.xpath.psi.XPathNodeTest;
-
 import com.intellij.codeInspection.InspectionManager;
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemHighlightType;
 import com.intellij.psi.xml.XmlElement;
+import org.intellij.lang.xpath.context.ContextProvider;
+import org.intellij.lang.xpath.context.NamespaceContext;
+import org.intellij.lang.xpath.psi.PrefixedName;
+import org.intellij.lang.xpath.psi.XPathNodeTest;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.xml.namespace.QName;
-import java.util.Set;
 import java.text.MessageFormat;
+import java.util.Set;
 
 public class CheckNodeTest extends XPathInspection {
     @NonNls
     private static final String SHORT_NAME = "CheckNodeTest";
 
-    protected Visitor createVisitor(InspectionManager manager) {
-        return new MyVisitor(manager);
+    protected Visitor createVisitor(InspectionManager manager, boolean isOnTheFly) {
+        return new MyVisitor(manager, isOnTheFly);
     }
 
     @NotNull
@@ -56,8 +55,8 @@ public class CheckNodeTest extends XPathInspection {
     }
 
     final static class MyVisitor extends Visitor {
-        MyVisitor(InspectionManager manager) {
-            super(manager);
+        MyVisitor(InspectionManager manager, boolean isOnTheFly) {
+            super(manager, isOnTheFly);
         }
 
         protected void checkNodeTest(XPathNodeTest nodeTest) {
@@ -122,7 +121,7 @@ public class CheckNodeTest extends XPathInspection {
 
             final LocalQuickFix[] fixes = contextProvider.getQuickFixFactory().createUnknownNodeTestFixes(nodeTest);
             addProblem(myManager.createProblemDescriptor(nodeTest, "<html>Unknown " + type + " name " + name + "</html>",
-                    fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                    fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly));
         }
 
         private static boolean matches(@Nullable PrefixedName prefixedName, QName element, NamespaceContext namespaceContext, XmlElement context) {
index aee3f3bf6ad1e18a40e878e3b81838f5f17ee99a..733d1f8feb3b5e1d847868ddf455cc18d9cd83fd 100644 (file)
  */
 package org.intellij.lang.xpath.validation.inspections;
 
-import org.intellij.lang.xpath.psi.XPathExpression;
-import org.intellij.lang.xpath.psi.XPathBinaryExpression;
-import org.intellij.lang.xpath.psi.XPathFunctionCall;
-import org.intellij.lang.xpath.psi.XPathString;
-import org.intellij.lang.xpath.XPathTokenTypes;
-
 import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.ProblemHighlightType;
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.ProblemHighlightType;
+import org.intellij.lang.xpath.XPathTokenTypes;
+import org.intellij.lang.xpath.psi.XPathBinaryExpression;
+import org.intellij.lang.xpath.psi.XPathExpression;
+import org.intellij.lang.xpath.psi.XPathFunctionCall;
+import org.intellij.lang.xpath.psi.XPathString;
 import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
 
 public class HardwiredNamespacePrefix extends XPathInspection {
     public boolean isEnabledByDefault() {
         return true;
     }
 
-    protected Visitor createVisitor(final InspectionManager manager) {
-        return new Visitor(manager) {
+    protected Visitor createVisitor(final InspectionManager manager, final boolean isOnTheFly) {
+        return new Visitor(manager, isOnTheFly) {
             protected void checkExpression(XPathExpression expression) {
                 if (!(expression instanceof XPathBinaryExpression)) {
                     return;
@@ -48,12 +47,12 @@ public class HardwiredNamespacePrefix extends XPathInspection {
                     if (isNameComparison(lop, rop)) {
                         assert rop != null;
                         final ProblemDescriptor p = manager.createProblemDescriptor(rop, "Hardwired namespace prefix", LocalQuickFix.EMPTY_ARRAY,
-                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
                         addProblem(p);
                     } else if (isNameComparison(rop, lop)) {
                         assert lop != null;
                         final ProblemDescriptor p = manager.createProblemDescriptor(lop, "Hardwired namespace prefix", LocalQuickFix.EMPTY_ARRAY,
-                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
                         addProblem(p);
                     } else if (isNameFunctionCall(lop)) {
                         // TODO
@@ -93,4 +92,4 @@ public class HardwiredNamespacePrefix extends XPathInspection {
     public String getShortName() {
         return "HardwiredNamespacePrefix";
     }
-}
\ No newline at end of file
+}
index 6ab1f1785dc7db683e9161b14d536a0f4b1278ab..3a513a26859b6d01b4c7e0c5cf6df0ea7521c690 100644 (file)
  */
 package org.intellij.lang.xpath.validation.inspections;
 
-import org.intellij.lang.xpath.context.ContextProvider;
-import org.intellij.lang.xpath.psi.XPathExpression;
-import org.intellij.lang.xpath.psi.XPathType;
-import org.intellij.lang.xpath.psi.XPathFunctionCall;
-import org.intellij.lang.xpath.validation.ExpectedTypeUtil;
-import org.intellij.lang.xpath.validation.inspections.quickfix.XPathQuickFixFactory;
-
 import com.intellij.codeInspection.InspectionManager;
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemHighlightType;
 import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.util.Alarm;
+import org.intellij.lang.xpath.context.ContextProvider;
+import org.intellij.lang.xpath.psi.XPathExpression;
+import org.intellij.lang.xpath.psi.XPathFunctionCall;
+import org.intellij.lang.xpath.psi.XPathType;
+import org.intellij.lang.xpath.validation.ExpectedTypeUtil;
+import org.intellij.lang.xpath.validation.inspections.quickfix.XPathQuickFixFactory;
+import org.jdom.Element;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import org.jdom.Element;
-
 import javax.swing.*;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
@@ -83,8 +81,8 @@ public class ImplicitTypeConversion extends XPathInspection {
         return true;
     }
 
-    protected Visitor createVisitor(InspectionManager manager) {
-        return new MyElementVisitor(manager);
+    protected Visitor createVisitor(InspectionManager manager, boolean isOnTheFly) {
+        return new MyElementVisitor(manager, isOnTheFly);
     }
 
     @Nullable
@@ -107,8 +105,8 @@ public class ImplicitTypeConversion extends XPathInspection {
     }
 
     final class MyElementVisitor extends Visitor {
-        MyElementVisitor(InspectionManager manager) {
-            super(manager);
+        MyElementVisitor(InspectionManager manager, boolean isOnTheFly) {
+            super(manager, isOnTheFly);
         }
 
         protected void checkExpression(@NotNull XPathExpression expression) {
@@ -146,7 +144,7 @@ public class ImplicitTypeConversion extends XPathInspection {
 
                 addProblem(myManager.createProblemDescriptor(expression,
                         "Expression should be of type '" + type.getName() + "'", fixes,
-                        ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                        ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly));
             }
         }
 
index 5a46a5537837581b8cd502f1ebb14741a22f3dff..e0570ab271a1d351b4d4630549c5235bda626ec7 100644 (file)
  */
 package org.intellij.lang.xpath.validation.inspections;
 
-import org.intellij.lang.xpath.psi.*;
-import org.intellij.lang.xpath.validation.ExpectedTypeUtil;
-import org.intellij.lang.xpath.XPathTokenTypes;
-
 import com.intellij.codeInspection.InspectionManager;
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemHighlightType;
+import org.intellij.lang.xpath.XPathTokenTypes;
+import org.intellij.lang.xpath.psi.*;
+import org.intellij.lang.xpath.validation.ExpectedTypeUtil;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
 public class IndexZeroPredicate extends XPathInspection {
-    protected Visitor createVisitor(InspectionManager manager) {
-        return new MyVisitor(manager);
+    protected Visitor createVisitor(InspectionManager manager, boolean isOnTheFly) {
+        return new MyVisitor(manager, isOnTheFly);
     }
 
     @NotNull
@@ -46,8 +45,8 @@ public class IndexZeroPredicate extends XPathInspection {
     }
 
     final static class MyVisitor extends Visitor {
-        MyVisitor(InspectionManager manager) {
-            super(manager);
+        MyVisitor(InspectionManager manager, boolean isOnTheFly) {
+            super(manager, isOnTheFly);
         }
 
         protected void checkPredicate(XPathPredicate predicate) {
@@ -57,7 +56,7 @@ public class IndexZeroPredicate extends XPathInspection {
                     if (isZero(expr)) {
                         addProblem(myManager.createProblemDescriptor(expr,
                                 "Use of 0 as predicate index", (LocalQuickFix)null,
-                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly));
                     }
                 } else if (expr instanceof XPathBinaryExpression && expr.getType() == XPathType.BOOLEAN) {
                     final XPathBinaryExpression expression = (XPathBinaryExpression)expr;
@@ -74,7 +73,7 @@ public class IndexZeroPredicate extends XPathInspection {
                         if (isPosition(rOp)) {
                             addProblem(myManager.createProblemDescriptor(expr,
                                     "Comparing position() to 0", (LocalQuickFix)null,
-                                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly));
                         }
                     } else if (isZero(rOp)) {
                         assert rOp != null;
@@ -82,7 +81,7 @@ public class IndexZeroPredicate extends XPathInspection {
                         if (isPosition(lOp)) {
                             addProblem(myManager.createProblemDescriptor(expr,
                                     "Comparing position() to 0", (LocalQuickFix)null,
-                                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly));
                         }
                     }
                 }
index 7b71e25452ac655b346714d4fcce1ed21b5b6ca7..2fc31056e767c1a5a9f6bc9e11c58bbd8ea434aa 100644 (file)
  */
 package org.intellij.lang.xpath.validation.inspections;
 
+import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.ProblemHighlightType;
 import org.intellij.lang.xpath.context.ContextProvider;
 import org.intellij.lang.xpath.psi.XPathExpression;
 import org.intellij.lang.xpath.psi.XPathFunctionCall;
 import org.intellij.lang.xpath.psi.XPathType;
 import org.intellij.lang.xpath.validation.ExpectedTypeUtil;
 import org.intellij.lang.xpath.validation.inspections.quickfix.XPathQuickFixFactory;
-
-import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemHighlightType;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -52,8 +51,8 @@ public class RedundantTypeConversion extends XPathInspection {
         return true;
     }
 
-    protected Visitor createVisitor(InspectionManager manager) {
-        return new MyElementVisitor(manager);
+    protected Visitor createVisitor(InspectionManager manager, boolean isOnTheFly) {
+        return new MyElementVisitor(manager, isOnTheFly);
     }
 
     @Nullable
@@ -63,8 +62,8 @@ public class RedundantTypeConversion extends XPathInspection {
 
     final class MyElementVisitor extends Visitor {
 
-        MyElementVisitor(InspectionManager manager) {
-            super(manager);
+        MyElementVisitor(InspectionManager manager, boolean isOnTheFly) {
+            super(manager, isOnTheFly);
         }
 
         protected void checkExpression(final @NotNull XPathExpression expr) {
@@ -79,7 +78,7 @@ public class RedundantTypeConversion extends XPathInspection {
 
                     addProblem(myManager.createProblemDescriptor(expression,
                             "Redundant conversion to type '" + convertedType.getName() + "'", fixes,
-                            ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                            ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly));
                 } else if (CHECK_ANY) {
                     final XPathType expectedType = ExpectedTypeUtil.getExpectedType(expression);
                     if (expectedType == XPathType.ANY) {
@@ -88,7 +87,7 @@ public class RedundantTypeConversion extends XPathInspection {
 
                         addProblem(myManager.createProblemDescriptor(expression,
                                 "Redundant conversion to type '" + expectedType.getName() + "'", fixes,
-                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly));
                     }
                 }
             }
index fc6102f67c07a4f766e6c445db0aa984dbf8fd1b..c9da2780a58e4adec2daf05b34c31f2557009bd3 100644 (file)
  */
 package org.intellij.lang.xpath.validation.inspections;
 
-import com.intellij.codeInspection.CustomSuppressableInspectionTool;
-import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.LocalInspectionTool;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.codeInspection.SuppressIntentionAction;
+import com.intellij.codeInspection.*;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiRecursiveElementVisitor;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.SmartList;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
 import org.intellij.lang.xpath.XPathFileType;
 import org.intellij.lang.xpath.context.ContextProvider;
 import org.intellij.lang.xpath.psi.XPathElement;
 import org.intellij.lang.xpath.psi.XPathExpression;
 import org.intellij.lang.xpath.psi.XPathNodeTest;
 import org.intellij.lang.xpath.psi.XPathPredicate;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 public abstract class XPathInspection extends LocalInspectionTool implements CustomSuppressableInspectionTool {
 
@@ -57,12 +52,12 @@ public abstract class XPathInspection extends LocalInspectionTool implements Cus
         return ContextProvider.getContextProvider(element.getContainingFile()).getQuickFixFactory().isSuppressedFor(element, this);
     }
 
-    protected abstract Visitor createVisitor(InspectionManager manager);
+    protected abstract Visitor createVisitor(InspectionManager manager, boolean isOnTheFly);
 
     @Nullable
     public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
         if (file.getLanguage() != XPathFileType.XPATH.getLanguage()) return null;
-        final Visitor visitor = createVisitor(manager);
+        final Visitor visitor = createVisitor(manager, isOnTheFly);
 
         file.accept(visitor);
 
@@ -71,10 +66,12 @@ public abstract class XPathInspection extends LocalInspectionTool implements Cus
 
     protected static abstract class Visitor extends PsiRecursiveElementVisitor {
         protected final InspectionManager myManager;
-        private SmartList<ProblemDescriptor> myProblems;
+      protected boolean myOnTheFly;
+      private SmartList<ProblemDescriptor> myProblems;
 
-        public Visitor(InspectionManager manager) {
+      public Visitor(InspectionManager manager, boolean isOnTheFly) {
             myManager = manager;
+          this.myOnTheFly = isOnTheFly;
         }
 
         public void visitElement(PsiElement psiElement) {
index 55a1538257942bd279612e692dfe920e3ca94763..5532b0b6e44a7a9a07814a85472ccfcaf3e0068b 100644 (file)
@@ -99,7 +99,7 @@ public class ComparingReferencesInspection extends BaseJavaLocalInspectionTool {
             if (problemList[0] == null) problemList[0] = new ArrayList();
             problemList[0].add(manager.createProblemDescriptor(expression, DESCRIPTION_TEMPLATE,
                                                                myQuickFix,
-                                                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
+                                                               ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly));
           }
         }
       }
index 649524ceeb750aaee833493f13efae82efac838d..21fe65029decfe3b7483d536e1ae11e8052c0e7e 100644 (file)
@@ -20,16 +20,16 @@ import com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl;
 import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.lang.annotation.Annotation;
 import com.intellij.lang.annotation.HighlightSeverity;
 import com.intellij.openapi.editor.colors.CodeInsightColors;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiElement;
 import com.intellij.util.Function;
 import org.jetbrains.annotations.Nullable;
@@ -55,7 +55,7 @@ public class DomElementsHighlightingUtil {
     return createProblemDescriptors(problemDescriptor, new Function<Pair<TextRange, PsiElement>, ProblemDescriptor>() {
       public ProblemDescriptor fun(final Pair<TextRange, PsiElement> s) {
         return manager
-          .createProblemDescriptor(s.second, s.first, problemDescriptor.getDescriptionTemplate(), type, problemDescriptor.getFixes());
+          .createProblemDescriptor(s.second, s.first, problemDescriptor.getDescriptionTemplate(), type, true, problemDescriptor.getFixes());
       }
     });
   }