This commit is contained in:
Alexey Kudravtsev
2017-07-27 14:27:04 +03:00
parent 22a5027512
commit e9fc8fc962
@@ -197,14 +197,9 @@ public class AnalysisScope {
@NotNull
private FileIndex getFileIndex() {
final FileIndex fileIndex;
if (myModule != null) {
fileIndex = ModuleRootManager.getInstance(myModule).getFileIndex();
}
else {
fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
}
return fileIndex;
return myModule == null ?
ProjectRootManager.getInstance(myProject).getFileIndex() :
ModuleRootManager.getInstance(myModule).getFileIndex();
}
private static String displayProjectRelativePath(@NotNull PsiFileSystemItem item) {
@@ -359,12 +354,11 @@ public class AnalysisScope {
@NotNull final PsiManager psiManager,
final boolean needReadAction,
final boolean clearResolveCache) {
final Runnable runnable = () -> doProcessFile(visitor, psiManager, vFile, clearResolveCache);
if (needReadAction && !ApplicationManager.getApplication().isDispatchThread()) {
commitAndRunInSmartMode(runnable, psiManager.getProject());
commitAndRunInSmartMode(() -> doProcessFile(visitor, psiManager, vFile, clearResolveCache), psiManager.getProject());
}
else {
runnable.run();
doProcessFile(visitor, psiManager, vFile, clearResolveCache);
}
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
return indicator == null || !indicator.isCanceled();
@@ -404,11 +398,11 @@ public class AnalysisScope {
private static void doProcessFile(@NotNull PsiElementVisitor visitor, @NotNull PsiManager psiManager, @NotNull VirtualFile vFile,
boolean clearResolveCache) {
ProgressManager.checkCanceled();
if (!vFile.isValid()) return;
PsiFile psiFile = psiManager.findFile(vFile);
if (psiFile == null || !shouldHighlightFile(psiFile)) return;
psiFile.accept(visitor);
if (clearResolveCache) {
psiManager.dropResolveCaches();