diff options
Diffstat (limited to 'platform/analysis-api/src/com')
5 files changed, 43 insertions, 18 deletions
diff --git a/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java b/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java index 893a7f3d30da..f7c4ca1bf274 100644 --- a/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java +++ b/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -80,8 +80,8 @@ public class AnalysisScope { private boolean mySearchInLibraries = false; @Type protected int myType; - private Set<VirtualFile> myVFiles; - protected Set<VirtualFile> myFilesSet; + private final Set<VirtualFile> myVFiles; // initial files and directories the scope is configured on + protected Set<VirtualFile> myFilesSet; // set of files (not directories) this scope consists of. calculated in initFilesSet() protected boolean myIncludeTestSource = true; @@ -92,6 +92,7 @@ public class AnalysisScope { myModule = null; myScope = null; myType = PROJECT; + myVFiles = null; } public AnalysisScope(@NotNull Module module) { @@ -101,6 +102,7 @@ public class AnalysisScope { myScope = null; myModule = module; myType = MODULE; + myVFiles = null; } public AnalysisScope(@NotNull Module[] modules) { @@ -110,6 +112,7 @@ public class AnalysisScope { myElement = null; myScope = null; myType = MODULES; + myVFiles = null; } public AnalysisScope(@NotNull PsiDirectory psiDirectory) { @@ -119,6 +122,7 @@ public class AnalysisScope { myScope = null; myElement = psiDirectory; myType = DIRECTORY; + myVFiles = null; } public AnalysisScope(@NotNull PsiFile psiFile) { @@ -128,6 +132,7 @@ public class AnalysisScope { myModules = null; myScope = null; myType = FILE; + myVFiles = null; } public AnalysisScope(@NotNull SearchScope scope, @NotNull Project project) { @@ -138,6 +143,7 @@ public class AnalysisScope { myScope = scope; myType = CUSTOM; mySearchInLibraries = scope instanceof GlobalSearchScope && ((GlobalSearchScope)scope).isSearchInLibraries(); + myVFiles = null; } public AnalysisScope(@NotNull Project project, @NotNull Collection<VirtualFile> virtualFiles) { @@ -212,10 +218,11 @@ public class AnalysisScope { } public boolean contains(@NotNull PsiElement psiElement) { - return contains(psiElement.getContainingFile().getVirtualFile()); + VirtualFile file = psiElement.getContainingFile().getVirtualFile(); + return file != null && contains(file); } - public boolean contains(VirtualFile file) { + public boolean contains(@NotNull VirtualFile file) { if (myFilesSet == null) { if (myType == CUSTOM) { // optimization @@ -289,6 +296,7 @@ public class AnalysisScope { @Override public Boolean compute() { if (!myIncludeTestSource && projectFileIndex.isInTestSourceContent(fileOrDir)) return false; + if (isInGeneratedSources(fileOrDir, myProject)) return false; return ((GlobalSearchScope)myScope).contains(fileOrDir); } }).booleanValue(); @@ -424,7 +432,7 @@ public class AnalysisScope { return indicator == null || !indicator.isCanceled(); } - protected static boolean shouldHighlightFile(PsiFile file) { + protected static boolean shouldHighlightFile(@NotNull PsiFile file) { return ProblemHighlightFilter.shouldProcessFileInBatch(file); } @@ -451,11 +459,14 @@ public class AnalysisScope { final Project project = dir.getProject(); final PsiManager psiManager = PsiManager.getInstance(project); final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); + //we should analyze generated source files only if the action is explicitly invoked for a directory located under generated roots + final boolean processGeneratedFiles = isInGeneratedSources(dir.getVirtualFile(), project); VfsUtilCore.iterateChildrenRecursively(dir.getVirtualFile(), VirtualFileFilter.ALL, new ContentIterator() { @Override @SuppressWarnings({"SimplifiableIfStatement"}) public boolean processFile(@NotNull final VirtualFile fileOrDir) { if (!myIncludeTestSource && index.isInTestSourceContent(fileOrDir)) return true; + if (!processGeneratedFiles && isInGeneratedSources(fileOrDir, project)) return true; if (!fileOrDir.isDirectory()) { return AnalysisScope.processFile(fileOrDir, visitor, psiManager, needReadAction); } @@ -481,6 +492,7 @@ public class AnalysisScope { return myType; } + @NotNull public String getDisplayName() { switch (myType) { case CUSTOM: @@ -515,12 +527,14 @@ public class AnalysisScope { return ""; } + @NotNull private static String getPresentableUrl(@NotNull final PsiFileSystemItem element) { final VirtualFile virtualFile = element.getVirtualFile(); assert virtualFile != null : element; return virtualFile.getPresentableUrl(); } + @NotNull public String getShortenName(){ switch (myType) { case CUSTOM: @@ -589,9 +603,7 @@ public class AnalysisScope { } public void invalidate(){ - if (myType != VIRTUAL_FILES) { - myFilesSet = null; - } else { + if (myType == VIRTUAL_FILES) { for (Iterator<VirtualFile> i = myVFiles.iterator(); i.hasNext();) { final VirtualFile virtualFile = i.next(); if (virtualFile == null || !virtualFile.isValid()) { @@ -599,6 +611,9 @@ public class AnalysisScope { } } } + else { + myFilesSet = null; + } } public boolean containsSources(boolean isTest) { diff --git a/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionManager.java b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionManager.java index aeb671df1e84..8aea24650b22 100644 --- a/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionManager.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionManager.java @@ -17,6 +17,7 @@ package com.intellij.codeInsight.intention; import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.project.Project; @@ -24,6 +25,7 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.UserDataHolder; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -126,6 +128,12 @@ public abstract class IntentionManager { public abstract List<IntentionAction> getStandardIntentionOptions(@NotNull HighlightDisplayKey displayKey, @NotNull PsiElement context); /** + * @return "Fix all '' inspections problems for a file" intention if toolWrapper is local inspection or simple global one + */ + @Nullable + public abstract IntentionAction createFixAllIntention(InspectionToolWrapper toolWrapper, IntentionAction action); + + /** * Wraps given action in a LocalQuickFix object. * @param action action to convert. * @return quick fix instance. diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java index 43d80faad886..450b4c2a4418 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java @@ -71,7 +71,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{ public boolean isSuppressedFor(@NotNull PsiElement element) { Set<InspectionSuppressor> suppressors = getSuppressors(element); for (InspectionSuppressor suppressor : suppressors) { - if (suppressor != null && isSuppressed(suppressor, element)) { + if (isSuppressed(suppressor, element)) { return true; } } @@ -99,10 +99,8 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{ }); Set<InspectionSuppressor> suppressors = getSuppressors(element); for (InspectionSuppressor suppressor : suppressors) { - if (suppressor != null) { - SuppressQuickFix[] actions = suppressor.getSuppressActions(element, getShortName()); - fixes.addAll(Arrays.asList(actions)); - } + SuppressQuickFix[] actions = suppressor.getSuppressActions(element, getShortName()); + fixes.addAll(Arrays.asList(actions)); } return fixes.toArray(new SuppressQuickFix[fixes.size()]); } @@ -121,16 +119,17 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{ public static Set<InspectionSuppressor> getSuppressors(@NotNull PsiElement element) { FileViewProvider viewProvider = element.getContainingFile().getViewProvider(); + final InspectionSuppressor elementLanguageSuppressor = LanguageInspectionSuppressors.INSTANCE.forLanguage(element.getLanguage()); if (viewProvider instanceof TemplateLanguageFileViewProvider) { LinkedHashSet<InspectionSuppressor> suppressors = new LinkedHashSet<InspectionSuppressor>(); ContainerUtil.addIfNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.forLanguage(viewProvider.getBaseLanguage())); for (Language language : viewProvider.getLanguages()) { ContainerUtil.addIfNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.forLanguage(language)); } - ContainerUtil.addIfNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.forLanguage(element.getLanguage())); + ContainerUtil.addIfNotNull(suppressors, elementLanguageSuppressor); return suppressors; } - return Collections.singleton(LanguageInspectionSuppressors.INSTANCE.forLanguage(element.getLanguage())); + return elementLanguageSuppressor != null ? Collections.singleton(elementLanguageSuppressor) : Collections.<InspectionSuppressor>emptySet(); } public void cleanup(Project project) { diff --git a/platform/analysis-api/src/com/intellij/profile/ProfileChangeAdapter.java b/platform/analysis-api/src/com/intellij/profile/ProfileChangeAdapter.java index 7e77e3de44ac..514c18766d40 100644 --- a/platform/analysis-api/src/com/intellij/profile/ProfileChangeAdapter.java +++ b/platform/analysis-api/src/com/intellij/profile/ProfileChangeAdapter.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull; */ public abstract class ProfileChangeAdapter { public void profileChanged(Profile profile){} - public void profileActivated(@NotNull Profile oldProfile, Profile profile){} + public void profileActivated(Profile oldProfile, Profile profile){} public void profilesInitialized() {} public void profilesShutdown(){} } diff --git a/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java b/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java index 7f01ead5359f..4fed9ea06538 100644 --- a/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java +++ b/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java @@ -79,11 +79,14 @@ public class FilePatternPackageSet extends PatternBasedPackageSet { matchesModule(myModuleGroupPattern, myModulePattern, file, fileIndex); } - private boolean fileMatcher(VirtualFile virtualFile, ProjectFileIndex fileIndex, VirtualFile projectBaseDir){ + private boolean fileMatcher(@NotNull VirtualFile virtualFile, ProjectFileIndex fileIndex, VirtualFile projectBaseDir){ final String relativePath = getRelativePath(virtualFile, fileIndex, true, projectBaseDir); if (relativePath == null) { LOG.error("vFile: " + virtualFile + "; projectBaseDir: " + projectBaseDir + "; content File: "+fileIndex.getContentRootForFile(virtualFile)); } + if (StringUtil.isEmptyOrSpaces(relativePath) && !virtualFile.equals(projectBaseDir)) { + return false; + } return myFilePattern.matcher(relativePath).matches(); } |