inspections: run inspection by name shows empty result (myView == null always while inspecting)

This commit is contained in:
Dmitry Batkovich
2016-02-24 22:26:10 +03:00
parent 75e518cc56
commit 335843a73a
@@ -390,13 +390,12 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
tool.inspectionStarted(inspectionManager, this, getPresentation(toolWrapper));
}
final boolean headlessEnvironment = ApplicationManager.getApplication().isHeadlessEnvironment();
final Map<String, InspectionToolWrapper> map = getInspectionWrappersMap(localTools);
final BlockingQueue<PsiFile> filesToInspect = new ArrayBlockingQueue<PsiFile>(1000);
final Queue<PsiFile> filesFailedToInspect = new LinkedBlockingQueue<PsiFile>();
// use original progress indicator here since we don't want it to cancel on write action start
Future<?> future = startIterateScopeInBackground(scope, localScopeFiles, headlessEnvironment, filesToInspect, progressIndicator);
Future<?> future = startIterateScopeInBackground(scope, localScopeFiles, filesToInspect, progressIndicator);
Processor<PsiFile> processor = new Processor<PsiFile>() {
@Override
@@ -522,7 +521,6 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
@NotNull
private Future<?> startIterateScopeInBackground(@NotNull final AnalysisScope scope,
@Nullable final Collection<VirtualFile> localScopeFiles,
final boolean headlessEnvironment,
@NotNull final BlockingQueue<PsiFile> outFilesToInspect,
@NotNull final ProgressIndicator progressIndicator) {
return ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@@ -542,7 +540,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
public Document compute() {
if (getProject().isDisposed()) throw new ProcessCanceledException();
PsiFile psi = PsiManager.getInstance(getProject()).findFile(file);
Document document = psi == null ? null : shouldProcess(psi, headlessEnvironment, localScopeFiles);
Document document = psi == null ? null : shouldProcess(psi, localScopeFiles);
if (document != null) {
psiFile[0] = psi;
}
@@ -578,15 +576,11 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
});
}
private Document shouldProcess(@NotNull PsiFile file, boolean headlessEnvironment, @Nullable Collection<VirtualFile> localScopeFiles) {
private Document shouldProcess(@NotNull PsiFile file, @Nullable Collection<VirtualFile> localScopeFiles) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) return null;
if (isBinary(file)) return null; //do not inspect binary files
if (myView == null && !headlessEnvironment) {
throw new ProcessCanceledException();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Running local inspections on " + virtualFile.getPath());
}
@@ -847,7 +841,6 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
@NotNull final Project project,
@Nullable final Runnable postRunnable,
@Nullable final String commandName) {
setCurrentScope(scope);
final int fileCount = scope.getFileCount();
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
final List<LocalInspectionToolWrapper> lTools = new ArrayList<LocalInspectionToolWrapper>();