do not analyse java files under library sources

This commit is contained in:
anna
2011-07-27 08:25:28 +04:00
parent c5bbd68753
commit 0a591e1db6
2 changed files with 21 additions and 5 deletions
@@ -21,6 +21,7 @@
package com.intellij.analysis;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
@@ -106,6 +107,17 @@ public class JavaAnalysisScope extends AnalysisScope {
super.initFilesSet();
}
@Override
protected boolean shouldHighlightFile(PsiFile file) {
final boolean shouldHighlight = super.shouldHighlightFile(file);
if (!shouldHighlight) return false;
if (file.getFileType() == StdFileTypes.JAVA) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile != null && ProjectRootManager.getInstance(file.getProject()).getFileIndex().isInLibrarySource(virtualFile)) return false;
}
return shouldHighlight;
}
protected void accept(final PsiElementVisitor visitor, final boolean needReadAction) {
if (myElement instanceof PsiPackage) {
final PsiPackage pack = (PsiPackage)myElement;
@@ -184,7 +184,7 @@ public class AnalysisScope {
return;
}
}
if (!ProblemHighlightFilter.shouldHighlightFile(file)) return;
if (!shouldHighlightFile(file)) return;
myFilesSet.add(virtualFile);
if (indicator != null) {
indicator.setText(AnalysisScopeBundle.message("scanning.scope.progress.title"));
@@ -252,7 +252,7 @@ public class AnalysisScope {
return ((GlobalSearchScope)myScope).contains(fileOrDir);
}
}).booleanValue();
return !isInScope || AnalysisScope.processFile(fileOrDir, visitor, psiManager, needReadAction);
return !isInScope || AnalysisScope.this.processFile(fileOrDir, visitor, psiManager, needReadAction);
}
};
projectFileIndex.iterateContent(contentIterator);
@@ -327,7 +327,7 @@ public class AnalysisScope {
return true;
}
private static boolean processFile(final VirtualFile fileOrDir, final PsiElementVisitor visitor, final PsiManager psiManager,
private boolean processFile(final VirtualFile fileOrDir, final PsiElementVisitor visitor, final PsiManager psiManager,
final boolean needReadAction) {
if (!fileOrDir.isValid()) return false;
final PsiFile file = getPsiFileInReadAction(psiManager, fileOrDir);
@@ -335,7 +335,7 @@ public class AnalysisScope {
//skip .class files under src directory
return true;
}
if (!ProblemHighlightFilter.shouldHighlightFile(file)) return true;
if (!shouldHighlightFile(file)) return true;
if (needReadAction) {
PsiDocumentManager.getInstance(psiManager.getProject()).commitAndRunReadAction(new Runnable(){
public void run() {
@@ -350,6 +350,10 @@ public class AnalysisScope {
return indicator == null || !indicator.isCanceled();
}
protected boolean shouldHighlightFile(PsiFile file) {
return ProblemHighlightFilter.shouldHighlightFile(file);
}
private static void doProcessFile(PsiElementVisitor visitor, PsiManager psiManager, PsiFile file) {
file.accept(visitor);
psiManager.dropResolveCaches();
@@ -365,7 +369,7 @@ public class AnalysisScope {
public boolean processFile(final VirtualFile fileOrDir) {
if (!myIncludeTestSource && index.isInTestSourceContent(fileOrDir)) return true;
if (!fileOrDir.isDirectory()) {
return AnalysisScope.processFile(fileOrDir, visitor, psiManager, needReadAction);
return AnalysisScope.this.processFile(fileOrDir, visitor, psiManager, needReadAction);
}
return true;
}