From b32acd226a9d8fee5679a694a96bc31fc88aa44b Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 16 Feb 2010 14:36:19 +0300 Subject: [PATCH] cleanup --- .../HighlightSuppressedWarningsHandler.java | 2 +- .../daemon/impl/LocalInspectionsPass.java | 4 ++-- .../ex/GlobalInspectionContextImpl.java | 19 +++++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java index 19aa7cc0fd60..c7211eb840e5 100644 --- a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java @@ -117,7 +117,7 @@ public class HighlightSuppressedWarningsHandler extends HighlightUsagesHandlerBa final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false); tool.initialize(context); ((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted(); - pass.doInspectInBatch(managerEx, new InspectionProfileEntry[]{tool}, false); + pass.doInspectInBatch(managerEx, Collections.singletonList(tool), false); for (HighlightInfo info : pass.getInfos()) { final PsiElement element = CollectHighlightsUtil.findCommonParent(myFile, info.startOffset, info.endOffset); if (element != null) { 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 c74efd2d06b1..f789c6ce3407 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 @@ -118,12 +118,12 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass inspect(tools, iManager, true, true); } - public void doInspectInBatch(final InspectionManagerEx iManager, InspectionProfileEntry[] toolWrappers, boolean ignoreSuppressed) { + public void doInspectInBatch(final InspectionManagerEx iManager, List toolWrappers, boolean ignoreSuppressed) { myDescriptors = new ArrayList(); myLevels = new ArrayList(); myTools = new ArrayList(); - Map tool2Wrapper = new THashMap(toolWrappers.length); + Map tool2Wrapper = new THashMap(toolWrappers.size()); for (InspectionProfileEntry toolWrapper : toolWrappers) { tool2Wrapper.put(((LocalInspectionToolWrapper)toolWrapper).getTool(), (LocalInspectionToolWrapper)toolWrapper); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index 3e3dd8df1e65..4e3256258f1a 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -420,7 +420,7 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext { public void run() { LOG.info("Code inspection finished"); - final InspectionResultsView view = new InspectionResultsView(myProject, getCurrentProfile(), + InspectionResultsView view = new InspectionResultsView(myProject, getCurrentProfile(), scope, GlobalInspectionContextImpl.this, new InspectionRVContentProviderImpl(myProject)); if (!view.update() && !getUIOptions().SHOW_ONLY_DIFF) { @@ -469,11 +469,11 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext { } private void runTools(final List needRepeatSearchRequest, final AnalysisScope scope, final InspectionManager manager) { - final List usedTools = new ArrayList(); + final List globalTools = new ArrayList(); final List localTools = new ArrayList(); - initializeTools(usedTools, localTools); + initializeTools(globalTools, localTools); ((RefManagerImpl)getRefManager()).initializeAnnotators(); - for (Tools tools : usedTools) { + for (Tools tools : globalTools) { for (ScopeToolState state : tools.getTools()) { final InspectionTool tool = (InspectionTool)state.getTool(); try { @@ -510,14 +510,13 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext { scope.accept(new PsiRecursiveElementVisitor() { @Override public void visitFile(PsiFile file) { - final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { incrementJobDoneAmount(LOCAL_ANALYSIS, ProjectUtil.calcRelativeToProjectPath(virtualFile, myProject)); } final FileViewProvider viewProvider = psiManager.findViewProvider(virtualFile); - final com.intellij.openapi.editor.Document document = viewProvider != null ? viewProvider.getDocument() : null; + final com.intellij.openapi.editor.Document document = viewProvider == null ? null : viewProvider.getDocument(); if (document == null || virtualFile.getFileType().isBinary()) return; //do not inspect binary files final LocalInspectionsPass pass = new LocalInspectionsPass(file, document, 0, file.getTextLength()); try { @@ -528,7 +527,7 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext { lTools.add(enabledTool); } } - pass.doInspectInBatch((InspectionManagerEx)manager, lTools.toArray(new InspectionProfileEntry[lTools.size()]), true); + pass.doInspectInBatch((InspectionManagerEx)manager, lTools, true); } catch (ProcessCanceledException e) { throw e; @@ -540,7 +539,7 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext { }); } - public void initializeTools(List tools, List localTools) { + public void initializeTools(List globalTools, List localTools) { myJobDescriptors = new ArrayList(); final InspectionProfileImpl profile = new InspectionProfileImpl((InspectionProfileImpl)getCurrentProfile()); final List usedTools = profile.getAllEnabledInspectionTools(); @@ -553,7 +552,7 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext { appendJobDescriptor(LOCAL_ANALYSIS); } else { - tools.add(currentTools); + globalTools.add(currentTools); JobDescriptor[] jobDescriptors = tool.getJobDescriptors(); for (JobDescriptor jobDescriptor : jobDescriptors) { appendJobDescriptor(jobDescriptor); @@ -565,7 +564,7 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext { } } for (GlobalInspectionContextExtension extension : myExtensions.values()) { - extension.performPreRunActivities(tools, localTools, this); + extension.performPreRunActivities(globalTools, localTools, this); } }