diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index f63641d9a7f6..ace9d8dac9c7 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -670,26 +670,19 @@ public class CompileDriver { didSomething |= invokeFileProcessingCompilers(compilerManager, context, SourceInstrumentingCompiler.class, FILE_PROCESSING_COMPILER_ADAPTER_FACTORY, forceCompile, true, onlyCheckStatus); + didSomething |= invokeFileProcessingCompilers(compilerManager, context, SourceProcessingCompiler.class, + FILE_PROCESSING_COMPILER_ADAPTER_FACTORY, forceCompile, true, onlyCheckStatus); + + final CompileScope intermediateSources = attachIntermediateOutputDirectories(new CompositeScope(CompileScope.EMPTY_ARRAY) { + @NotNull + public Module[] getAffectedModules() { + return context.getCompileScope().getAffectedModules(); + } + }, SOURCE_PROCESSING_ONLY); + context.addScope(intermediateSources); + didSomething |= translate(context, compilerManager, forceCompile, isRebuild, trackDependencies, onlyCheckStatus); - final boolean sourceProcessed = - invokeFileProcessingCompilers(compilerManager, context, SourceProcessingCompiler.class, FILE_PROCESSING_COMPILER_ADAPTER_FACTORY, - forceCompile, true, onlyCheckStatus); - didSomething |= sourceProcessed; - - if (sourceProcessed) { - final CompileScope intermediateSources = attachIntermediateOutputDirectories(new CompositeScope(CompileScope.EMPTY_ARRAY) { - @NotNull - public Module[] getAffectedModules() { - return context.getCompileScope().getAffectedModules(); - } - }, SOURCE_PROCESSING_ONLY); - context.addScope(intermediateSources); - - // important: override rebuild, forceCompile, and trackDependencies options in order to compile only newly generated stuff - didSomething |= translate(context, compilerManager, false, false, false, onlyCheckStatus); - } - didSomething |= invokeFileProcessingCompilers(compilerManager, context, ClassInstrumentingCompiler.class, FILE_PROCESSING_COMPILER_ADAPTER_FACTORY, isRebuild, false, onlyCheckStatus); diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactModelImpl.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactModelImpl.java index 2617aaf973b0..38f46dbf6ab3 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactModelImpl.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactModelImpl.java @@ -68,8 +68,9 @@ public class ArtifactModelImpl extends ArtifactModelBase implements ModifiableAr @NotNull public ModifiableArtifact addArtifact(@NotNull String name, @NotNull ArtifactType artifactType, CompositePackagingElement rootElement) { - final String outputPath = ArtifactUtil.getDefaultArtifactOutputPath(name, myArtifactManager.getProject()); - final ArtifactImpl artifact = new ArtifactImpl(generateUniqueName(name), artifactType, false, rootElement, outputPath, myDispatcher); + final String uniqueName = generateUniqueName(name); + final String outputPath = ArtifactUtil.getDefaultArtifactOutputPath(uniqueName, myArtifactManager.getProject()); + final ArtifactImpl artifact = new ArtifactImpl(uniqueName, artifactType, false, rootElement, outputPath, myDispatcher); myOriginalArtifacts.add(artifact); myArtifact2ModifiableCopy.put(artifact, artifact); myModifiable2Original.put(artifact, artifact); diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java index cf2b82412988..85006853c97a 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactUtil.java @@ -22,11 +22,11 @@ import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.SourceFolder; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.Trinity; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.deployment.DeploymentUtil; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.artifacts.ArtifactManager; import com.intellij.packaging.artifacts.ArtifactProperties; @@ -289,10 +289,10 @@ public class ArtifactUtil { } public static Collection findArtifactsByFile(@NotNull final VirtualFile file, @NotNull Project project) { - final Collection> pairs = findContainingArtifactsWithOutputPaths(file, project); + final Collection>, String>> items = findContainingArtifactsWithOutputPaths(file, project); final List result = new ArrayList(); - for (Pair pair : pairs) { - result.add(pair.getFirst()); + for (Trinity>, String> item : items) { + result.add(item.getFirst()); } return result; } @@ -305,8 +305,8 @@ public class ArtifactUtil { processPackagingElements(artifact, PackagingElementFactoryImpl.DIRECTORY_COPY_ELEMENT_TYPE, processor, context, processSubstitutions); } - public static Collection> findContainingArtifactsWithOutputPaths(@NotNull final VirtualFile file, @NotNull Project project) { - final List> artifacts = new ArrayList>(); + public static Collection>, String>> findContainingArtifactsWithOutputPaths(@NotNull final VirtualFile file, @NotNull Project project) { + final List>, String>> artifacts = new ArrayList>, String>>(); for (final Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) { processFileOrDirectoryCopyElements(artifact, new PackagingElementProcessor>() { @Override @@ -314,28 +314,14 @@ public class ArtifactUtil { @NotNull FileOrDirectoryCopyPackagingElement element) { final VirtualFile root = element.findFile(); if (root != null && VfsUtil.isAncestor(root, file, false)) { - boolean isInArchive = false; - for (CompositePackagingElement parent : parents) { - if (parent instanceof ArchivePackagingElement) { - isInArchive = true; - break; - } - } - String path; - if (!isInArchive) { - final String relativePath; - if (root.equals(file) && element instanceof FileCopyPackagingElement) { - relativePath = ((FileCopyPackagingElement)element).getOutputFileName(); - } - else { - relativePath = VfsUtil.getRelativePath(file, root, '/'); - } - path = DeploymentUtil.concatPaths(getPathFromRoot(parents, "/"), relativePath); + final String relativePath; + if (root.equals(file) && element instanceof FileCopyPackagingElement) { + relativePath = ((FileCopyPackagingElement)element).getOutputFileName(); } else { - path = null; + relativePath = VfsUtil.getRelativePath(file, root, '/'); } - artifacts.add(Pair.create(artifact, path)); + artifacts.add(Trinity.create(artifact, parents, relativePath)); return false; } return true; diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileAction.java b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileAction.java new file mode 100644 index 000000000000..0f4560abbd29 --- /dev/null +++ b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileAction.java @@ -0,0 +1,101 @@ +/** + * @author cdr + */ +package com.intellij.packaging.impl.ui.actions; + +import com.intellij.CommonBundle; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.compiler.CompilerBundle; +import com.intellij.openapi.compiler.CompilerManager; +import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectFileIndex; +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.wm.WindowManager; +import com.intellij.packaging.artifacts.Artifact; +import com.intellij.packaging.impl.artifacts.ArtifactUtil; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.text.DateFormat; +import java.util.*; + +public class PackageFileAction extends AnAction { + public PackageFileAction() { + super(CompilerBundle.message("action.name.package.file"), CompilerBundle.message("action.description.package.file"), null); + } + + @Override + public void update(AnActionEvent e) { + boolean visible = false; + final Project project = e.getData(PlatformDataKeys.PROJECT); + if (project != null) { + final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY); + if (files != null && files.length > 0) { + visible = true; + e.getPresentation().setText(files.length == 1 ? CompilerBundle.message("action.name.package.file") : CompilerBundle.message("action.name.package.files")); + } + } + + e.getPresentation().setVisible(visible); + } + + private static List getFilesToPackage(@NotNull AnActionEvent e, @NotNull Project project) { + final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY); + if (files == null) return Collections.emptyList(); + + List result = new ArrayList(); + ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); + final CompilerManager compilerManager = CompilerManager.getInstance(project); + for (VirtualFile file : files) { + if (file == null || file.isDirectory() || + fileIndex.isInSourceContent(file) && compilerManager.isCompilableFileType(file.getFileType())) { + return Collections.emptyList(); + } + final Collection artifacts = ArtifactUtil.findArtifactsByFile(file, project); + for (Artifact artifact : artifacts) { + if (!StringUtil.isEmpty(artifact.getOutputPath())) { + result.add(file); + break; + } + } + } + return result; + } + + @Override + public void actionPerformed(AnActionEvent event) { + final Project project = event.getData(PlatformDataKeys.PROJECT); + if (project == null) return; + + FileDocumentManager.getInstance().saveAllDocuments(); + final List files = getFilesToPackage(event, project); + try { + for (VirtualFile file : files) { + PackageFileWorker.packageFile(file, project); + } + setStatusText(project, files.toArray(new VirtualFile[files.size()])); + } + catch (IOException e) { + Messages.showErrorDialog(CompilerBundle.message("message.tect.package.file.io.error", e), CommonBundle.getErrorTitle()); + } + } + + public static void setStatusText(Project project, VirtualFile[] files) { + if (files.length != 0) { + String fileNames = ""; + for (VirtualFile file : files) { + if (fileNames.length() != 0) fileNames += ", "; + fileNames+="'"+file.getName()+"'"; + } + String time = DateFormat.getTimeInstance().format(new Date()); + final String statusText = CompilerBundle.message("status.text.file.has.been.packaged", files.length, fileNames, time); + WindowManager.getInstance().getStatusBar(project).setInfo(statusText); + } + } +} diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java new file mode 100644 index 000000000000..81be7ca024b9 --- /dev/null +++ b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java @@ -0,0 +1,137 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.packaging.impl.ui.actions; + +import com.intellij.openapi.deployment.DeploymentUtil; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Trinity; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.packaging.artifacts.Artifact; +import com.intellij.packaging.elements.ArtifactRootElement; +import com.intellij.packaging.elements.CompositePackagingElement; +import com.intellij.packaging.impl.artifacts.ArtifactUtil; +import com.intellij.packaging.impl.elements.ArchivePackagingElement; +import com.intellij.util.PathUtil; +import com.intellij.util.io.zip.JBZipEntry; +import com.intellij.util.io.zip.JBZipFile; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +/** + * @author nik + */ +public class PackageFileWorker { + private final File myFile; + private final String myRelativeOutputPath; + + private PackageFileWorker(File file, String relativeOutputPath) { + myFile = file; + myRelativeOutputPath = relativeOutputPath; + } + + public static void packageFile(@NotNull VirtualFile file, @NotNull Project project) throws IOException { + final Collection>,String>> items = ArtifactUtil.findContainingArtifactsWithOutputPaths(file, project); + File ioFile = VfsUtil.virtualToIoFile(file); + for (Trinity>, String> item : items) { + final Artifact artifact = item.getFirst(); + final List> parents = item.getSecond(); + final String outputPath = artifact.getOutputPath(); + if (!StringUtil.isEmpty(outputPath)) { + PackageFileWorker worker = new PackageFileWorker(ioFile, item.getThird()); + worker.packageFile(outputPath, parents); + } + } + } + + private void packageFile(String outputPath, List> parents) throws IOException { + List> parentsList = new ArrayList>(parents); + Collections.reverse(parentsList); + if (!parentsList.isEmpty() && parentsList.get(0) instanceof ArtifactRootElement) { + parentsList = parentsList.subList(1, parentsList.size()); + } + copyFile(outputPath, parentsList); + } + + private void copyFile(String outputPath, List> parents) throws IOException { + if (parents.isEmpty()) { + FileUtil.copy(myFile, new File(FileUtil.toSystemDependentName(DeploymentUtil.appendToPath(outputPath, myRelativeOutputPath)))); + return; + } + + final CompositePackagingElement element = parents.get(0); + final String nextOutputPath = outputPath + "/" + element.getName(); + final List> parentsTrail = parents.subList(1, parents.size()); + if (element instanceof ArchivePackagingElement) { + packFile(nextOutputPath, "", parentsTrail); + } + else { + copyFile(nextOutputPath, parentsTrail); + } + } + + private void packFile(String archivePath, String pathInArchive, List> parents) throws IOException { + final File archiveFile = new File(FileUtil.toSystemDependentName(archivePath)); + if (parents.isEmpty()) { + JBZipFile file = getOrCreateZipFile(archiveFile); + try { + final String fullPathInArchive = DeploymentUtil.trimForwardSlashes(DeploymentUtil.appendToPath(pathInArchive, myRelativeOutputPath)); + final JBZipEntry entry = file.getOrCreateEntry(fullPathInArchive); + entry.setData(FileUtil.loadFileBytes(myFile)); + } + finally { + file.close(); + } + return; + } + + final CompositePackagingElement element = parents.get(0); + final String nextPathInArchive = DeploymentUtil.trimForwardSlashes(DeploymentUtil.appendToPath(pathInArchive, element.getName())); + final List> parentsTrail = parents.subList(1, parents.size()); + if (element instanceof ArchivePackagingElement) { + JBZipFile zipFile = getOrCreateZipFile(archiveFile); + try { + final JBZipEntry entry = zipFile.getOrCreateEntry(nextPathInArchive); + final File tempFile = FileUtil.createTempFile("packageFile" + FileUtil.sanitizeFileName(nextPathInArchive), FileUtil.getExtension(PathUtil.getFileName(nextPathInArchive))); + if (entry.getSize() != -1) { + FileUtil.writeToFile(tempFile, entry.getData()); + } + packFile(FileUtil.toSystemIndependentName(tempFile.getAbsolutePath()), "", parentsTrail); + entry.setData(FileUtil.loadFileBytes(tempFile)); + FileUtil.delete(tempFile); + } + finally { + zipFile.close(); + } + } + else { + packFile(archivePath, nextPathInArchive, parentsTrail); + } + } + + private static JBZipFile getOrCreateZipFile(File archiveFile) throws IOException { + FileUtil.createIfDoesntExist(archiveFile); + return new JBZipFile(archiveFile); + } +} diff --git a/java/java-impl/src/com/intellij/codeInspection/LossyEncodingInspection.java b/java/java-impl/src/com/intellij/codeInspection/LossyEncodingInspection.java index 407f2926f68d..9e8514d95b17 100644 --- a/java/java-impl/src/com/intellij/codeInspection/LossyEncodingInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/LossyEncodingInspection.java @@ -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 +} diff --git a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java index f8155df3d035..c4bc71b35a30 100644 --- a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java @@ -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)); } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java b/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java index 641934454211..e1269c8cb59c 100644 --- a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java @@ -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; diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java index 1d350f2a16c6..2e420ba2e7fa 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java @@ -40,11 +40,13 @@ class CatchBodyVisitor extends JavaRecursiveElementWalkingVisitor { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.defaultFileTemplateUsage.CatchBodyVisitor"); Collection myProblemDescriptors; + private boolean myOnTheFly; private final InspectionManager myManager; - public CatchBodyVisitor(InspectionManager manager, Collection descriptors) { + public CatchBodyVisitor(InspectionManager manager, Collection descriptors, boolean onTheFly) { myManager = manager; myProblemDescriptors = descriptors; + myOnTheFly = onTheFly; } @Override public void visitCatchSection(PsiCatchSection section) { @@ -104,7 +106,8 @@ class CatchBodyVisitor extends JavaRecursiveElementWalkingVisitor { } Pair 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); } diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java index 612f8e3ffaed..d1156a131a07 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java @@ -59,10 +59,10 @@ public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionT public ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) { Collection descriptors = new ArrayList(); 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()); + CatchBodyVisitor visitor = new CatchBodyVisitor(manager, new ArrayList(), 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}; } diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java index 0236386a9c19..56c9251fa0c4 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java @@ -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 offsetToProperty = new TIntObjectHashMap(); 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, onTheFly, quickFix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } return null; } diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java index d894108cfcf3..2a99d957e10f 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java @@ -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 problemDescriptors) { + final Collection 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 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); } diff --git a/java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java b/java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java index cd13d258affd..7c2496db3f9d 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java @@ -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,7 @@ 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(), isOnTheFly, new LocalQuickFix[]{new EditDependencyRulesAction(dependencyRule)}, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java index 3053954c5713..f6856f608435 100644 --- a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java @@ -146,7 +146,7 @@ public class EmptyMethodInspection extends GlobalJavaInspectionTool { } }); - final ProblemDescriptor descriptor = manager.createProblemDescriptor(refMethod.getElement().getNavigationElement(), message, + final ProblemDescriptor descriptor = manager.createProblemDescriptor(refMethod.getElement().getNavigationElement(), message, false, fixes.toArray(new LocalQuickFix[fixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); return new ProblemDescriptor[]{descriptor}; diff --git a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocLocalInspection.java b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocLocalInspection.java index b30cc9d57d2e..59fe65ab71fb 100644 --- a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocLocalInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocLocalInspection.java @@ -269,12 +269,14 @@ 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, onTheFly, (LocalQuickFix [])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } - 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 +358,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 +395,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 tagProblems = getTagValuesProblems(psiClass, tags, manager); + ArrayList 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 absentParameters = null; @@ -426,7 +428,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 +440,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", "@param"); - return createDescriptor(nameIdentifier, message, new AddMissingTagFix("param", "<" + psiTypeParameter.getName() + ">"), manager); + return createDescriptor(nameIdentifier, message, new AddMissingTagFix("param", "<" + psiTypeParameter.getName() + ">"), manager, + isOnTheFly); } @Nullable @@ -452,19 +455,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 problems = new ArrayList(2); - ArrayList tagProblems = getTagValuesProblems(psiField, docComment.getTags(), manager); + ArrayList 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 +491,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 +513,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { final ArrayList problems = new ArrayList(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 +554,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 +562,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 +585,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { if (valueElement != null) { problems.add(createDescriptor(valueElement, InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "@param " + valueElement.getText() + ""), - manager)); + manager, isOnTheFly)); } } @@ -597,20 +601,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 tagProblems = getTagValuesProblems(psiMethod, tags, manager); + ArrayList 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 +627,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { if (paramRef.getReference().isReferenceTo(param)) { problems.add(createDescriptor(value, InspectionsBundle.message("inspection.javadoc.method.problem.descriptor", "@param", "" + param.getName() + ""), - manager)); + manager, isOnTheFly)); } } } @@ -633,13 +637,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", "@return"); - 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 +670,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { private static void processThrowsTags(final PsiDocTag[] tags, final Map declaredExceptions, final InspectionManager mananger, - @NotNull final ArrayList problems) { + @NotNull final ArrayList problems, boolean isOnTheFly) { for (PsiDocTag tag : tags) { if ("throws".equals(tag.getName()) || "exception".equals(tag.getName())) { final PsiDocTagValue value = tag.getValueElement(); @@ -683,7 +688,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", "" + tag.getName() + ""), mananger)); + problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "" + tag.getName() + ""), mananger, + isOnTheFly)); } it.remove(); } @@ -696,25 +702,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", "@" + tag + " " + 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", "@" + tag + ""); - 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", "@param", "" + param.getName() + ""); - 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 +816,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { private void checkForPeriodInDoc(PsiDocComment docComment, ArrayList problems, - InspectionManager manager) { + InspectionManager manager, boolean onTheFly) { if (IGNORE_JAVADOC_PERIOD) return; PsiDocTag[] tags = docComment.getTags(); int dotIndex = docComment.getText().indexOf('.'); @@ -830,13 +837,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 getTagValuesProblems(PsiDocCommentOwner context, PsiDocTag[] tags, InspectionManager inspectionManager) { + private ArrayList getTagValuesProblems(PsiDocCommentOwner context, PsiDocTag[] tags, InspectionManager inspectionManager, + boolean isOnTheFly) { final ArrayList problems = new ArrayList(2); nextTag: for (PsiDocTag tag : tags) { @@ -851,9 +858,11 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { } if (tagInfo == null){ - problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.wrong.tag", "" + tagName + ""), new AddUnknownTagToCustoms(tag), inspectionManager)); + problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.wrong.tag", "" + tagName + ""), new AddUnknownTagToCustoms(tag), inspectionManager, + isOnTheFly)); } else { - problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.disallowed.tag", "" + tagName + ""), new AddUnknownTagToCustoms(tag), inspectionManager)); + problems.add(createDescriptor(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.disallowed.tag", "" + tagName + ""), new AddUnknownTagToCustoms(tag), inspectionManager, + isOnTheFly)); } } @@ -870,7 +879,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 +888,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", "" + tag.getName() + ""), null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true)); + problems.add(inspectionManager.createProblemDescriptor(tag, InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "" + tag.getName() + ""), 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 +903,15 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { private void checkInlineTags(final InspectionManager inspectionManager, final ArrayList 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", "" + inlineDocTag.getName() + ""), new AddUnknownTagToCustoms(inlineDocTag), inspectionManager)); + problems.add(createDescriptor(nameElement, InspectionsBundle.message("inspection.javadoc.problem.wrong.tag", "" + inlineDocTag.getName() + ""), new AddUnknownTagToCustoms(inlineDocTag), inspectionManager, + isOnTheFly)); } } final PsiDocTagValue value = inlineDocTag.getValueElement(); @@ -910,7 +922,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 +995,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { private static void checkDuplicateTags(final PsiDocTag[] tags, ArrayList problems, - final InspectionManager manager) { + final InspectionManager manager, boolean isOnTheFly) { Set documentedParamNames = null; Set documentedExceptions = null; Set uniqueTags = null; @@ -998,7 +1011,8 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { documentedParamNames = new HashSet(); } 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 +1034,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 +1047,8 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool { uniqueTags = new HashSet(); } 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()); } diff --git a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java index 2032924f7a07..982910c89a00 100644 --- a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java @@ -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, onTheFly, (LocalQuickFix [])null, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL); } @Nullable @@ -64,12 +65,13 @@ public class JavaDocReferenceInspection extends BaseLocalInspectionTool { if (docComment == null) return null; final Set references = new HashSet(); - docComment.accept(getVisitor(references, docCommentOwner, problems, manager)); + docComment.accept(getVisitor(references, docCommentOwner, problems, manager, isOnTheFly)); for (PsiJavaCodeReferenceElement reference : references) { final List classesToImport = new ImportClassFix(reference).getClassesToImport(); problems.add(manager.createProblemDescriptor(reference, InspectionsBundle.message("inspection.javadoc.problem.cannot.resolve", "" + reference.getText() + ""), - !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 references, final PsiElement context, final ArrayList 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 problems, - InspectionManager inspectionManager) { + public static void visitRefInDocTag(final PsiDocTag tag, final JavadocManager manager, final PsiElement context, ArrayList 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 = "" + value.getContainingFile().getViewProvider().getContents().subSequence(textOffset, value.getTextRange().getEndOffset()) + ""; - 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)); } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java b/java/java-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java index 88582e71e8d5..0ee44048a971 100644 --- a/java/java-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java +++ b/java/java-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java @@ -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 list = checkCodeBlock(method.getBody(), manager); + List 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 allProblems = null; final PsiClassInitializer[] initializers = aClass.getInitializers(); for (PsiClassInitializer initializer : initializers) { - final List problems = checkCodeBlock(initializer.getBody(), manager); + final List problems = checkCodeBlock(initializer.getBody(), manager, isOnTheFly); if (problems != null) { if (allProblems == null) { allProblems = new ArrayList(1); @@ -75,7 +77,7 @@ public class LocalCanBeFinal extends BaseLocalInspectionTool { } @Nullable - private List checkCodeBlock(final PsiCodeBlock body, InspectionManager manager) { + private List 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)); } } diff --git a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java index 1af783871799..d17847b12353 100644 --- a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java +++ b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java @@ -34,7 +34,7 @@ public abstract class GenericsInspectionToolBase extends BaseLocalInspectionTool if (initializers.length == 0) return null; List descriptors = new ArrayList(); 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); } diff --git a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantArrayForVarargsCallInspection.java b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantArrayForVarargsCallInspection.java index 7650b7a4f3ce..18496c684a7e 100644 --- a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantArrayForVarargsCallInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantArrayForVarargsCallInspection.java @@ -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 problems = new ArrayList(); 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); } diff --git a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java index 6d4553327d6b..37df723c47fb 100644 --- a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java @@ -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 problems = new ArrayList(); 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); } } diff --git a/java/java-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java b/java/java-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java index dc74c4662601..ce8d2be492a6 100644 --- a/java/java-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java @@ -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 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", "" + cast.getOperand().getText() + "", "#ref #loc"); - return manager.createProblemDescriptor(cast.getCastType(), message, myQuickFixAction, ProblemHighlightType.LIKE_UNUSED_SYMBOL); + return manager.createProblemDescriptor(cast.getCastType(), message, myQuickFixAction, ProblemHighlightType.LIKE_UNUSED_SYMBOL, onTheFly); } diff --git a/java/java-impl/src/com/intellij/codeInspection/sameParameterValue/SameParameterValueInspection.java b/java/java-impl/src/com/intellij/codeInspection/sameParameterValue/SameParameterValueInspection.java index 2beb28ebe9fa..68ce05a0b3e0 100644 --- a/java/java-impl/src/com/intellij/codeInspection/sameParameterValue/SameParameterValueInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/sameParameterValue/SameParameterValueInspection.java @@ -64,7 +64,7 @@ public class SameParameterValueInspection extends GlobalJavaInspectionTool { problems.add(manager.createProblemDescriptor(refParameter.getElement(), InspectionsBundle.message( "inspection.same.parameter.problem.descriptor", "" + paramName + "", "" + value + ""), new InlineParameterValueFix(paramName, value), - ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); + ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false)); } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/sameReturnValue/SameReturnValueInspection.java b/java/java-impl/src/com/intellij/codeInspection/sameReturnValue/SameReturnValueInspection.java index c62a409107a2..db40b99a0cba 100644 --- a/java/java-impl/src/com/intellij/codeInspection/sameReturnValue/SameReturnValueInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/sameReturnValue/SameReturnValueInspection.java @@ -47,7 +47,7 @@ public class SameReturnValueInspection extends GlobalJavaInspectionTool { message = InspectionsBundle.message("inspection.same.return.value.problem.descriptor2", "" + returnValue + ""); } - 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, false, (LocalQuickFix [])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)}; } } diff --git a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java b/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java index 690b73ce5987..3bf4a4a8f113 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java +++ b/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java @@ -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", "#ref"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL)); + "inspection.redundant.throws.problem.descriptor", "#ref"), 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", "#ref"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL)); + "inspection.redundant.throws.problem.descriptor1", "#ref"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL, + false)); } else { problems.add(manager.createProblemDescriptor(throwsRef, InspectionsBundle.message( - "inspection.redundant.throws.problem.descriptor2", "#ref"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL)); + "inspection.redundant.throws.problem.descriptor2", "#ref"), getFix(processor, throwsClassName), ProblemHighlightType.LIKE_UNUSED_SYMBOL, + false)); } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java b/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java index 435090ee3162..daf3868dd728 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java +++ b/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclaration.java @@ -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 problems = new HashSet(); 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); } } diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java b/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java index bcaa3740a8c9..54be3627bd9a 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java @@ -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()]); diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java b/java/java-impl/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java index 58a4ae1f631f..95c740818a3b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java +++ b/java/java-impl/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java @@ -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)}; } } diff --git a/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java b/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java index 740b41d6b572..2f60d21f4dbc 100644 --- a/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java @@ -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)}; } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java b/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java index a0ed44123afe..04365a22fbf6 100644 --- a/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java @@ -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,7 @@ 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, isOnTheFly, availableFixes.toArray(new LocalQuickFix[availableFixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING)}; } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java index 9312cd73248f..6838e8987693 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java @@ -78,7 +78,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl IElementType elementType = element.getElementType(); if (element.getTreeNext() == null && ElementType.PRIMITIVE_TYPE_BIT_SET.contains(elementType)) { addTypeUseAnnotationsFromModifierList(getParent(), typeAnnos); - PsiAnnotation[] array = typeAnnos.toArray(new PsiAnnotation[typeAnnos.size()]); + PsiAnnotation[] array = toAnnotationsArray(typeAnnos); cachedType = JavaPsiFacade.getInstance(getProject()).getElementFactory().createPrimitiveType(element.getText(), array); assert cachedType != null; @@ -90,7 +90,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl } else if (elementType == JavaElementType.JAVA_CODE_REFERENCE) { addTypeUseAnnotationsFromModifierList(getParent(), typeAnnos); - PsiAnnotation[] array = typeAnnos.toArray(new PsiAnnotation[typeAnnos.size()]); + PsiAnnotation[] array = toAnnotationsArray(typeAnnos); cachedType = new PsiClassReferenceType((PsiJavaCodeReferenceElement)element.getPsi(), null,array); } else if (elementType == JavaTokenType.QUEST) { @@ -118,6 +118,11 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl return cachedType; } + private static PsiAnnotation[] toAnnotationsArray(List typeAnnos) { + final int size = typeAnnos.size(); + return size == 0 ? PsiAnnotation.EMPTY_ARRAY : typeAnnos.toArray(new PsiAnnotation[size]); + } + public static void addTypeUseAnnotationsFromModifierList(PsiElement member, List typeAnnos) { if (!(member instanceof PsiModifierListOwner)) return; PsiModifierList list = ((PsiModifierListOwner)member).getModifierList(); @@ -250,7 +255,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl result.add((PsiAnnotation)element); } - return result== null ? PsiAnnotation.EMPTY_ARRAY : result.toArray(new PsiAnnotation[result.size()]); + return result== null ? PsiAnnotation.EMPTY_ARRAY : toAnnotationsArray(result); } @NotNull @@ -260,7 +265,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl ArrayList list = new ArrayList(Arrays.asList(annotations)); addTypeUseAnnotationsFromModifierList(getParent(), list); - return list.toArray(new PsiAnnotation[list.size()]); + return toAnnotationsArray(list); } public PsiAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/InlineSameParameterValueTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/InlineSameParameterValueTest.java index c2c326d77c72..d2e1ef9aa180 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/InlineSameParameterValueTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/InlineSameParameterValueTest.java @@ -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 +} diff --git a/java/openapi/src/com/intellij/psi/util/PropertyUtil.java b/java/openapi/src/com/intellij/psi/util/PropertyUtil.java index e60bded0ee71..b28d808c2a35 100644 --- a/java/openapi/src/com/intellij/psi/util/PropertyUtil.java +++ b/java/openapi/src/com/intellij/psi/util/PropertyUtil.java @@ -296,7 +296,7 @@ public class PropertyUtil { } public static String suggestGetterName(@NotNull String propertyName, @Nullable PsiType propertyType, @NonNls String existingGetterName) { - @NonNls StringBuffer name = new StringBuffer(StringUtil.capitalize(propertyName)); + @NonNls StringBuffer name = new StringBuffer(StringUtil.capitalizeWithJavaBeanConvention(propertyName)); if (isBoolean(propertyType)) { if (existingGetterName == null || !existingGetterName.startsWith("get")) { name.insert(0, "is"); @@ -319,12 +319,12 @@ public class PropertyUtil { @NonNls public static String[] suggestGetterNames(String propertyName) { - final String str = StringUtil.capitalize(propertyName); + final String str = StringUtil.capitalizeWithJavaBeanConvention(propertyName); return new String[] { "is" + str, "get" + str }; } public static String suggestSetterName(String propertyName) { - @NonNls StringBuffer name = new StringBuffer(StringUtil.capitalize(propertyName)); + @NonNls StringBuffer name = new StringBuffer(StringUtil.capitalizeWithJavaBeanConvention(propertyName)); name.insert(0, "set"); return name.toString(); } diff --git a/platform/lang-api/src/com/intellij/codeInspection/InspectionManager.java b/platform/lang-api/src/com/intellij/codeInspection/InspectionManager.java index 4570459478fa..660371445e6a 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/InspectionManager.java +++ b/platform/lang-api/src/com/intellij/codeInspection/InspectionManager.java @@ -37,35 +37,81 @@ public abstract class InspectionManager { * @param psiElement problem is reported against * @param descriptionTemplate problem message. Use #ref for a link to problem piece of code and #loc 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, + boolean onTheFly, LocalQuickFix[] fixes, ProblemHighlightType highlightType); - @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(); + public abstract ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement, + final TextRange rangeInElement, + @NotNull final String descriptionTemplate, + 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, boolean onTheFly, final LocalQuickFix... fixes); + + public abstract ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement, + @NotNull final String descriptionTemplate, + final boolean showTooltip, + final ProblemHighlightType highlightType, boolean onTheFly, final LocalQuickFix... fixes); + + + @Deprecated + /** + * Factory method for ProblemDescriptor. Should be called from LocalInspectionTool.checkXXX() methods. + * @param psiElement problem is reported against + * @param descriptionTemplate problem message. Use #ref for a link to problem piece of code and #loc for location in source code. + * @param fix should be null if no fix is provided. + */ + @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate, LocalQuickFix fix, ProblemHighlightType highlightType); + + @Deprecated + @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate, LocalQuickFix[] fixes, ProblemHighlightType highlightType); + + @Deprecated + @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate, LocalQuickFix[] fixes, ProblemHighlightType highlightType, boolean isAfterEndOfLine); + + @Deprecated + @NotNull public abstract ProblemDescriptor createProblemDescriptor(@NotNull PsiElement startElement, + @NotNull PsiElement endElement, + @NotNull String descriptionTemplate, + ProblemHighlightType highlightType, + LocalQuickFix... fixes + ); + + + @Deprecated public abstract ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement, final TextRange rangeInElement, @NotNull final String descriptionTemplate, final ProblemHighlightType highlightType, final LocalQuickFix... fixes); + @Deprecated public abstract ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement, @NotNull final String descriptionTemplate, final ProblemHighlightType highlightType, @Nullable final HintAction hintAction, final LocalQuickFix... fixes); + @Deprecated public abstract ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement, @NotNull final String descriptionTemplate, final boolean showTooltip, diff --git a/platform/lang-api/src/com/intellij/codeInspection/ProblemDescriptor.java b/platform/lang-api/src/com/intellij/codeInspection/ProblemDescriptor.java index 3ddf3b152c11..2eb72817a8d5 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/ProblemDescriptor.java +++ b/platform/lang-api/src/com/intellij/codeInspection/ProblemDescriptor.java @@ -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(); diff --git a/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java b/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java index 4c7a3a80f861..30d46f0e7788 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java +++ b/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java @@ -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 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, myOnTheFly, fixes, highlightType)); } 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; + } } diff --git a/platform/lang-api/src/com/intellij/psi/stubs/DefaultStubBuilder.java b/platform/lang-api/src/com/intellij/psi/stubs/DefaultStubBuilder.java index ac623fd12f78..91bdaffb17dc 100644 --- a/platform/lang-api/src/com/intellij/psi/stubs/DefaultStubBuilder.java +++ b/platform/lang-api/src/com/intellij/psi/stubs/DefaultStubBuilder.java @@ -44,8 +44,7 @@ public class DefaultStubBuilder implements StubBuilder { } } - final PsiElement[] psiElements = elt.getChildren(); - for (PsiElement child : psiElements) { + for (PsiElement child = elt.getFirstChild(); child != null; child = child.getNextSibling()) { buildStubTreeFor(child, stub); } diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java index a02395bd6f1a..3bfdb90d9d4d 100644 --- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java @@ -334,7 +334,9 @@ public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent. } public void resetPanel() { - ensurePanel().reset(); + if (myPanel != null) { + myPanel.reset(); + } } public void reset() { diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleMainPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleMainPanel.java index 4ec9c86a1f64..1b22827a3067 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleMainPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleMainPanel.java @@ -132,7 +132,10 @@ public class CodeStyleMainPanel extends JPanel { } public void reset() { - clearPanels(); + for (NewCodeStyleSettingsPanel panel : mySettingsPanels.values()) { + panel.reset(); + } + onCurrentSchemeChanged(); } @@ -177,7 +180,7 @@ public class CodeStyleMainPanel extends JPanel { } public String getDisplayName() { - return ensureCurrentPanel().getDisplayName(); + return myModel.getSelectedScheme().getName(); } public void disposeUIResources() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index a943ec93fe97..c74efd2d06b1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -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 result, List 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()); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/GlobalInspectionUtil.java b/platform/lang-impl/src/com/intellij/codeInspection/GlobalInspectionUtil.java index 75c129695ced..b5b0a077e8ed 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/GlobalInspectionUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/GlobalInspectionUtil.java @@ -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 diff --git a/platform/lang-impl/src/com/intellij/codeInspection/SyntaxErrorInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/SyntaxErrorInspection.java index 38b18ffb4e22..a39140be981d 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/SyntaxErrorInspection.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/SyntaxErrorInspection.java @@ -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.openapi.extensions.Extensions; -import com.intellij.psi.*; -import com.intellij.codeInsight.highlighting.HighlightErrorFilter; 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 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); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsAction.java index e366aa7145e2..e3cc57b73e00 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsAction.java @@ -41,11 +41,11 @@ import javax.swing.*; public class EditInspectionToolsSettingsAction implements IntentionAction { private final String myShortName; - public EditInspectionToolsSettingsAction(LocalInspectionTool tool) { + public EditInspectionToolsSettingsAction(@NotNull LocalInspectionTool tool) { myShortName = tool.getShortName(); } - public EditInspectionToolsSettingsAction(HighlightDisplayKey key) { + public EditInspectionToolsSettingsAction(@NotNull HighlightDisplayKey key) { myShortName = key.toString(); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java index 07b9960af054..8a1113e73c15 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java @@ -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 { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java index 2999778704f8..8c4c5e0e1c9b 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java @@ -98,58 +98,58 @@ 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, onTheFly, quickFixes, highlightType); } @NotNull public ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, @NotNull String descriptionTemplate, + boolean onTheFly, LocalQuickFix[] fixes, ProblemHighlightType highlightType) { - return createProblemDescriptor(psiElement, descriptionTemplate, fixes, highlightType, false); + 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) { @@ -213,4 +213,73 @@ public class InspectionManagerEx extends InspectionManager { } return false; } + + @Deprecated + @NotNull + public ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, + @NotNull String descriptionTemplate, + LocalQuickFix fix, + ProblemHighlightType highlightType) { + LocalQuickFix[] quickFixes = fix != null ? new LocalQuickFix[]{fix} : null; + return createProblemDescriptor(psiElement, descriptionTemplate, quickFixes, highlightType); + } + + @Deprecated + @NotNull + public ProblemDescriptor createProblemDescriptor(@NotNull PsiElement psiElement, + @NotNull String descriptionTemplate, + LocalQuickFix[] fixes, + ProblemHighlightType highlightType) { + return createProblemDescriptor(psiElement, descriptionTemplate, fixes, highlightType, false); + } + + @Deprecated + @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, true); + } + + @Deprecated + @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, true); + } + + @Deprecated + 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, true); + } + + @Deprecated + public ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement, + @NotNull final String descriptionTemplate, + final ProblemHighlightType highlightType, + @Nullable final HintAction hintAction, + final LocalQuickFix... fixes) { + + return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, null, hintAction, true); + } + + @Deprecated + @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, + true); + } } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java index 675f231ed034..ba6e0964e4cf 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java @@ -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"); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/ProblemDescriptorImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/ProblemDescriptorImpl.java index 5e8475a520da..6a04b2ebb44d 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/ProblemDescriptorImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/ProblemDescriptorImpl.java @@ -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); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java index 5c77b4405346..a7c1b6bf903e 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java @@ -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,10 +108,10 @@ 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, + descriptor = inspectionManager.createProblemDescriptor(psiElement, offlineProblemDescriptor.getDescription(), false, quickFixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } setUserObject(descriptor); @@ -150,4 +150,4 @@ public class OfflineProblemDescriptorNode extends ProblemDescriptionNode { public boolean isValid() { return getDescriptor() != null && super.isValid(); } -} \ No newline at end of file +} diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java index 5c19584f6b3c..24ee0577a4d9 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java @@ -132,7 +132,7 @@ public class ProblemDescriptionNode extends InspectionTreeNode { final TextRange elementRange = psiElement.getTextRange(); if (textRange!=null && elementRange!=null) { textRange = textRange.shiftRight(-elementRange.getStartOffset()); - if(textRange.getStartOffset() < 0 && textRange.getEndOffset()= 0 && textRange.getEndOffset() <= ref.length()) ref = textRange.substring(ref); } } diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyTreeStructure.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyTreeStructure.java index 373fc0a49ddc..f3981e15b81c 100644 --- a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyTreeStructure.java +++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyTreeStructure.java @@ -146,10 +146,11 @@ public abstract class HierarchyTreeStructure extends AbstractTreeStructure { } else if (HierarchyBrowserBaseEx.SCOPE_TEST.equals(scopeType)) { searchScope = GlobalSearchScope.projectTestScope(myProject); - } - final NamedScope namedScope = NamedScopesHolder.getScope(myProject, scopeType); - if (namedScope != null) { - searchScope = GlobalSearchScope.filterScope(myProject, namedScope); + } else { + final NamedScope namedScope = NamedScopesHolder.getScope(myProject, scopeType); + if (namedScope != null) { + searchScope = GlobalSearchScope.filterScope(myProject, namedScope); + } } return searchScope; } diff --git a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java index 149983fdba9a..46f25a7019e1 100644 --- a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java +++ b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java @@ -229,6 +229,7 @@ public class PsiViewerDialog extends DialogWrapper { myGroup.add(new AnAction(popupItem.getText(), popupItem.getText(), popupItem.getIcon()) { public void actionPerformed(AnActionEvent e) { updatePresentation(e.getPresentation()); + updateDialectsCombo(); } }); } @@ -308,7 +309,8 @@ public class PsiViewerDialog extends DialogWrapper { public void actionPerformed(ActionEvent e) { if (myRefs.isFocusOwner()) { focusTree(); - } else if (myTree.isFocusOwner()) { + } + else if (myTree.isFocusOwner()) { focusRefs(); } } diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java index 9809e3699dd3..b53d91f6ecd2 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java @@ -178,7 +178,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe try { try { // disable up-to-date check to avoid locks on attempt to acquire index write lock while holding at the same time the readLock for this index - FileBasedIndex.getInstance().disableUpToDateCheckForCurrentThread(); + FileBasedIndex.disableUpToDateCheckForCurrentThread(); index.getReadLock().lock(); final ValueContainer container = index.getData(key); @@ -257,7 +257,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe } finally { index.getReadLock().unlock(); - FileBasedIndex.getInstance().enableUpToDateCheckForCurrentThread(); + FileBasedIndex.enableUpToDateCheckForCurrentThread(); } } catch (StorageException e) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/classMembers/UsedByMemberDependencyGraph.java b/platform/lang-impl/src/com/intellij/refactoring/classMembers/UsedByMemberDependencyGraph.java index 335c6e67348b..d3663ba8075f 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/classMembers/UsedByMemberDependencyGraph.java +++ b/platform/lang-impl/src/com/intellij/refactoring/classMembers/UsedByMemberDependencyGraph.java @@ -36,7 +36,7 @@ public class UsedByMemberDependencyGraph> myDependenciesToDependent = null; private final MemberDependenciesStorage myMemberDependenciesStorage; - UsedByMemberDependencyGraph(C aClass) { + public UsedByMemberDependencyGraph(C aClass) { myMemberDependenciesStorage = new MemberDependenciesStorage(aClass, null); mySelectedNormal = new HashSet(); mySelectedAbstract = new HashSet(); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java index c0b7224835d6..1cca34d6b080 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java @@ -528,12 +528,12 @@ public class FileBasedIndex implements ApplicationComponent { private static final ThreadLocal myUpToDateCheckState = new ThreadLocal(); - public void disableUpToDateCheckForCurrentThread() { + public static void disableUpToDateCheckForCurrentThread() { final Integer currentValue = myUpToDateCheckState.get(); myUpToDateCheckState.set(currentValue == null? 1 : currentValue.intValue() + 1); } - public void enableUpToDateCheckForCurrentThread() { + public static void enableUpToDateCheckForCurrentThread() { final Integer currentValue = myUpToDateCheckState.get(); if (currentValue != null) { final int newValue = currentValue.intValue() - 1; diff --git a/platform/lang-impl/src/com/intellij/util/indexing/SingleEntryFileBasedIndexExtension.java b/platform/lang-impl/src/com/intellij/util/indexing/SingleEntryFileBasedIndexExtension.java index afbf8d920ffa..9c26f432e819 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/SingleEntryFileBasedIndexExtension.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/SingleEntryFileBasedIndexExtension.java @@ -16,7 +16,7 @@ package com.intellij.util.indexing; -import com.intellij.util.io.EnumeratorIntegerDescriptor; +import com.intellij.util.io.ExternalIntegerKeyDescriptor; import com.intellij.util.io.KeyDescriptor; /** @@ -27,7 +27,7 @@ import com.intellij.util.io.KeyDescriptor; */ public abstract class SingleEntryFileBasedIndexExtension extends FileBasedIndexExtension{ public final KeyDescriptor getKeyDescriptor() { - return new EnumeratorIntegerDescriptor(); + return new ExternalIntegerKeyDescriptor(); } public boolean dependsOnFileContent() { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/HighlighterList.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/HighlighterList.java index a4d0e8bcd8f0..a9b333747c82 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/HighlighterList.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/HighlighterList.java @@ -16,8 +16,9 @@ package com.intellij.openapi.editor.impl; import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.event.DocumentAdapter; import com.intellij.openapi.editor.event.DocumentEvent; +import com.intellij.openapi.editor.event.DocumentListener; +import com.intellij.openapi.editor.ex.PrioritizedDocumentListener; import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.util.containers.SortedList; @@ -54,7 +55,7 @@ public abstract class HighlighterList { }; private boolean myIsDirtied = false; - private final DocumentAdapter myDocumentListener; + private final DocumentListener myDocumentListener; private final Document myDoc; private int myLongestHighlighterLength = 0; @@ -73,7 +74,13 @@ public abstract class HighlighterList { }; public HighlighterList(Document doc) { - myDocumentListener = new DocumentAdapter() { + myDocumentListener = new PrioritizedDocumentListener() { + public int getPriority() { + return 0; // Need to make sure we invalidate all the stuff before someone (like LineStatusTracker) starts to modify highlights. + } + + public void beforeDocumentChange(DocumentEvent event) {} + public void documentChanged(DocumentEvent e) { myIsDirtied = true; mySegmentHighlighters.markDirty(); diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/BackgroundableProcessIndicator.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/BackgroundableProcessIndicator.java index 5ba60105a7ca..8b69f07ed1c3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/BackgroundableProcessIndicator.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/BackgroundableProcessIndicator.java @@ -26,9 +26,7 @@ import com.intellij.openapi.progress.PerformInBackgroundOption; import com.intellij.openapi.progress.Task; import com.intellij.openapi.progress.TaskInfo; import com.intellij.openapi.progress.util.ProgressWindow; -import com.intellij.openapi.project.DumbModeAction; -import com.intellij.openapi.project.DumbService; -import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.*; import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.ex.StatusBarEx; @@ -47,6 +45,7 @@ public class BackgroundableProcessIndicator extends ProgressWindow { private boolean myDisposed; private DumbModeAction myDumbModeAction = DumbModeAction.NOTHING; + private ProjectManagerListener myListener; public BackgroundableProcessIndicator(Task.Backgroundable task) { this(task.getProject(), task, task); @@ -65,8 +64,18 @@ public class BackgroundableProcessIndicator extends ProgressWindow { } } - public BackgroundableProcessIndicator(@Nullable Project project, TaskInfo info, @NotNull PerformInBackgroundOption option) { + public BackgroundableProcessIndicator(@Nullable final Project project, TaskInfo info, @NotNull PerformInBackgroundOption option) { super(info.isCancellable(), true, project, info.getCancelText()); + if (project != null) { + myListener = new ProjectManagerAdapter() { + public void projectClosing(Project closingProject) { + if (project == closingProject && isRunning()) { + cancel(); + } + } + }; + ProjectManager.getInstance().addProjectManagerListener(myListener); + } setOwnerTask(info); setProcessId(info.getProcessId()); myOption = option; @@ -136,6 +145,10 @@ public class BackgroundableProcessIndicator extends ProgressWindow { public void dispose() { super.dispose(); + if (myListener != null) { + ProjectManager.getInstance().removeProjectManagerListener(myListener); + myListener = null; + } myDisposed = true; myInfo = null; myStatusBar = null; diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java index b6b471bde257..e49a5b47e6ff 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java @@ -15,7 +15,6 @@ */ package com.intellij.openapi.progress.impl; -import com.intellij.openapi.Disposable; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; @@ -51,9 +50,10 @@ public class ProgressManagerImpl extends ProgressManager { private static volatile int ourLockedCheckCounter = 0; private final List myFunComponentProviders = new ArrayList(); @NonNls private static final String NAME = "Progress Cancel Checker"; + private static final boolean DISABLED = Comparing.equal(System.getProperty(PROCESS_CANCELED_EXCEPTION), "disabled"); public ProgressManagerImpl(Application application) { - if (!application.isUnitTestMode() && !Comparing.equal(System.getProperty(PROCESS_CANCELED_EXCEPTION), "disabled")) { + if (!application.isUnitTestMode() && !DISABLED) { new Thread(NAME) { public void run() { while (true) { @@ -77,6 +77,9 @@ public class ProgressManagerImpl extends ProgressManager { progress.checkCanceled(); } catch (ProcessCanceledException e) { + if (DISABLED) { + return; + } if (Thread.holdsLock(PsiLock.LOCK)) { ourLockedCheckCounter++; if (ourLockedCheckCounter > 10) { @@ -317,14 +320,7 @@ public class ProgressManagerImpl extends ProgressManager { else { final BackgroundableProcessIndicator indicator = new BackgroundableProcessIndicator(task); final Project project = task.getProject(); - Disposer.register(project != null ? project : ApplicationManager.getApplication(), new Disposable() { - public void dispose() { - if (indicator.isRunning()) { - indicator.cancel(); - Disposer.dispose(indicator); - } - } - }); + Disposer.register(ApplicationManager.getApplication(), indicator); progressIndicator = indicator; } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java index 7ced1f16384f..ca89ef58f9e3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java @@ -365,6 +365,9 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di int arc = 8; + g.setColor(UIManager.getColor("Panel.background")); + g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc); + Color bg = getBackground().darker().darker(); bg = new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), 230); diff --git a/platform/platform-impl/src/com/intellij/ui/SystemNotificationsImpl.java b/platform/platform-impl/src/com/intellij/ui/SystemNotificationsImpl.java index 2c6f965a03b9..16ed34cfde63 100644 --- a/platform/platform-impl/src/com/intellij/ui/SystemNotificationsImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/SystemNotificationsImpl.java @@ -15,6 +15,7 @@ */ package com.intellij.ui; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; @@ -40,7 +41,7 @@ public class SystemNotificationsImpl implements SystemNotifications, PersistentS private boolean myGrowlDisabled = false; public void notify(@NotNull String notificationName, @NotNull String title, @NotNull String text) { - if (!isGrowlEnabled()) return; + if (!isGrowlEnabled() || ApplicationManager.getApplication().isActive()) return; final GrowlNotifications nofications; try { diff --git a/platform/platform-resources/src/idea/DefaultKeymap.xml b/platform/platform-resources/src/idea/DefaultKeymap.xml index 53c807a31c9b..29a81a004436 100644 --- a/platform/platform-resources/src/idea/DefaultKeymap.xml +++ b/platform/platform-resources/src/idea/DefaultKeymap.xml @@ -877,7 +877,7 @@ - + diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index 5a196ff2aa7c..8de7b5992d80 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -610,6 +610,14 @@ public class StringUtil { return toUpperCase(s.charAt(0)) + s.substring(1); } + @NotNull + public static String capitalizeWithJavaBeanConvention(@NotNull String s) { + if (s.length() > 1 && Character.isUpperCase(s.charAt(1))) { + return s; + } + return capitalize(s); + } + public static int stringHashCode(CharSequence chars) { if (chars instanceof String) return chars.hashCode(); if (chars instanceof CharSequenceWithStringHash) return chars.hashCode(); diff --git a/platform/util/src/com/intellij/util/io/ExternalIntegerKeyDescriptor.java b/platform/util/src/com/intellij/util/io/ExternalIntegerKeyDescriptor.java new file mode 100644 index 000000000000..6cca6132e40f --- /dev/null +++ b/platform/util/src/com/intellij/util/io/ExternalIntegerKeyDescriptor.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * @author max + */ +package com.intellij.util.io; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public class ExternalIntegerKeyDescriptor implements KeyDescriptor { + public int getHashCode(final Integer value) { + return value.intValue(); + } + + public boolean isEqual(final Integer val1, final Integer val2) { + return val1.equals(val2); + } + + public void save(final DataOutput out, final Integer value) throws IOException { + DataInputOutputUtil.writeINT(out, value.intValue()); + } + + public Integer read(final DataInput in) throws IOException { + return DataInputOutputUtil.readINT(in); + } +} \ No newline at end of file diff --git a/platform/util/src/com/intellij/util/io/PersistentEnumerator.java b/platform/util/src/com/intellij/util/io/PersistentEnumerator.java index fffb874b0314..bae8d23bf561 100644 --- a/platform/util/src/com/intellij/util/io/PersistentEnumerator.java +++ b/platform/util/src/com/intellij/util/io/PersistentEnumerator.java @@ -401,7 +401,8 @@ public class PersistentEnumerator implements Forceable { myKeyStorage.force(); - DataInputStream keysStream = new DataInputStream(new BufferedInputStream(new FileInputStream(keystreamFile()))); + DataInputStream keysStream = new DataInputStream(new BufferedInputStream(new LimitedInputStream(new FileInputStream(keystreamFile()), + (int)myKeyStorage.length()))); try { try { while (true) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickListPopupAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickListPopupAction.java index d942eb6dd662..3119f90ad3be 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickListPopupAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickListPopupAction.java @@ -90,8 +90,6 @@ public class VcsQuickListPopupAction extends QuickSwitchSchemeAction implements } } - addAction("ActivateChangesToolWindow", group); - // basic operations addSeparator(group, vcs != null ? vcs.getDisplayName() : null); addAction("ChangesView.AddUnversioned", group); @@ -104,17 +102,14 @@ public class VcsQuickListPopupAction extends QuickSwitchSchemeAction implements addAction("Vcs.ShowTabbedFileHistory", group); addAction("Annotate", group); addAction("Compare.SameVersion", group); - addAction("Compare.LastVersion", group); // custom actions addSeparator(group); addActions(actions, group); - addAction("Vcs.UpdateProject", group); // additional stuff addSeparator(group); addAction("MoveToChangeList", group); - addAction("CompareClipboardWithSelection", group); // local history addLocalHistoryActions(group); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictTracker.java index a66046cbb189..f6f729aa3255 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictTracker.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictTracker.java @@ -157,10 +157,11 @@ public class ChangelistConflictTracker { for (FileEditor editor : editors) { EditorNotificationPanel panel = editor.getUserData(KEY); if (add && panel == null) { - panel = new ChangelistConflictNotificationPanel(ChangelistConflictTracker.this, file); - - myFileEditorManager.addTopComponent(editor, panel); - editor.putUserData(KEY, panel); + if (getChangeListManager().getChangeList(file) != null) { + panel = new ChangelistConflictNotificationPanel(ChangelistConflictTracker.this, file); + myFileEditorManager.addTopComponent(editor, panel); + editor.putUserData(KEY, panel); + } } else if (panel != null) { myFileEditorManager.removeTopComponent(editor, panel); editor.putUserData(KEY, null); @@ -273,8 +274,18 @@ public class ChangelistConflictTracker { if (!myOptions.TRACKING_ENABLED) { return false; } - Conflict conflict = myConflicts.get(file.getPath()); - return conflict != null && !conflict.ignored; + String path = file.getPath(); + Conflict conflict = myConflicts.get(path); + if (conflict != null && !conflict.ignored) { + if (isFromActiveChangelist(file)) { + myConflicts.remove(path); + return false; + } + return true; + } + else { + return false; + } } public void ignoreConflict(@NotNull VirtualFile file, boolean ignore) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/LineStatusTrackerManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/LineStatusTrackerManager.java index f183b6b13503..5ce376ef357b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/LineStatusTrackerManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/LineStatusTrackerManager.java @@ -368,7 +368,8 @@ public class LineStatusTrackerManager implements ProjectComponent { private class MyEditorFactoryListener extends EditorFactoryAdapter { public void editorCreated(EditorFactoryEvent event) { - trackAwtThread(); + // note that in case of lazy loading of configurables, this event can happen + // outside of EDT, so the EDT check mustn't be done here Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) return; Document document = editor.getDocument(); diff --git a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java index 6b688bc5eba7..6eb70208d301 100644 --- a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java +++ b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java @@ -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; diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/global/BooleanFieldAlwaysNegatedInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/global/BooleanFieldAlwaysNegatedInspection.java index da4831b3015b..45964c5d9938 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/global/BooleanFieldAlwaysNegatedInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/global/BooleanFieldAlwaysNegatedInspection.java @@ -63,7 +63,7 @@ public class BooleanFieldAlwaysNegatedInspection extends BaseGlobalInspection { return null; } return new ProblemDescriptor[]{manager.createProblemDescriptor(refField.getElement(), InspectionGadgetsBundle.message( - "boolean.field.always.negated.problem.descriptor"), (LocalQuickFix []) null, + "boolean.field.always.negated.problem.descriptor"), false, (LocalQuickFix []) null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)}; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysConstantInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysConstantInspection.java index 83a729a268f7..351e7446501c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysConstantInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysConstantInspection.java @@ -83,8 +83,7 @@ public class MethodReturnAlwaysConstantInspection extends BaseGlobalInspection { } out.add(manager.createProblemDescriptor(identifier, InspectionGadgetsBundle.message( - "method.return.always.constant.problem.descriptor"), - (LocalQuickFix[]) null, + "method.return.always.constant.problem.descriptor"), false, (LocalQuickFix[]) null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); siblingRefMethod.putUserData(ALWAYS_CONSTANT, Boolean.valueOf(true)); @@ -110,4 +109,4 @@ public class MethodReturnAlwaysConstantInspection extends BaseGlobalInspection { final PsiExpression value = returnStatement.getReturnValue(); return value != null && PsiUtil.isConstantExpression(value); } -} \ No newline at end of file +} diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysIgnoredInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysIgnoredInspection.java index 02b3f26efa0d..172f58e4afbb 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysIgnoredInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/global/MethodReturnAlwaysIgnoredInspection.java @@ -74,8 +74,7 @@ public class MethodReturnAlwaysIgnoredInspection extends BaseGlobalInspection { } final ProblemDescriptor descriptor = manager.createProblemDescriptor(method, - InspectionGadgetsBundle.message("method.return.always.ignored.problem.descriptor"), - (LocalQuickFix []) null, + InspectionGadgetsBundle.message("method.return.always.ignored.problem.descriptor"), false, (LocalQuickFix []) null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); if (originalProblemDescriptors == null) { return new ProblemDescriptor[]{descriptor}; diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/ConstantNamingConventionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/ConstantNamingConventionInspection.java index c1109861b09d..22c6707c3253 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/ConstantNamingConventionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/ConstantNamingConventionInspection.java @@ -15,6 +15,7 @@ */ package com.siyeh.ig.naming; +import com.intellij.psi.PsiEnumConstant; import com.intellij.psi.PsiField; import com.intellij.psi.PsiModifier; import com.intellij.psi.PsiType; @@ -104,6 +105,9 @@ public class ConstantNamingConventionInspection extends ConventionInspection { @Override public void visitField(@NotNull PsiField field) { super.visitField(field); + if (field instanceof PsiEnumConstant) { + return; + } if (!field.hasModifierProperty(PsiModifier.STATIC) || !field.hasModifierProperty(PsiModifier.FINAL)) { return; @@ -122,4 +126,4 @@ public class ConstantNamingConventionInspection extends ConventionInspection { registerFieldError(field, name); } } -} \ No newline at end of file +} diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/EnumeratedConstantNamingConventionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/EnumeratedConstantNamingConventionInspection.java index fbf77801f49f..50b54fbeb883 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/EnumeratedConstantNamingConventionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/EnumeratedConstantNamingConventionInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2009 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,20 +28,24 @@ public class EnumeratedConstantNamingConventionInspection private static final int DEFAULT_MIN_LENGTH = 5; private static final int DEFAULT_MAX_LENGTH = 32; + @Override @NotNull public String getDisplayName() { return InspectionGadgetsBundle.message( "enumerated.constant.naming.convention.display.name"); } + @Override protected InspectionGadgetsFix buildFix(Object... infos) { return new RenameFix(); } + @Override protected boolean buildQuickFixesOnlyForOnTheFlyErrors() { return true; } + @Override @NotNull public String buildErrorString(Object... infos) { final String fieldName = (String)infos[0]; @@ -58,18 +62,22 @@ public class EnumeratedConstantNamingConventionInspection getRegex()); } + @Override protected String getDefaultRegex() { return "[A-Z][A-Za-z\\d]*"; } + @Override protected int getDefaultMinLength() { return DEFAULT_MIN_LENGTH; } + @Override protected int getDefaultMaxLength() { return DEFAULT_MAX_LENGTH; } + @Override public BaseInspectionVisitor buildVisitor() { return new NamingConventionsVisitor(); } @@ -88,4 +96,4 @@ public class EnumeratedConstantNamingConventionInspection registerFieldError(constant, name); } } -} \ No newline at end of file +} diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/TypeParameterNamingConventionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/TypeParameterNamingConventionInspection.java index 224d06c5830f..85b1fbbbe681 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/TypeParameterNamingConventionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/TypeParameterNamingConventionInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2009 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public class TypeParameterNamingConventionInspection } protected String getDefaultRegex() { - return "[A-Z\\d]"; + return "[A-Z][A-Za-z\\d]*"; } protected int getDefaultMinLength() { diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java index 1c30e04e0d49..2a384c8dec68 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java @@ -16,6 +16,7 @@ package org.intellij.plugins.intelliLang; +import com.intellij.ide.ui.SplitterProportionsDataImpl; import com.intellij.lang.Language; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.fileChooser.FileChooserDescriptor; @@ -34,7 +35,6 @@ import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.peer.PeerFactory; import com.intellij.ui.*; import com.intellij.ui.table.TableView; import com.intellij.util.Consumer; @@ -574,7 +574,7 @@ public class InjectionsSettingsUI implements Configurable { final FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, myProject); - final SplitterProportionsData splitterData = PeerFactory.getInstance().getUIHelper().createSplitterProportionsData(); + final SplitterProportionsData splitterData = new SplitterProportionsDataImpl(); splitterData.externalizeFromDimensionService("IntelliLang.ImportSettingsKey.SplitterProportions"); final VirtualFile[] files = chooser.choose(null, myProject); diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java index 673e36ab0ee1..f2e78dc7eea8 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/MethodParameterPanel.java @@ -25,14 +25,10 @@ import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Condition; -import com.intellij.peer.PeerFactory; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.PsiFormatUtil; -import com.intellij.ui.BooleanTableCellRenderer; -import com.intellij.ui.ColoredTreeCellRenderer; -import com.intellij.ui.ReferenceEditorWithBrowseButton; -import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.*; import com.intellij.ui.dualView.TreeTableView; import com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns; import com.intellij.ui.treeStructure.treetable.TreeColumnInfo; @@ -121,7 +117,7 @@ public class MethodParameterPanel extends AbstractInjectionPanel() { + new TreeTableSpeedSearch(myParamsTable, new Convertor() { @Nullable public String convert(final TreePath o) { final Object userObject = ((DefaultMutableTreeNode)o.getLastPathComponent()).getUserObject(); diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertIntegerToDecimalIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertIntegerToDecimalIntention.java index af83e0a2bb7e..0eeaa72e08e8 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertIntegerToDecimalIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertIntegerToDecimalIntention.java @@ -23,7 +23,7 @@ import com.siyeh.ipp.psiutils.ExpressionUtils; import org.jetbrains.annotations.NotNull; public class ConvertIntegerToDecimalIntention extends Intention { - + @Override @NotNull public PsiElementPredicate getElementPredicate() { return new ConvertIntegerToDecimalPredicate(); @@ -36,43 +36,39 @@ public class ConvertIntegerToDecimalIntention extends Intention { final boolean negated = ExpressionUtils.isNegated(expression); final Number value = (Number)ExpressionUtils.computeConstantExpression(expression); + if (value == null) { + return; + } final PsiType type = expression.getType(); final String decimalString; - if (PsiType.INT.equals(type)) { - if (negated) { - decimalString = String.valueOf(-value.intValue()); + if (PsiType.INT.equals(type)) { + if (negated) { + decimalString = String.valueOf(-value.intValue()); + } else { + decimalString = String.valueOf(value.intValue()); + } + } else if (PsiType.LONG.equals(type)) { + if (negated) { + decimalString = String.valueOf(-value.longValue()) + 'L'; + } else { + decimalString = String.valueOf(value.longValue()) + 'L'; + } + } else if (PsiType.FLOAT.equals(type)) { + if (negated) { + decimalString = String.valueOf(-value.floatValue()) + 'f'; + } else { + decimalString = String.valueOf(value.floatValue()) + 'f'; + } } - else { - decimalString = String.valueOf(value.intValue()); + else if (PsiType.DOUBLE.equals(type)) { + if (negated) { + decimalString = String.valueOf(-value.doubleValue()); + } else { + decimalString = String.valueOf(value.doubleValue()); + } + } else { + return; } - } - else if (PsiType.LONG.equals(type)) { - if (negated) { - decimalString = String.valueOf(-value.longValue()); - } - else { - decimalString = String.valueOf(value.longValue()); - } - } - else if (PsiType.FLOAT.equals(type)) { - if (negated) { - decimalString = String.valueOf(-value.floatValue()); - } - else { - decimalString = String.valueOf(value.floatValue()); - } - } - else if (PsiType.DOUBLE.equals(type)) { - if (negated) { - decimalString = String.valueOf(-value.doubleValue()); - } - else { - decimalString = String.valueOf(value.doubleValue()); - } - } - else { - return; - } if (negated) { replaceExpression(decimalString, (PsiExpression)expression.getParent()); @@ -80,4 +76,4 @@ public class ConvertIntegerToDecimalIntention extends Intention { replaceExpression(decimalString, expression); } } -} \ No newline at end of file +} diff --git a/plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateImportedTargetsInspection.java b/plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateImportedTargetsInspection.java index 3b0766b2bebd..5349624fae94 100644 --- a/plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateImportedTargetsInspection.java +++ b/plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateImportedTargetsInspection.java @@ -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,7 @@ 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, isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } final int prolemCount = problems.size(); diff --git a/plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateTargetsInspection.java b/plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateTargetsInspection.java index c5024eb79735..62386d4f8774 100644 --- a/plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateTargetsInspection.java +++ b/plugins/ant/src/com/intellij/lang/ant/validation/AntDuplicateTargetsInspection.java @@ -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,9 @@ 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, isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); problems - .add(manager.createProblemDescriptor(t, duplicatedMessage, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); + .add(manager.createProblemDescriptor(t, duplicatedMessage, isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } name2Target.put(name, target); } diff --git a/plugins/ant/src/com/intellij/lang/ant/validation/AntMissingPropertiesFileInspection.java b/plugins/ant/src/com/intellij/lang/ant/validation/AntMissingPropertiesFileInspection.java index fe320d431aed..10f360813664 100644 --- a/plugins/ant/src/com/intellij/lang/ant/validation/AntMissingPropertiesFileInspection.java +++ b/plugins/ant/src/com/intellij/lang/ant/validation/AntMissingPropertiesFileInspection.java @@ -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 problems = new ArrayList(); - checkElement(project, manager, problems); + checkElement(project, manager, problems, isOnTheFly); final int problemCount = problems.size(); if (problemCount > 0) { return problems.toArray(new ProblemDescriptor[problemCount]); @@ -69,20 +69,20 @@ public class AntMissingPropertiesFileInspection extends AntInspection { private static void checkElement(final AntStructuredElement tag, @NotNull InspectionManager manager, - final List problems) { + final List problems, boolean isOnTheFly) { for (final PsiElement element : tag.getChildren()) { if (element instanceof AntProperty) { final AntProperty prop = (AntProperty)element; if (AntFileImpl.PROPERTY.equals(prop.getSourceElement().getName())) { 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, + problems.add(manager.createProblemDescriptor(prop, AntBundle.message("file.doesnt.exist", filename), isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } } else if (element instanceof AntStructuredElement) { - checkElement((AntStructuredElement)element, manager, problems); + checkElement((AntStructuredElement)element, manager, problems, isOnTheFly); } } } diff --git a/plugins/devkit/src/inspections/ComponentNotRegisteredInspection.java b/plugins/devkit/src/inspections/ComponentNotRegisteredInspection.java index 3ab081009878..a9ff3b9ec728 100644 --- a/plugins/devkit/src/inspections/ComponentNotRegisteredInspection.java +++ b/plugins/devkit/src/inspections/ComponentNotRegisteredInspection.java @@ -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 diff --git a/plugins/devkit/src/inspections/DescriptionNotFoundInspection.java b/plugins/devkit/src/inspections/DescriptionNotFoundInspection.java index cdefd284711f..f72017c26dd7 100644 --- a/plugins/devkit/src/inspections/DescriptionNotFoundInspection.java +++ b/plugins/devkit/src/inspections/DescriptionNotFoundInspection.java @@ -77,8 +77,7 @@ public class DescriptionNotFoundInspection extends DevKitInspectionBase{ final PsiElement problem = getProblemElement(aClass, method); final ProblemDescriptor problemDescriptor = manager .createProblemDescriptor(problem == null ? nameIdentifier : problem, - "Inspection does not have a description", - new LocalQuickFix[]{new CreateHtmlDescriptionFix(filename, module)}, + "Inspection does not have a description", isOnTheFly, new LocalQuickFix[]{new CreateHtmlDescriptionFix(filename, module)}, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); return new ProblemDescriptor[]{problemDescriptor}; } diff --git a/plugins/devkit/src/inspections/RegistrationProblemsInspection.java b/plugins/devkit/src/inspections/RegistrationProblemsInspection.java index 07b93eb427e0..c6e79a0493a0 100644 --- a/plugins/devkit/src/inspections/RegistrationProblemsInspection.java +++ b/plugins/devkit/src/inspections/RegistrationProblemsInspection.java @@ -140,8 +140,7 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase { compClass.isInterface() ? DevKitBundle.message("keyword.implement") : DevKitBundle.message("keyword.extend"), - compClass.getQualifiedName()), - ImplementOrExtendFix.createFix(compClass, checkedClass, isOnTheFly), + compClass.getQualifiedName()), isOnTheFly, ImplementOrExtendFix.createFix(compClass, checkedClass, isOnTheFly), ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } @@ -150,12 +149,12 @@ 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"), isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } return problems != null ? problems.toArray(new ProblemDescriptor[problems.size()]) : null; } @@ -197,10 +196,10 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase { private List myList; private final InspectionManager myManager; private final XmlFile myXmlFile; - private final boolean myOnTheFly; private final PsiManager myPsiManager; private final GlobalSearchScope myScope; private final Set myInterfaceClasses = new THashSet(); + private boolean myOnTheFly; public RegistrationChecker(InspectionManager manager, XmlFile xmlFile, boolean onTheFly) { myManager = manager; @@ -214,7 +213,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 +227,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 +247,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 +271,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 +283,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 +318,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 +326,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 +346,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(); - myList.add(myManager.createProblemDescriptor(element, problem, fixes, type)); + myList.add(myManager.createProblemDescriptor(element, problem, onTheFly, fixes, type)); } @Nullable diff --git a/plugins/git4idea/src/git4idea/actions/GitQuickListContentProvider.java b/plugins/git4idea/src/git4idea/actions/GitQuickListContentProvider.java index 4f203d68fd01..be3708f3ecac 100644 --- a/plugins/git4idea/src/git4idea/actions/GitQuickListContentProvider.java +++ b/plugins/git4idea/src/git4idea/actions/GitQuickListContentProvider.java @@ -44,8 +44,6 @@ public class GitQuickListContentProvider implements VcsQuickListContentProvider final ActionManager manager = ActionManager.getInstance(); final List actions = new ArrayList(); - add("ActivateChangesToolWindow", manager, actions); - // Basic actions.add(new Separator(activeVcs.getDisplayName())); add("ChangesView.AddUnversioned", manager, actions); @@ -58,27 +56,15 @@ public class GitQuickListContentProvider implements VcsQuickListContentProvider add("Vcs.ShowTabbedFileHistory", manager, actions); add("Annotate", manager, actions); add("Compare.SameVersion", manager, actions); - add("Compare.LastVersion", manager, actions); // Pull/Push addSeparator(actions); add("Git.Checkout", manager, actions); - add("Git.Pull", manager, actions); - add("Git.Push", manager, actions); add("Git.Push.Active.Branches", manager, actions); - add("Git.Fetch", manager, actions); - add("Vcs.UpdateProject", manager, actions); // misc - addSeparator(actions); add("Git.Stash", manager, actions); add("Git.Unstash", manager, actions); - add("Git.Rebase", manager, actions); - add("Git.Rebase.Continue", manager, actions); - add("Git.Rebase.Abort", manager, actions); - - addSeparator(actions); - add("CompareClipboardWithSelection", manager, actions); return actions; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspection.java index 277a17120c6a..435d7074b7db 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspection.java @@ -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 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 +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java index 8236677b71f3..a21546214a7c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java @@ -16,7 +16,6 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions; import com.intellij.pom.java.LanguageLevel; -import static com.intellij.psi.CommonClassNames.*; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.tree.IElementType; @@ -27,7 +26,6 @@ import gnu.trove.TIntObjectHashMap; import gnu.trove.TObjectIntHashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression; @@ -41,6 +39,9 @@ import org.jetbrains.plugins.groovy.lang.resolve.processors.MethodResolverProces import java.util.Map; +import static com.intellij.psi.CommonClassNames.*; +import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*; + /** * @author ven */ @@ -204,7 +205,7 @@ public class TypesUtil { } } - if (lType.equalsToText(JAVA_LANG_STRING) && isNumericType(rType)) return true; + if (lType.equalsToText(JAVA_LANG_STRING)) return true; rType = boxPrimitiveType(rType, manager, scope); lType = boxPrimitiveType(lType, manager, scope); diff --git a/plugins/groovy/testdata/highlighting/RawArrayStyleAccess.groovy b/plugins/groovy/testdata/highlighting/RawArrayStyleAccess.groovy index 797386c4c9be..9eb27414b7cc 100644 --- a/plugins/groovy/testdata/highlighting/RawArrayStyleAccess.groovy +++ b/plugins/groovy/testdata/highlighting/RawArrayStyleAccess.groovy @@ -5,4 +5,4 @@ class C { C c=new C(); c.a="abc"; -String s=c[0]; \ No newline at end of file +Date s=c[0]; \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/RawArrayStyleAccessToList.groovy b/plugins/groovy/testdata/highlighting/RawArrayStyleAccessToList.groovy index da7660544c5c..a9151fada3ff 100644 --- a/plugins/groovy/testdata/highlighting/RawArrayStyleAccessToList.groovy +++ b/plugins/groovy/testdata/highlighting/RawArrayStyleAccessToList.groovy @@ -1,3 +1,3 @@ List l=new ArrayList(); l.add("abc"); -String s=l[0]; \ No newline at end of file +Date s=l[0]; \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/RawArrayStyleAccessToMap.groovy b/plugins/groovy/testdata/highlighting/RawArrayStyleAccessToMap.groovy index 21886569b119..af0643fee115 100644 --- a/plugins/groovy/testdata/highlighting/RawArrayStyleAccessToMap.groovy +++ b/plugins/groovy/testdata/highlighting/RawArrayStyleAccessToMap.groovy @@ -1,3 +1,3 @@ Map map=new HashMap(); map.add("abc", "abc"); -String s=map["abc"]; \ No newline at end of file +Date s=map["abc"]; \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/RawFieldAccess.groovy b/plugins/groovy/testdata/highlighting/RawFieldAccess.groovy index 5b02d5a0f200..db3489ea2049 100644 --- a/plugins/groovy/testdata/highlighting/RawFieldAccess.groovy +++ b/plugins/groovy/testdata/highlighting/RawFieldAccess.groovy @@ -3,4 +3,4 @@ class X{ } X x=new X(); x.field="abc"; -String s=x.field; \ No newline at end of file +Date s=x.field; \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/RawMethodAccess.groovy b/plugins/groovy/testdata/highlighting/RawMethodAccess.groovy index bfdb1896d80a..0e90b9d140cf 100644 --- a/plugins/groovy/testdata/highlighting/RawMethodAccess.groovy +++ b/plugins/groovy/testdata/highlighting/RawMethodAccess.groovy @@ -1,3 +1,3 @@ List l=new ArrayList(); l.add("abc"); -String s=l.get(0); \ No newline at end of file +Date s=l.get(0); \ No newline at end of file diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java index 2b813f2634e6..370da4b9a527 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java @@ -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 result = new ArrayList(); 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 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 myProblems = new ArrayList(); 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) { @@ -435,8 +437,7 @@ public class I18nInspection extends BaseLocalInspectionTool { final ProblemDescriptor problem = myManager .createProblemDescriptor(expression, - description, - fixes.toArray(new LocalQuickFix[fixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); + description, myOnTheFly, fixes.toArray(new LocalQuickFix[fixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); myProblems.add(problem); } } diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InconsistentResourceBundleInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InconsistentResourceBundleInspection.java index 2c4c8550dafd..0e2a3fb74098 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InconsistentResourceBundleInspection.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InconsistentResourceBundleInspection.java @@ -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); @@ -197,8 +197,7 @@ public class InconsistentResourceBundleInspection extends DescriptorProviderInsp Property property = file.findPropertyByKey(inconsistentKey); assert property != null; String message = InspectionsBundle.message("inconsistent.bundle.property.error", inconsistentKey, parent.getName()); - ProblemDescriptor descriptor = manager.createProblemDescriptor(property, message, - LocalQuickFix.EMPTY_ARRAY, + ProblemDescriptor descriptor = manager.createProblemDescriptor(property, message, false, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); addProblemElement(getRefManager().getReference(file), descriptor); } @@ -234,8 +233,7 @@ public class InconsistentResourceBundleInspection extends DescriptorProviderInsp } assert untranslatedProperty != null; String message = InspectionsBundle.message("inconsistent.bundle.untranslated.property.error", untranslatedKey, file.getName()); - ProblemDescriptor descriptor = manager.createProblemDescriptor(untranslatedProperty, message, - LocalQuickFix.EMPTY_ARRAY, + ProblemDescriptor descriptor = manager.createProblemDescriptor(untranslatedProperty, message, false, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); addProblemElement(getRefManager().getReference(untranslatedFile), descriptor); } diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspection.java index 0fbb62afa508..d4cb8baeafe4 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspection.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspection.java @@ -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 result = new ArrayList(); 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 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 myProblems = new ArrayList(); + 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); } } @@ -195,7 +197,7 @@ public class InvalidPropertyKeyInspection extends BaseJavaLocalInspectionTool { && !hasArrayTypeAt(i+1, methodCall)) { myProblems.add(myManager.createProblemDescriptor(methodCall, CodeInsightBundle.message("property.has.more.parameters.than.passed", key, paramsCount, args.length-i-1), - new LocalQuickFix[0], + onTheFly, new LocalQuickFix[0], ProblemHighlightType.GENERIC_ERROR)); } break; diff --git a/plugins/java-i18n/src/com/intellij/lang/properties/UnusedMessageFormatParameterInspection.java b/plugins/java-i18n/src/com/intellij/lang/properties/UnusedMessageFormatParameterInspection.java index c5217e696a66..b0c3058b106b 100644 --- a/plugins/java-i18n/src/com/intellij/lang/properties/UnusedMessageFormatParameterInspection.java +++ b/plugins/java-i18n/src/com/intellij/lang/properties/UnusedMessageFormatParameterInspection.java @@ -15,24 +15,24 @@ */ 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 @@ -93,8 +93,7 @@ public class UnusedMessageFormatParameterInspection extends BaseLocalInspectionT ASTNode[] nodes = property.getNode().getChildren(null); 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)); + "unused.message.format.parameter.problem.descriptor", integer.toString(), Integer.toString(i)), isOnTheFly, (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); break; } } diff --git a/plugins/properties/src/com/intellij/codeInspection/duplicatePropertyInspection/DuplicatePropertyInspection.java b/plugins/properties/src/com/intellij/codeInspection/duplicatePropertyInspection/DuplicatePropertyInspection.java index b71dad412145..130bf3821dae 100644 --- a/plugins/properties/src/com/intellij/codeInspection/duplicatePropertyInspection/DuplicatePropertyInspection.java +++ b/plugins/properties/src/com/intellij/codeInspection/duplicatePropertyInspection/DuplicatePropertyInspection.java @@ -262,8 +262,7 @@ public class DuplicatePropertyInspection extends DescriptorProviderInspection { } } if (duplicatesCount > 1) { - problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(), - (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); + problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(), false, (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } @@ -304,8 +303,7 @@ 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)); + problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(), false, (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } @@ -342,8 +340,7 @@ public class DuplicatePropertyInspection extends DescriptorProviderInspection { surroundWithHref(message, property.getFirstChild(), false); } } - problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(), - (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); + problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(), false, (LocalQuickFix[])null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } } diff --git a/plugins/properties/src/com/intellij/lang/properties/UnusedPropertyInspection.java b/plugins/properties/src/com/intellij/lang/properties/UnusedPropertyInspection.java index 87047193e5cc..e2b0b02a06a2 100644 --- a/plugins/properties/src/com/intellij/lang/properties/UnusedPropertyInspection.java +++ b/plugins/properties/src/com/intellij/lang/properties/UnusedPropertyInspection.java @@ -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 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); } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java index fe3094d2390b..081366965736 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java @@ -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); } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java index 6f48b221e8c6..f12b64eb5aad 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java @@ -40,10 +40,10 @@ public class TextSplitter { private static final Pattern HTML = Pattern.compile("<(0)>"); @NonNls - /*private static final Pattern WORD = Pattern.compile("\\b\\p{L}+'?\\p{L}*\\b");*/ - private static final Pattern WORD = Pattern.compile("\\b\\p{Alpha}*'?\\p{Alpha}*"); - private static final Pattern EXTENDED_WORD = Pattern.compile("\\b\\p{Alpha}*'?\\p{Alpha}(_*\\p{Alpha})*"); + private static final Pattern WORD = Pattern.compile("\\b\\p{L}*'?\\p{L}*"); + + private static final Pattern EXTENDED_WORD = Pattern.compile("\\b\\p{L}*'?\\p{L}(_*\\p{L})*"); private static final String WORD_SPLITTER = "\\s+|<[^>]+>"; diff --git a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java index 57843e55cf9d..727160248bac 100644 --- a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java +++ b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java @@ -224,6 +224,18 @@ public class SplitterTest extends TestCase { correctListToCheck(checkAreas, text, new String[]{"BADD"}); correctIgnored(checkAreas, text, new String[]{}); } + public void testWordWithUmlauts() { + String text = "rechtsbündig"; + List checkAreas = TextSplitter.splitText(text); + correctListToCheck(checkAreas, text, new String[]{"rechtsbündig"}); + correctIgnored(checkAreas, text, new String[]{}); + } + public void testWordUpperCasedWithUmlauts() { + String text = "rechtsbündig".toUpperCase(); + List checkAreas = TextSplitter.splitText(text); + correctListToCheck(checkAreas, text, new String[]{"rechtsbündig".toUpperCase()}); + correctIgnored(checkAreas, text, new String[]{}); + } @Nullable diff --git a/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnGroupsInspection.java b/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnGroupsInspection.java index 985b3c49729e..e4eb7986a54b 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnGroupsInspection.java +++ b/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnGroupsInspection.java @@ -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 +} diff --git a/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnMethodInspection.java b/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnMethodInspection.java index 56f3f6227f27..be2e622ebc70 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnMethodInspection.java +++ b/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnMethodInspection.java @@ -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 problemDescriptors) { + private static void checkMethodNameDependency(InspectionManager manager, PsiClass psiClass, String methodName, PsiNameValuePair dep, + List 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 +} diff --git a/plugins/testng/src/com/theoryinpractice/testng/inspection/JUnitConvertTool.java b/plugins/testng/src/com/theoryinpractice/testng/inspection/JUnitConvertTool.java index 4e561ceda7e5..d27017aba35f 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/inspection/JUnitConvertTool.java +++ b/plugins/testng/src/com/theoryinpractice/testng/inspection/JUnitConvertTool.java @@ -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; diff --git a/plugins/testng/src/com/theoryinpractice/testng/inspection/UndeclaredTestInspection.java b/plugins/testng/src/com/theoryinpractice/testng/inspection/UndeclaredTestInspection.java index 8df2e132281e..2f3e406806de 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/inspection/UndeclaredTestInspection.java +++ b/plugins/testng/src/com/theoryinpractice/testng/inspection/UndeclaredTestInspection.java @@ -101,7 +101,7 @@ public class UndeclaredTestInspection extends BaseJavaLocalInspectionTool { final PsiIdentifier nameIdentifier = aClass.getNameIdentifier(); LOG.assertTrue(nameIdentifier != null); return new ProblemDescriptor[]{manager.createProblemDescriptor(nameIdentifier, "Undeclared test \'" + aClass.getName() + "\'", - new LocalQuickFix[]{new RegisterClassFix(aClass), + isOnTheFly, new LocalQuickFix[]{new RegisterClassFix(aClass), new CreateTestngFix()}, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)}; } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java index 6c865ba1ed3b..14235ed1200d 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java @@ -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) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormFileErrorCollector.java b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormFileErrorCollector.java index c0a1fd072519..4adf77d8faf3 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormFileErrorCollector.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormFileErrorCollector.java @@ -15,18 +15,21 @@ */ 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 myProblems = new ArrayList(); - 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()); diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/CheckNodeTest.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/CheckNodeTest.java index 94e6ca3f2194..ad1b372e5c3b 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/CheckNodeTest.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/CheckNodeTest.java @@ -15,29 +15,28 @@ */ 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) { @@ -121,8 +120,7 @@ public class CheckNodeTest extends XPathInspection { } final LocalQuickFix[] fixes = contextProvider.getQuickFixFactory().createUnknownNodeTestFixes(nodeTest); - addProblem(myManager.createProblemDescriptor(nodeTest, "Unknown " + type + " name " + name + "", - fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); + addProblem(myManager.createProblemDescriptor(nodeTest, "Unknown " + type + " name " + name + "", myOnTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } private static boolean matches(@Nullable PrefixedName prefixedName, QName element, NamespaceContext namespaceContext, XmlElement context) { diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/HardwiredNamespacePrefix.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/HardwiredNamespacePrefix.java index aee3f3bf6ad1..248d277a2fac 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/HardwiredNamespacePrefix.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/HardwiredNamespacePrefix.java @@ -15,27 +15,26 @@ */ 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; @@ -47,12 +46,14 @@ public class HardwiredNamespacePrefix extends XPathInspection { if (isNameComparison(lop, rop)) { assert rop != null; - final ProblemDescriptor p = manager.createProblemDescriptor(rop, "Hardwired namespace prefix", LocalQuickFix.EMPTY_ARRAY, + final ProblemDescriptor p = manager.createProblemDescriptor(rop, "Hardwired namespace prefix", isOnTheFly, + LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); addProblem(p); } else if (isNameComparison(rop, lop)) { assert lop != null; - final ProblemDescriptor p = manager.createProblemDescriptor(lop, "Hardwired namespace prefix", LocalQuickFix.EMPTY_ARRAY, + final ProblemDescriptor p = manager.createProblemDescriptor(lop, "Hardwired namespace prefix", isOnTheFly, + LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); addProblem(p); } else if (isNameFunctionCall(lop)) { @@ -93,4 +94,4 @@ public class HardwiredNamespacePrefix extends XPathInspection { public String getShortName() { return "HardwiredNamespacePrefix"; } -} \ No newline at end of file +} diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/ImplicitTypeConversion.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/ImplicitTypeConversion.java index 6ab1f1785dc7..efebfc6933af 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/ImplicitTypeConversion.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/ImplicitTypeConversion.java @@ -22,25 +22,23 @@ */ 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) { @@ -145,7 +143,7 @@ public class ImplicitTypeConversion extends XPathInspection { } addProblem(myManager.createProblemDescriptor(expression, - "Expression should be of type '" + type.getName() + "'", fixes, + "Expression should be of type '" + type.getName() + "'", myOnTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/IndexZeroPredicate.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/IndexZeroPredicate.java index 5a46a5537837..e0570ab271a1 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/IndexZeroPredicate.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/IndexZeroPredicate.java @@ -15,19 +15,18 @@ */ 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)); } } } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/RedundantTypeConversion.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/RedundantTypeConversion.java index 7b71e25452ac..16f677673f26 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/RedundantTypeConversion.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/RedundantTypeConversion.java @@ -15,16 +15,15 @@ */ 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) { @@ -78,7 +77,7 @@ public class RedundantTypeConversion extends XPathInspection { LocalQuickFix[] fixes = fixFactory.createRedundantTypeConversionFixes(expression); addProblem(myManager.createProblemDescriptor(expression, - "Redundant conversion to type '" + convertedType.getName() + "'", fixes, + "Redundant conversion to type '" + convertedType.getName() + "'", myOnTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } else if (CHECK_ANY) { final XPathType expectedType = ExpectedTypeUtil.getExpectedType(expression); @@ -87,7 +86,7 @@ public class RedundantTypeConversion extends XPathInspection { LocalQuickFix[] fixes = fixFactory.createRedundantTypeConversionFixes(expression); addProblem(myManager.createProblemDescriptor(expression, - "Redundant conversion to type '" + expectedType.getName() + "'", fixes, + "Redundant conversion to type '" + expectedType.getName() + "'", myOnTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/XPathInspection.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/XPathInspection.java index fc6102f67c07..c9da2780a58e 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/XPathInspection.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/XPathInspection.java @@ -15,26 +15,21 @@ */ 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 myProblems; + protected boolean myOnTheFly; + private SmartList myProblems; - public Visitor(InspectionManager manager) { + public Visitor(InspectionManager manager, boolean isOnTheFly) { myManager = manager; + this.myOnTheFly = isOnTheFly; } public void visitElement(PsiElement psiElement) { diff --git a/resources-en/src/messages/CompilerBundle.properties b/resources-en/src/messages/CompilerBundle.properties index 500cde9b63dc..19586e5d6c48 100644 --- a/resources-en/src/messages/CompilerBundle.properties +++ b/resources-en/src/messages/CompilerBundle.properties @@ -223,6 +223,15 @@ compiler.initial.scanning.progress.text=Looking for sources to recompile dialog.title.output.directory.for.artifact=Output Directory for Artifact chooser.description.select.output.directory.for.0.artifact=Select output directory for ''{0}'' artifact +#package file action +action.name.package.file=Package file +action.description.package.file=Update the file into the corresponding artifacts +message.tect.package.file.io.error=IO Error:\n{0} +command.name.package.file=Package file +status.text.file.has.been.packaged={0, choice, 1#File|2#Files} {1} {0, choice, 1#has|2#have} been packaged at {2}. +action.name.package.files=Package files + + # validation validation.display.name=Validation action.name.exclude.from.validation=Exclude from Validation diff --git a/resources/src/idea/IdeaActions.xml b/resources/src/idea/IdeaActions.xml index bc50a097dcba..443009053fb9 100644 --- a/resources/src/idea/IdeaActions.xml +++ b/resources/src/idea/IdeaActions.xml @@ -371,6 +371,15 @@ + + + + + + + + + diff --git a/samples/comparingReferences/source/com/intellij/codeInspection/ComparingReferencesInspection.java b/samples/comparingReferences/source/com/intellij/codeInspection/ComparingReferencesInspection.java index 55a153825794..5532b0b6e44a 100644 --- a/samples/comparingReferences/source/com/intellij/codeInspection/ComparingReferencesInspection.java +++ b/samples/comparingReferences/source/com/intellij/codeInspection/ComparingReferencesInspection.java @@ -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)); } } } diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsHighlightingUtil.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsHighlightingUtil.java index 649524ceeb75..21fe65029dec 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsHighlightingUtil.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsHighlightingUtil.java @@ -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, ProblemDescriptor>() { public ProblemDescriptor fun(final Pair s) { return manager - .createProblemDescriptor(s.second, s.first, problemDescriptor.getDescriptionTemplate(), type, problemDescriptor.getFixes()); + .createProblemDescriptor(s.second, s.first, problemDescriptor.getDescriptionTemplate(), type, true, problemDescriptor.getFixes()); } }); }