From 3fbae6576dd93c484d359196ec1150dc38b613c4 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 24 Mar 2005 15:10:49 +0300 Subject: [PATCH] (no message) --- .../ex/InspectionManagerEx.java | 61 +++++++++---------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/source/com/intellij/codeInspection/ex/InspectionManagerEx.java b/source/com/intellij/codeInspection/ex/InspectionManagerEx.java index edfb71d1a74a..676bb01f99d7 100644 --- a/source/com/intellij/codeInspection/ex/InspectionManagerEx.java +++ b/source/com/intellij/codeInspection/ex/InspectionManagerEx.java @@ -79,14 +79,14 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern public static final JobDescriptor BUILD_GRAPH = new JobDescriptor("Processing project usages in "); public static final JobDescriptor FIND_EXTERNAL_USAGES = new JobDescriptor("Processing external usages of "); - public static final JobDescriptor LOCAL_ANALYSIS = new JobDescriptor("Analyzing code in "); + private static final JobDescriptor LOCAL_ANALYSIS = new JobDescriptor("Analyzing code in "); - public static final String SUPPRESS_INSPECTIONS_TAG_NAME = "noinspection"; - public static final String SUPPRESS_INSPECTIONS_ANNOTATION_NAME = "com.intellij.util.annotations.NoInspection"; + private static final String SUPPRESS_INSPECTIONS_TAG_NAME = "noinspection"; + private static final String SUPPRESS_INSPECTIONS_ANNOTATION_NAME = "com.intellij.util.annotations.NoInspection"; //for use in local comments - public static final Pattern SUPPRESS_PATTERN = Pattern.compile("//" + SUPPRESS_INSPECTIONS_TAG_NAME + " (\\w+(,\\w+)*)"); + private static final Pattern SUPPRESS_PATTERN = Pattern.compile("//\\s*" + SUPPRESS_INSPECTIONS_TAG_NAME + "\\s+(\\w+(,\\w+)*)"); private InspectionProfile myExternalProfile = null; @@ -184,7 +184,7 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.INSPECTION).activate(null); } - private boolean isInspectionToolIdMentioned(String inspectionsList, String inspectionToolID) { + private static boolean isInspectionToolIdMentioned(String inspectionsList, String inspectionToolID) { String[] ids = inspectionsList.split(","); for (int i = 0; i < ids.length; i++) { String id = ids[i]; @@ -193,7 +193,7 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern return false; } - public boolean isToCheckMember(PsiElement member, String inspectionToolID) { + public static boolean isToCheckMember(PsiElement member, String inspectionToolID) { PsiDocCommentOwner owner; if (member instanceof PsiDocCommentOwner){ owner = (PsiDocCommentOwner)member; @@ -231,7 +231,7 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern return true; } - public boolean inspectionResultSuppressed(PsiElement place, String id) { + public static boolean inspectionResultSuppressed(PsiElement place, String id) { PsiStatement statement = PsiTreeUtil.getParentOfType(place, PsiStatement.class); if (statement != null) { PsiElement prev = PsiTreeUtil.skipSiblingsBackward(statement, new Class[]{PsiWhiteSpace.class}); @@ -262,16 +262,17 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern myUIOptions.myAutoScrollToSourceHandler.install(tree); } - public interface DerivedClassesProcessor { - boolean process(PsiClass inheritor); + public interface DerivedClassesProcessor extends Processor{ } - public interface DerivedMethodsProcessor { - boolean process(PsiMethod derivedMethod); + public interface DerivedMethodsProcessor extends Processor { } - public interface UsagesProcessor { - boolean process(PsiReference psiReference); + public interface UsagesProcessor extends Processor { + } + + private interface Processor { + boolean process(T element); } public void enqueueClassUsagesProcessing(RefClass refClass, UsagesProcessor p) { @@ -300,10 +301,10 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern enqueueRequestImpl(refMethod, myMethodUsagesRequests, p); } - private static void enqueueRequestImpl(RefElement refElement, HashMap requestMap, Object processor) { - ArrayList requests = (ArrayList)requestMap.get(refElement.getElement()); + private static void enqueueRequestImpl(RefElement refElement, Map> requestMap, T processor) { + List requests = requestMap.get(refElement.getElement()); if (requests == null) { - requests = new ArrayList(); + requests = new ArrayList(); requestMap.put(refElement.getElement(), requests); } requests.add(processor); @@ -430,7 +431,7 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern ProgressManager.getInstance().runProcess(new Runnable() { public void run() { if (myDerivedClassesRequests != null) { - ArrayList sortedIDs = getSortedIDs(myDerivedClassesRequests); + List sortedIDs = getSortedIDs(myDerivedClassesRequests); for (int i = 0; i < sortedIDs.size(); i++) { PsiClass psiClass = (PsiClass)sortedIDs.get(i); incrementJobDoneAmount(FIND_EXTERNAL_USAGES, psiClass.getQualifiedName()); @@ -456,7 +457,7 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern } if (myDerivedMethodsRequests != null) { - ArrayList sortedIDs = getSortedIDs(myDerivedMethodsRequests); + List sortedIDs = getSortedIDs(myDerivedMethodsRequests); for (int i = 0; i < sortedIDs.size(); i++) { PsiMethod psiMethod = (PsiMethod)sortedIDs.get(i); final RefMethod refMethod = (RefMethod)refManager.getReference(psiMethod); @@ -485,7 +486,7 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern } if (myFieldUsagesRequests != null) { - ArrayList sortedIDs = getSortedIDs(myFieldUsagesRequests); + List sortedIDs = getSortedIDs(myFieldUsagesRequests); for (int i = 0; i < sortedIDs.size(); i++) { PsiField psiField = (PsiField)sortedIDs.get(i); final List processors = myFieldUsagesRequests.get(psiField); @@ -499,7 +500,7 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern } if (myClassUsagesRequests != null) { - ArrayList sortedIDs = getSortedIDs(myClassUsagesRequests); + List sortedIDs = getSortedIDs(myClassUsagesRequests); for (int i = 0; i < sortedIDs.size(); i++) { PsiClass psiClass = (PsiClass)sortedIDs.get(i); final List processors = myClassUsagesRequests.get(psiClass); @@ -513,7 +514,7 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern } if (myMethodUsagesRequests != null) { - ArrayList sortedIDs = getSortedIDs(myMethodUsagesRequests); + List sortedIDs = getSortedIDs(myMethodUsagesRequests); for (int i = 0; i < sortedIDs.size(); i++) { PsiMethod psiMethod = (PsiMethod)sortedIDs.get(i); final List processors = myMethodUsagesRequests.get(psiMethod); @@ -558,19 +559,16 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern return list.size(); } - private static ArrayList getSortedIDs(HashMap requests) { - ArrayList result = new ArrayList(); - for (Iterator iterator = requests.keySet().iterator(); iterator.hasNext();) { - PsiElement id = (PsiElement)iterator.next(); + private static List getSortedIDs(Map requests) { + List result = new ArrayList(); + for (Iterator iterator = requests.keySet().iterator(); iterator.hasNext();) { + PsiElement id = iterator.next(); result.add(id); } - Collections.sort(result, new Comparator() { - public int compare(Object o1, Object o2) { - PsiElement i1 = (PsiElement)o1; - PsiElement i2 = (PsiElement)o2; - - return i1.getContainingFile().getName().compareTo(i2.getContainingFile().getName()); + Collections.sort(result, new Comparator() { + public int compare(PsiElement o1, PsiElement o2) { + return o1.getContainingFile().getName().compareTo(o2.getContainingFile().getName()); } }); @@ -619,7 +617,6 @@ public class InspectionManagerEx extends InspectionManager implements JDOMExtern if (!ApplicationManager.getApplication().runProcessWithProgressSynchronously(runInspection, "Inspecting Code...", true, myProject)) return; InspectionResultsView view = new InspectionResultsView(myProject, getCurrentProfile(), scope); - InspectionTool[] tools = getCurrentProfile().getInspectionTools(myProject); if (!view.update()) { Messages.showMessageDialog(myProject, "No suspicious code found",