diff --git a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java index fe67af7da906..f65d58051522 100644 --- a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java @@ -83,10 +83,10 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{ } @Override - public void runInspection(final AnalysisScope scope, - final InspectionManager manager, - final GlobalInspectionContext globalContext, - final ProblemDescriptionsProcessor problemDescriptionsProcessor) { + public void runInspection(@NotNull final AnalysisScope scope, + @NotNull final InspectionManager manager, + @NotNull final GlobalInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) { globalContext.getRefManager().iterate(new RefJavaVisitor() { @Override public void visitClass(@NotNull RefClass refClass) { if (!globalContext.shouldCheck(refClass, RedundantSuppressInspection.this)) return; @@ -110,13 +110,13 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{ } @Nullable - private CommonProblemDescriptor[] checkElement(RefClass refEntity, InspectionManager manager, final Project project) { + private CommonProblemDescriptor[] checkElement(@NotNull RefClass refEntity, @NotNull InspectionManager manager, @NotNull Project project) { final PsiClass psiClass = refEntity.getElement(); if (psiClass == null) return null; return checkElement(psiClass, manager, project); } - public CommonProblemDescriptor[] checkElement(@NotNull final PsiElement psiElement, InspectionManager manager, Project project) { + public CommonProblemDescriptor[] checkElement(@NotNull final PsiElement psiElement, @NotNull InspectionManager manager, @NotNull Project project) { final Map> suppressedScopes = new THashMap>(); psiElement.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitModifierList(PsiModifierList list) { @@ -302,7 +302,7 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{ @Override @Nullable - public String getHint(final QuickFix fix) { + public String getHint(@NotNull final QuickFix fix) { if (myQuickFixes != null) { final List list = myQuickFixes.getKeysByValue(fix); if (list != null) { diff --git a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalAnnotator.java b/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalAnnotator.java index 6f5d3a8f3c9e..3b322ff616ee 100644 --- a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalAnnotator.java +++ b/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalAnnotator.java @@ -20,6 +20,7 @@ import com.intellij.codeInspection.reference.*; import com.intellij.psi.*; import com.intellij.psi.controlFlow.*; import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; @@ -34,7 +35,7 @@ class CanBeFinalAnnotator extends RefGraphAnnotatorEx { private final RefManager myManager; public static int CAN_BE_FINAL_MASK; - public CanBeFinalAnnotator(RefManager manager) { + public CanBeFinalAnnotator(@NotNull RefManager manager) { myManager = manager; } diff --git a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java b/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java index b274e5b138f4..35a997fc3b9c 100644 --- a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java @@ -125,18 +125,18 @@ public class CanBeFinalInspection extends GlobalJavaInspectionTool { @Override @Nullable - public RefGraphAnnotator getAnnotator(final RefManager refManager) { + public RefGraphAnnotator getAnnotator(@NotNull final RefManager refManager) { return new CanBeFinalAnnotator(refManager); } @Override @Nullable - public CommonProblemDescriptor[] checkElement(final RefEntity refEntity, - final AnalysisScope scope, - final InspectionManager manager, - final GlobalInspectionContext globalContext, - final ProblemDescriptionsProcessor processor) { + public CommonProblemDescriptor[] checkElement(@NotNull final RefEntity refEntity, + @NotNull final AnalysisScope scope, + @NotNull final InspectionManager manager, + @NotNull final GlobalInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor processor) { if (refEntity instanceof RefJavaElement) { final RefJavaElement refElement = (RefJavaElement)refEntity; if (refElement instanceof RefParameter) return null; @@ -177,8 +177,8 @@ public class CanBeFinalInspection extends GlobalJavaInspectionTool { } @Override - protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext globalContext, - final ProblemDescriptionsProcessor problemsProcessor) { + protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor problemsProcessor) { for (RefElement entryPoint : globalContext.getEntryPointsManager(manager).getEntryPoints()) { problemsProcessor.ignoreElement(entryPoint); } diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/RefUnreachableFilter.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/RefUnreachableFilter.java index b6ca8f42ec67..650e7c527edf 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/RefUnreachableFilter.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/RefUnreachableFilter.java @@ -27,11 +27,12 @@ package com.intellij.codeInspection.deadCode; import com.intellij.codeInspection.ex.InspectionTool; import com.intellij.codeInspection.reference.*; import com.intellij.codeInspection.util.RefFilter; +import org.jetbrains.annotations.NotNull; public class RefUnreachableFilter extends RefFilter { protected InspectionTool myTool; - public RefUnreachableFilter(final InspectionTool tool) { + public RefUnreachableFilter(@NotNull InspectionTool tool) { myTool = tool; } diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnreferencedFilter.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnreferencedFilter.java index b82c6fa0fc29..32dc52252e95 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnreferencedFilter.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnreferencedFilter.java @@ -26,9 +26,10 @@ package com.intellij.codeInspection.deadCode; import com.intellij.codeInspection.ex.InspectionTool; import com.intellij.codeInspection.reference.*; +import org.jetbrains.annotations.NotNull; public class UnreferencedFilter extends RefUnreachableFilter { - public UnreferencedFilter(final InspectionTool tool) { + public UnreferencedFilter(@NotNull InspectionTool tool) { super(tool); } diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index e4086d5b864a..70f22c0765fc 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java @@ -528,7 +528,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool { } private static class WeakUnreferencedFilter extends UnreferencedFilter { - private WeakUnreferencedFilter(final InspectionTool tool) { + private WeakUnreferencedFilter(@NotNull InspectionTool tool) { super(tool); } @@ -770,7 +770,8 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool { if (descriptor instanceof ProblemDescriptor) { if (DELETE.equals(hint)) { return new PermanentDeleteFix(((ProblemDescriptor)descriptor).getPsiElement()); - } else if (COMMENT.equals(hint)) { + } + if (COMMENT.equals(hint)) { return new CommentOutFix(((ProblemDescriptor)descriptor).getPsiElement()); } } diff --git a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java index 08f1e42e3039..479272842951 100644 --- a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java @@ -63,11 +63,11 @@ public class EmptyMethodInspection extends GlobalJavaInspectionTool { @Override @Nullable - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, - AnalysisScope scope, - InspectionManager manager, - GlobalInspectionContext globalContext, - ProblemDescriptionsProcessor processor) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, + @NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor processor) { if (!(refEntity instanceof RefMethod)) { return null; } @@ -202,8 +202,8 @@ public class EmptyMethodInspection extends GlobalJavaInspectionTool { } @Override - protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext context, - final ProblemDescriptionsProcessor descriptionsProcessor) { + protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext context, + @NotNull final ProblemDescriptionsProcessor descriptionsProcessor) { manager.iterate(new RefJavaVisitor() { @Override public void visitElement(@NotNull RefEntity refEntity) { if (refEntity instanceof RefElement && descriptionsProcessor.getDescriptions(refEntity) != null) { @@ -266,7 +266,7 @@ public class EmptyMethodInspection extends GlobalJavaInspectionTool { } @Override - public String getHint(final QuickFix fix) { + public String getHint(@NotNull final QuickFix fix) { final List list = myQuickFixes.getKeysByValue(fix); if (list != null) { LOG.assertTrue(list.size() == 1); diff --git a/java/java-impl/src/com/intellij/codeInspection/inconsistentLanguageLevel/InconsistentLanguageLevelInspection.java b/java/java-impl/src/com/intellij/codeInspection/inconsistentLanguageLevel/InconsistentLanguageLevelInspection.java index 9ff80b54409d..4c0e2227e038 100644 --- a/java/java-impl/src/com/intellij/codeInspection/inconsistentLanguageLevel/InconsistentLanguageLevelInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/inconsistentLanguageLevel/InconsistentLanguageLevelInspection.java @@ -22,15 +22,10 @@ package com.intellij.codeInspection.inconsistentLanguageLevel; import com.intellij.analysis.AnalysisScope; import com.intellij.codeInsight.daemon.GroupNames; -import com.intellij.codeInspection.CommonProblemDescriptor; -import com.intellij.codeInspection.GlobalInspectionContext; -import com.intellij.codeInspection.InspectionManager; -import com.intellij.codeInspection.QuickFix; -import com.intellij.codeInspection.ex.DescriptorProviderInspection; -import com.intellij.codeInspection.ex.JobDescriptor; +import com.intellij.codeInspection.*; +import com.intellij.codeInspection.reference.RefManager; import com.intellij.codeInspection.reference.RefModule; import com.intellij.codeInspection.unnecessaryModuleDependency.UnnecessaryModuleDependencyInspection; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.project.Project; @@ -47,11 +42,12 @@ import org.jetbrains.annotations.NotNull; import java.util.Set; -public class InconsistentLanguageLevelInspection extends DescriptorProviderInspection{ - private static final Logger LOGGER = Logger.getInstance("#" + InconsistentLanguageLevelInspection.class.getName()); - +public class InconsistentLanguageLevelInspection extends GlobalInspectionTool { @Override - public void runInspection(@NotNull AnalysisScope scope, @NotNull InspectionManager manager) { + public void runInspection(@NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor problemProcessor) { final Set modules = new THashSet(); scope.accept(new PsiElementVisitor(){ @Override @@ -69,8 +65,8 @@ public class InconsistentLanguageLevelInspection extends DescriptorProviderInspe if (languageLevel == null) { languageLevel = projectLanguageLevel; } - LOGGER.assertTrue(languageLevel != null); - final RefModule refModule = getRefManager().getRefModule(module); + RefManager refManager = globalContext.getRefManager(); + final RefModule refModule = refManager.getRefModule(module); for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) { if (!(entry instanceof ModuleOrderEntry)) continue; final Module dependantModule = ((ModuleOrderEntry)entry).getModule(); @@ -79,25 +75,18 @@ public class InconsistentLanguageLevelInspection extends DescriptorProviderInspe if (dependantLanguageLevel == null) { dependantLanguageLevel = projectLanguageLevel; } - LOGGER.assertTrue(dependantLanguageLevel != null); if (languageLevel.compareTo(dependantLanguageLevel) < 0) { final CommonProblemDescriptor problemDescriptor = manager.createProblemDescriptor( "Inconsistent language level settings: module " + module.getName() + " with language level " + languageLevel + " depends on module " + dependantModule.getName() +" with language level " + dependantLanguageLevel, new UnnecessaryModuleDependencyInspection.RemoveModuleDependencyFix(module, dependantModule), new OpenModuleSettingsFix(module)); - addProblemElement(refModule, problemDescriptor); + problemProcessor.addProblemElement(refModule, problemDescriptor); } } } } - @Override - @NotNull - public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext globalInspectionContext) { - return JobDescriptor.EMPTY_ARRAY; - } - @Override public boolean isEnabledByDefault() { return false; diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java index 13020923b013..8c9cda6eb582 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java @@ -265,7 +265,7 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass { } @Override - public void accept(final RefVisitor visitor) { + public void accept(@NotNull final RefVisitor visitor) { if (visitor instanceof RefJavaVisitor) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefFieldImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefFieldImpl.java index 7e2bef09d30f..35262e3e725c 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefFieldImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefFieldImpl.java @@ -100,7 +100,7 @@ public class RefFieldImpl extends RefJavaElementImpl implements RefField { } @Override - public void accept(final RefVisitor visitor) { + public void accept(@NotNull final RefVisitor visitor) { if (visitor instanceof RefJavaVisitor) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java index d47b5a0d0281..5d9bd6c2fa1a 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java @@ -29,6 +29,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.Computable; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiModifierListOwner; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class RefImplicitConstructorImpl extends RefMethodImpl implements RefImplicitConstructor { @@ -47,6 +48,7 @@ public class RefImplicitConstructorImpl extends RefMethodImpl implements RefImpl return ((RefClassImpl)getOwnerClass()).isSuspicious(); } + @NotNull @Override public String getName() { return InspectionsBundle.message("inspection.reference.implicit.constructor.name", getOwnerClass().getName()); diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaElementImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaElementImpl.java index 6b79741b9d98..c0cd71eda18a 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaElementImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaElementImpl.java @@ -48,7 +48,7 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa private static final int IS_USES_DEPRECATION_MASK = 0x200; private static final int IS_SYNTHETIC_JSP_ELEMENT = 0x400; - protected RefJavaElementImpl(String name, RefJavaElement owner) { + protected RefJavaElementImpl(String name, @NotNull RefJavaElement owner) { super(name, owner); String am = owner.getAccessModifier(); doSetAccessModifier(am); diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java index b8fea07a1847..d094a1896461 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java @@ -35,6 +35,7 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; import gnu.trove.THashMap; import org.jdom.Element; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -53,7 +54,7 @@ public class RefJavaManagerImpl extends RefJavaManager { private PsiElementVisitor myProjectIterator; private EntryPointsManager myEntryPointsManager; - public RefJavaManagerImpl(RefManagerImpl manager) { + public RefJavaManagerImpl(@NotNull RefManagerImpl manager) { myRefManager = manager; final Project project = manager.getProject(); final PsiManager psiManager = PsiManager.getInstance(project); @@ -174,7 +175,7 @@ public class RefJavaManagerImpl extends RefJavaManager { @Override - public void iterate(final RefVisitor visitor) { + public void iterate(@NotNull final RefVisitor visitor) { if (myPackages != null) { for (RefPackage refPackage : myPackages.values()) { refPackage.accept(visitor); diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java index e7802173c3e4..bca7bd179d03 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java @@ -68,7 +68,7 @@ public class RefMethodImpl extends RefJavaElementImpl implements RefMethod { } // To be used only from RefImplicitConstructor. - protected RefMethodImpl(String name, RefClass ownerClass) { + protected RefMethodImpl(String name, @NotNull RefClass ownerClass) { super(name, ownerClass); myOwnerClass = ownerClass; ((RefClassImpl)ownerClass).add(this); @@ -325,7 +325,7 @@ public class RefMethodImpl extends RefJavaElementImpl implements RefMethod { } @Override - public void accept(final RefVisitor visitor) { + public void accept(@NotNull final RefVisitor visitor) { if (visitor instanceof RefJavaVisitor) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override @@ -417,6 +417,7 @@ public class RefMethodImpl extends RefJavaElementImpl implements RefMethod { return (RefClass) getOwner(); } + @NotNull @Override public String getName() { if (isValid()) { diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefPackageImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefPackageImpl.java index 5fb00bf12dc7..32649b924a25 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefPackageImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefPackageImpl.java @@ -26,6 +26,7 @@ package com.intellij.codeInspection.reference; import com.intellij.openapi.application.ApplicationManager; import com.intellij.util.PlatformIcons; +import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -33,24 +34,25 @@ import javax.swing.*; public class RefPackageImpl extends RefEntityImpl implements RefPackage { private final String myQualifiedName; - public RefPackageImpl(String name, RefManager refManager) { + public RefPackageImpl(@NotNull String name, @NotNull RefManager refManager) { super(getPackageSuffix(name), refManager); myQualifiedName = name; } + @NotNull @Override public String getQualifiedName() { return myQualifiedName; } - private static String getPackageSuffix(String fullName) { + private static String getPackageSuffix(@NotNull String fullName) { int dotIndex = fullName.lastIndexOf('.'); return (dotIndex >= 0) ? fullName.substring(dotIndex + 1) : fullName; } @Override - public void accept(final RefVisitor visitor) { + public void accept(@NotNull final RefVisitor visitor) { if (visitor instanceof RefJavaVisitor) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefParameterImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefParameterImpl.java index 403d26db4b79..f33145fa070e 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefParameterImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefParameterImpl.java @@ -29,6 +29,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.psi.*; import com.intellij.psi.util.PsiFormatUtil; import com.intellij.psi.util.PsiTreeUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class RefParameterImpl extends RefJavaElementImpl implements RefParameter { @@ -83,7 +84,7 @@ public class RefParameterImpl extends RefJavaElementImpl implements RefParameter } @Override - public void accept(final RefVisitor visitor) { + public void accept(@NotNull final RefVisitor visitor) { if (visitor instanceof RefJavaVisitor) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override diff --git a/java/java-impl/src/com/intellij/codeInspection/sameParameterValue/SameParameterValueInspection.java b/java/java-impl/src/com/intellij/codeInspection/sameParameterValue/SameParameterValueInspection.java index 7e5e07181fd3..59abd75d39a5 100644 --- a/java/java-impl/src/com/intellij/codeInspection/sameParameterValue/SameParameterValueInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/sameParameterValue/SameParameterValueInspection.java @@ -46,8 +46,8 @@ public class SameParameterValueInspection extends GlobalJavaInspectionTool { @Override @Nullable - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, AnalysisScope scope, InspectionManager manager, GlobalInspectionContext globalContext, - ProblemDescriptionsProcessor processor) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, @NotNull AnalysisScope scope, @NotNull InspectionManager manager, @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor processor) { ArrayList problems = null; if (refEntity instanceof RefMethod) { final RefMethod refMethod = (RefMethod)refEntity; @@ -75,8 +75,8 @@ public class SameParameterValueInspection extends GlobalJavaInspectionTool { @Override - protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext globalContext, - final ProblemDescriptionsProcessor processor) { + protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor processor) { manager.iterate(new RefJavaVisitor() { @Override public void visitElement(@NotNull RefEntity refEntity) { if (refEntity instanceof RefElement && processor.getDescriptions(refEntity) != null) { @@ -129,7 +129,7 @@ public class SameParameterValueInspection extends GlobalJavaInspectionTool { @Override @Nullable - public String getHint(final QuickFix fix) { + public String getHint(@NotNull final QuickFix fix) { final InlineParameterValueFix valueFix = (InlineParameterValueFix)fix; return valueFix.getParamName() + " " + valueFix.getValue(); } diff --git a/java/java-impl/src/com/intellij/codeInspection/sameReturnValue/SameReturnValueInspection.java b/java/java-impl/src/com/intellij/codeInspection/sameReturnValue/SameReturnValueInspection.java index fd6cf5990a83..7d4c3536b139 100644 --- a/java/java-impl/src/com/intellij/codeInspection/sameReturnValue/SameReturnValueInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/sameReturnValue/SameReturnValueInspection.java @@ -29,8 +29,8 @@ import org.jetbrains.annotations.Nullable; public class SameReturnValueInspection extends GlobalJavaInspectionTool { @Override @Nullable - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, AnalysisScope scope, InspectionManager manager, GlobalInspectionContext globalContext, - ProblemDescriptionsProcessor processor) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, @NotNull AnalysisScope scope, @NotNull InspectionManager manager, @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor processor) { if (refEntity instanceof RefMethod) { final RefMethod refMethod = (RefMethod)refEntity; @@ -57,8 +57,8 @@ public class SameReturnValueInspection extends GlobalJavaInspectionTool { @Override - protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext globalContext, - final ProblemDescriptionsProcessor processor) { + protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor processor) { manager.iterate(new RefJavaVisitor() { @Override public void visitElement(@NotNull RefEntity refEntity) { if (refEntity instanceof RefElement && processor.getDescriptions(refEntity) != null) { diff --git a/java/java-impl/src/com/intellij/codeInspection/unnecessaryModuleDependency/UnnecessaryModuleDependencyInspection.java b/java/java-impl/src/com/intellij/codeInspection/unnecessaryModuleDependency/UnnecessaryModuleDependencyInspection.java index 049811978cc9..87e99c553b36 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unnecessaryModuleDependency/UnnecessaryModuleDependencyInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/unnecessaryModuleDependency/UnnecessaryModuleDependencyInspection.java @@ -28,12 +28,12 @@ import java.util.Set; public class UnnecessaryModuleDependencyInspection extends GlobalInspectionTool { @Override - public RefGraphAnnotator getAnnotator(final RefManager refManager) { + public RefGraphAnnotator getAnnotator(@NotNull final RefManager refManager) { return new UnnecessaryModuleDependencyAnnotator(refManager); } @Override - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, AnalysisScope scope, InspectionManager manager, final GlobalInspectionContext globalContext) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, @NotNull AnalysisScope scope, @NotNull InspectionManager manager, @NotNull final GlobalInspectionContext globalContext) { if (refEntity instanceof RefModule){ final RefModule refModule = (RefModule)refEntity; final Module module = refModule.getModule(); diff --git a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java b/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java index 7c748affc607..6b3ebe0defdd 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java +++ b/java/java-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrows.java @@ -51,11 +51,11 @@ public class RedundantThrows extends GlobalJavaInspectionTool { @Override @Nullable - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, - AnalysisScope scope, - InspectionManager manager, - GlobalInspectionContext globalContext, - ProblemDescriptionsProcessor processor) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, + @NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor processor) { if (refEntity instanceof RefMethod) { final RefMethod refMethod = (RefMethod)refEntity; if (refMethod.isSyntheticJSP()) return null; @@ -123,8 +123,8 @@ public class RedundantThrows extends GlobalJavaInspectionTool { @Override - protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext globalContext, - final ProblemDescriptionsProcessor processor) { + protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor processor) { manager.iterate(new RefJavaVisitor() { @Override public void visitElement(@NotNull RefEntity refEntity) { if (processor.getDescriptions(refEntity) != null) { @@ -184,7 +184,7 @@ public class RedundantThrows extends GlobalJavaInspectionTool { @Override @Nullable - public String getHint(final QuickFix fix) { + public String getHint(@NotNull final QuickFix fix) { final List hints = myQuickFixes.getKeysByValue(fix); LOG.assertTrue(hints != null && hints.size() == 1); return hints.get(0); diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedLibraries/UnusedLibrariesInspection.java b/java/java-impl/src/com/intellij/codeInspection/unusedLibraries/UnusedLibrariesInspection.java index c77d57989141..288202f9089f 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedLibraries/UnusedLibrariesInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/unusedLibraries/UnusedLibrariesInspection.java @@ -23,7 +23,7 @@ package com.intellij.codeInspection.unusedLibraries; import com.intellij.analysis.AnalysisScope; import com.intellij.codeInsight.daemon.GroupNames; import com.intellij.codeInspection.*; -import com.intellij.codeInspection.ex.DescriptorProviderInspection; +import com.intellij.codeInspection.ex.GlobalInspectionContextImpl; import com.intellij.codeInspection.ex.JobDescriptor; import com.intellij.codeInspection.reference.RefManager; import com.intellij.codeInspection.reference.RefModule; @@ -60,13 +60,17 @@ import org.jetbrains.annotations.NotNull; import java.util.*; -public class UnusedLibrariesInspection extends DescriptorProviderInspection { +public class UnusedLibrariesInspection extends GlobalInspectionTool { private static final Logger LOG = Logger.getInstance("#" + UnusedLibrariesInspection.class.getName()); private final JobDescriptor BACKWARD_ANALYSIS = new JobDescriptor(InspectionsBundle.message("unused.library.backward.analysis.job.description")); @Override - public void runInspection(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager) { - final Project project = getContext().getProject(); + public void runInspection(@NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull final GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor problemProcessor) { + ((GlobalInspectionContextImpl)globalContext).appendJobDescriptor(BACKWARD_ANALYSIS); + final Project project = manager.getProject(); final ArrayList libraryRoots = new ArrayList(); if (scope.getScopeType() == AnalysisScope.PROJECT) { ContainerUtil.addAll(libraryRoots, LibraryUtil.getLibraryRoots(project, false, false)); @@ -110,33 +114,43 @@ public class UnusedLibrariesInspection extends DescriptorProviderInspection { final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); BACKWARD_ANALYSIS.setTotalAmount(builder.getTotalFileCount()); - ((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable(){ - @Override - public void run() { - builder.analyze(); - } - }, new ProgressIndicatorBase() { - @Override - public void setFraction(final double fraction) { - super.setFraction(fraction); - int nextAmount = (int)(fraction * BACKWARD_ANALYSIS.getTotalAmount()); - if (nextAmount > BACKWARD_ANALYSIS.getDoneAmount() && nextAmount < BACKWARD_ANALYSIS.getTotalAmount()) { - BACKWARD_ANALYSIS.setDoneAmount(nextAmount); - getContext().incrementJobDoneAmount(BACKWARD_ANALYSIS, getText2()); - } - } + ((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable() { + @Override + public void run() { + builder.analyze(); + } + }, new ProgressIndicatorBase() { + @Override + public void setFraction(final double fraction) { + super.setFraction(fraction); + int nextAmount = (int)(fraction * + BACKWARD_ANALYSIS + .getTotalAmount()); + if (nextAmount > + BACKWARD_ANALYSIS.getDoneAmount() && + nextAmount < + BACKWARD_ANALYSIS.getTotalAmount()) { + BACKWARD_ANALYSIS.setDoneAmount(nextAmount); + globalContext + .incrementJobDoneAmount(BACKWARD_ANALYSIS, + getText2()); + } + } - @Override - public boolean isCanceled() { - return progressIndicator != null && progressIndicator.isCanceled() || super.isCanceled(); - } - }); + @Override + public boolean isCanceled() { + return progressIndicator != null && + progressIndicator.isCanceled() || + super.isCanceled(); + } + } + ); BACKWARD_ANALYSIS.setDoneAmount(BACKWARD_ANALYSIS.getTotalAmount()); final Map> dependencies = builder.getDependencies(); for (PsiFile file : dependencies.keySet()) { final VirtualFile virtualFile = file.getVirtualFile(); LOG.assertTrue(virtualFile != null); - for (Iterator i = libraryRoots.iterator(); i.hasNext();) { + for (Iterator i = libraryRoots.iterator(); i.hasNext(); ) { if (VfsUtil.isAncestor(i.next(), virtualFile, false)) { i.remove(); } @@ -158,7 +172,7 @@ public class UnusedLibrariesInspection extends DescriptorProviderInspection { files.add(libraryRoot); } } - final RefManager refManager = getRefManager(); + final RefManager refManager = globalContext.getRefManager(); for (OrderEntry orderEntry : unusedLibs.keySet()) { if (!(orderEntry instanceof LibraryOrderEntry)) continue; final RefModule refModule = refManager.getRefModule(orderEntry.getOwnerModule()); @@ -166,27 +180,24 @@ public class UnusedLibrariesInspection extends DescriptorProviderInspection { final VirtualFile[] roots = ((LibraryOrderEntry)orderEntry).getRootFiles(OrderRootType.CLASSES); if (files.size() < roots.length) { final String unusedLibraryRoots = StringUtil.join(files, new Function() { - @Override - public String fun(final VirtualFile file) { - return file.getPresentableName(); - } - }, ","); - String message = InspectionsBundle.message("unused.library.roots.problem.descriptor", unusedLibraryRoots, orderEntry.getPresentableName()); - addProblemElement(refModule, manager.createProblemDescriptor(message, new RemoveUnusedLibrary(refModule, orderEntry, files))); + @Override + public String fun(final VirtualFile file) { + return file.getPresentableName(); + } + }, ","); + String message = + InspectionsBundle.message("unused.library.roots.problem.descriptor", unusedLibraryRoots, orderEntry.getPresentableName()); + problemProcessor.addProblemElement(refModule, + manager.createProblemDescriptor(message, new RemoveUnusedLibrary(refModule, orderEntry, files))); } else { String message = InspectionsBundle.message("unused.library.problem.descriptor", orderEntry.getPresentableName()); - addProblemElement(refModule, manager.createProblemDescriptor(message, new RemoveUnusedLibrary(refModule, orderEntry, null))); + problemProcessor.addProblemElement(refModule, + manager.createProblemDescriptor(message, new RemoveUnusedLibrary(refModule, orderEntry, null))); } } } - @Override - @NotNull - public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext globalInspectionContext) { - return new JobDescriptor[] {BACKWARD_ANALYSIS}; - } - @Override public boolean isEnabledByDefault() { return false; diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java b/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java index b26e43fca402..ea832d151cf0 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java @@ -58,11 +58,11 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool { @Override @Nullable - public CommonProblemDescriptor[] checkElement(final RefEntity refEntity, - final AnalysisScope scope, - final InspectionManager manager, - final GlobalInspectionContext globalContext, - final ProblemDescriptionsProcessor processor) { + public CommonProblemDescriptor[] checkElement(@NotNull final RefEntity refEntity, + @NotNull final AnalysisScope scope, + @NotNull final InspectionManager manager, + @NotNull final GlobalInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor processor) { if (refEntity instanceof RefMethod) { final RefMethod refMethod = (RefMethod)refEntity; @@ -103,15 +103,15 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool { } @Override - protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext globalContext, - final ProblemDescriptionsProcessor processor) { + protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor processor) { final Project project = manager.getProject(); for (RefElement entryPoint : globalContext.getEntryPointsManager(manager).getEntryPoints()) { processor.ignoreElement(entryPoint); } final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(project); - final AnalysisScope scope = manager.getScope(); + final AnalysisScope scope = ((RefManagerImpl)manager).getScope(); manager.iterate(new RefJavaVisitor() { @Override public void visitElement(@NotNull RefEntity refEntity) { @@ -162,7 +162,7 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool { @Override @Nullable - public String getHint(final QuickFix fix) { + public String getHint(@NotNull final QuickFix fix) { return ((AcceptSuggested)fix).getHint(); } @@ -173,7 +173,7 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool { } @Override - public void compose(final StringBuffer buf, final RefEntity refEntity, final HTMLComposer composer) { + public void compose(@NotNull final StringBuffer buf, @NotNull final RefEntity refEntity, @NotNull final HTMLComposer composer) { if (refEntity instanceof RefMethod) { final RefMethod refMethod = (RefMethod)refEntity; final HTMLJavaHTMLComposer javaComposer = composer.getExtension(HTMLJavaHTMLComposer.COMPOSER); diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java b/java/java-impl/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java index 31a414d83a31..2bfbdf833c93 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java +++ b/java/java-impl/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java @@ -48,11 +48,11 @@ public class UnusedReturnValue extends GlobalJavaInspectionTool{ @Override @Nullable - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, - AnalysisScope scope, - InspectionManager manager, - GlobalInspectionContext globalContext, - ProblemDescriptionsProcessor processor) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, + @NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor processor) { if (refEntity instanceof RefMethod) { final RefMethod refMethod = (RefMethod)refEntity; @@ -90,8 +90,8 @@ public class UnusedReturnValue extends GlobalJavaInspectionTool{ } @Override - protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext globalContext, - final ProblemDescriptionsProcessor processor) { + protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor processor) { manager.iterate(new RefJavaVisitor() { @Override public void visitElement(@NotNull RefEntity refEntity) { if (refEntity instanceof RefElement && processor.getDescriptions(refEntity) != null) { diff --git a/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java b/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java index 65745a9d212f..112c379b712c 100644 --- a/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java @@ -143,11 +143,11 @@ public class VisibilityInspection extends GlobalJavaInspectionTool { @Override @Nullable - public CommonProblemDescriptor[] checkElement(final RefEntity refEntity, - final AnalysisScope scope, - final InspectionManager manager, - final GlobalInspectionContext globalContext, - final ProblemDescriptionsProcessor processor) { + public CommonProblemDescriptor[] checkElement(@NotNull final RefEntity refEntity, + @NotNull final AnalysisScope scope, + @NotNull final InspectionManager manager, + @NotNull final GlobalInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor processor) { if (refEntity instanceof RefJavaElement) { final RefJavaElement refElement = (RefJavaElement)refEntity; @@ -403,8 +403,8 @@ public class VisibilityInspection extends GlobalJavaInspectionTool { @Override - protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext globalContext, - final ProblemDescriptionsProcessor processor) { + protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor processor) { final EntryPointsManager entryPointsManager = globalContext.getEntryPointsManager(manager); for (RefElement entryPoint : entryPointsManager.getEntryPoints()) { ignoreElement(processor, entryPoint); @@ -516,7 +516,7 @@ public class VisibilityInspection extends GlobalJavaInspectionTool { } @Override - public void compose(final StringBuffer buf, final RefEntity refEntity, final HTMLComposer composer) { + public void compose(@NotNull final StringBuffer buf, @NotNull final RefEntity refEntity, @NotNull final HTMLComposer composer) { composer.appendElementInReferences(buf, (RefElement)refEntity); } @@ -528,7 +528,7 @@ public class VisibilityInspection extends GlobalJavaInspectionTool { @Override @Nullable - public String getHint(final QuickFix fix) { + public String getHint(@NotNull final QuickFix fix) { return ((AcceptSuggestedAccess)fix).getHint(); } diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearcher.java index 5bc07cb4e4bd..80459c1b20f8 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearcher.java @@ -28,7 +28,7 @@ public class ConstructorReferencesSearcher extends QueryExecutorBase { @NonNls public static final String CLASS = "class"; @@ -70,11 +71,13 @@ public abstract class RefJavaManager implements RefManagerExtension getID() { return MANAGER; diff --git a/java/openapi/src/com/intellij/codeInspection/reference/RefPackage.java b/java/openapi/src/com/intellij/codeInspection/reference/RefPackage.java index 699e57ce61be..3aee63a4421d 100644 --- a/java/openapi/src/com/intellij/codeInspection/reference/RefPackage.java +++ b/java/openapi/src/com/intellij/codeInspection/reference/RefPackage.java @@ -15,6 +15,8 @@ */ package com.intellij.codeInspection.reference; +import org.jetbrains.annotations.NotNull; + /** * A node in the reference graph corresponding to a Java package. * @@ -28,6 +30,7 @@ public interface RefPackage extends RefEntity { * * @return the full-qualified name for the package. */ + @NotNull @Override String getQualifiedName(); } diff --git a/platform/lang-api/src/com/intellij/analysis/AnalysisScope.java b/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java similarity index 90% rename from platform/lang-api/src/com/intellij/analysis/AnalysisScope.java rename to platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java index c3c58b411cad..510f4b5ffb06 100644 --- a/platform/lang-api/src/com/intellij/analysis/AnalysisScope.java +++ b/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java @@ -16,9 +16,9 @@ package com.intellij.analysis; +import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.daemon.ProblemHighlightFilter; import com.intellij.lang.injection.InjectedLanguageManager; -import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; @@ -27,20 +27,18 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectCoreUtil; -import com.intellij.openapi.project.ProjectUtil; +import com.intellij.openapi.project.ProjectUtilCore; import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.libraries.LibraryUtil; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; -import com.intellij.profile.ProjectProfileManager; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.GlobalSearchScopes; +import com.intellij.psi.search.GlobalSearchScopesCore; import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.SearchScope; import com.intellij.util.ArrayUtil; @@ -58,8 +56,6 @@ import java.util.*; public class AnalysisScope { private static final Logger LOG = Logger.getInstance("#com.intellij.analysis.AnalysisScope"); - public static final DataKey KEY = DataKey.create("analysisScope"); - public static final int PROJECT = 1; public static final int DIRECTORY = 2; public static final int FILE = 3; @@ -84,7 +80,7 @@ public class AnalysisScope { private boolean mySearchInLibraries = false; @Type protected int myType; - protected HashSet myFilesSet; + protected Set myFilesSet; protected boolean myIncludeTestSource = true; @@ -201,13 +197,19 @@ public class AnalysisScope { myFilesSet.add(virtualFile); if (indicator != null) { indicator.setText(AnalysisScopeBundle.message("scanning.scope.progress.title")); - indicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, file.getProject())); + Project project = file.getProject(); + String text = displayProjectRelativePath(virtualFile, project); + indicator.setText2(text); } } } }; } + private static String displayProjectRelativePath(@NotNull VirtualFile virtualFile, @NotNull Project project) { + return ProjectUtilCore.displayUrlRelativeToProject(virtualFile, virtualFile.getPresentableUrl(), project, false, false); + } + public boolean contains(@NotNull PsiElement psiElement) { return contains(psiElement.getContainingFile().getVirtualFile()); } @@ -267,7 +269,7 @@ public class AnalysisScope { return ((GlobalSearchScope)myScope).contains(fileOrDir); } }).booleanValue(); - return !isInScope || AnalysisScope.this.processFile(fileOrDir, visitor, psiManager, needReadAction); + return !isInScope || AnalysisScope.processFile(fileOrDir, visitor, psiManager, needReadAction); } }; projectFileIndex.iterateContent(contentIterator); @@ -348,10 +350,10 @@ public class AnalysisScope { return true; } - private boolean processFile(@NotNull final VirtualFile fileOrDir, - @NotNull final PsiElementVisitor visitor, - @NotNull final PsiManager psiManager, - final boolean needReadAction) { + private static boolean processFile(@NotNull final VirtualFile fileOrDir, + @NotNull final PsiElementVisitor visitor, + @NotNull final PsiManager psiManager, + final boolean needReadAction) { if (!fileOrDir.isValid()) return false; final PsiFile file = getPsiFileInReadAction(psiManager, fileOrDir); if (file == null){ @@ -407,7 +409,7 @@ public class AnalysisScope { public boolean processFile(@NotNull final VirtualFile fileOrDir) { if (!myIncludeTestSource && index.isInTestSourceContent(fileOrDir)) return true; if (!fileOrDir.isDirectory()) { - return AnalysisScope.this.processFile(fileOrDir, visitor, psiManager, needReadAction); + return AnalysisScope.processFile(fileOrDir, visitor, psiManager, needReadAction); } return true; } @@ -510,8 +512,7 @@ public class AnalysisScope { @Nullable private String getRelativePath() { - final String relativePath = ProjectUtil.calcRelativeToProjectPath(((PsiFileSystemItem)myElement).getVirtualFile(), - myElement.getProject()); + final String relativePath = displayProjectRelativePath(((PsiFileSystemItem)myElement).getVirtualFile(), myElement.getProject()); if (relativePath.length() > 100) { return null; } @@ -534,12 +535,9 @@ public class AnalysisScope { return myFilesSet.size(); } - public boolean checkScopeWritable(Project project) { + public boolean checkScopeWritable(@NotNull Project project) { if (myFilesSet == null) initFilesSet(); - final ReadonlyStatusHandler statusHandler = ReadonlyStatusHandler.getInstance(project); - final ReadonlyStatusHandler.OperationStatus status = - statusHandler.ensureFilesWritable(myFilesSet); - return status.hasReadonlyFiles(); + return !FileModificationService.getInstance().prepareVirtualFilesForWrite(project, myFilesSet); } public void invalidate(){ @@ -571,30 +569,6 @@ public class AnalysisScope { }); } - protected static void processDirectories(@NotNull final PsiDirectory[] psiDirectories, - @NotNull final Set result, - @NotNull final ProjectProfileManager profileManager) { - for (final PsiDirectory directory : psiDirectories) { - final PsiFile[] psiFiles = ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - @NotNull - public PsiFile[] compute() { - return directory.getFiles(); - } - }); - for (PsiFile file : psiFiles) { - result.add(profileManager.getProfileName()); - } - processDirectories(ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - @NotNull - public PsiDirectory[] compute() { - return directory.getSubdirectories(); - } - }), result, profileManager); - } - } - public boolean containsSources(boolean isTest) { if (myElement != null) { final Project project = myElement.getProject(); @@ -693,14 +667,14 @@ public class AnalysisScope { case CUSTOM: return myScope; case DIRECTORY: - return GlobalSearchScopes.directoryScope((PsiDirectory)myElement, true); + return GlobalSearchScopesCore.directoryScope((PsiDirectory)myElement, true); case FILE: return new LocalSearchScope(myElement); case INVALID: return LocalSearchScope.EMPTY; case MODULE: GlobalSearchScope moduleScope = GlobalSearchScope.moduleScope(myModule); - return myIncludeTestSource ? moduleScope : GlobalSearchScope.notScope(GlobalSearchScopes.projectTestScope(myModule.getProject())).intersectWith(moduleScope); + return myIncludeTestSource ? moduleScope : GlobalSearchScope.notScope(GlobalSearchScopesCore.projectTestScope(myModule.getProject())).intersectWith(moduleScope); case MODULES: SearchScope scope = GlobalSearchScope.EMPTY_SCOPE; for (Module module : myModules) { @@ -708,7 +682,7 @@ public class AnalysisScope { } return scope; case PROJECT: - return myIncludeTestSource ? GlobalSearchScope.projectScope(myProject) : GlobalSearchScopes.projectProductionScope(myProject); + return myIncludeTestSource ? GlobalSearchScope.projectScope(myProject) : GlobalSearchScopesCore.projectProductionScope(myProject); case VIRTUAL_FILES: return new GlobalSearchScope() { @Override diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/ProblemHighlightFilter.java b/platform/analysis-api/src/com/intellij/codeInsight/daemon/ProblemHighlightFilter.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInsight/daemon/ProblemHighlightFilter.java rename to platform/analysis-api/src/com/intellij/codeInsight/daemon/ProblemHighlightFilter.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/GlobalInspectionContext.java b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionContext.java similarity index 99% rename from platform/lang-api/src/com/intellij/codeInspection/GlobalInspectionContext.java rename to platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionContext.java index 7c31288700ee..2c9748c0ede5 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/GlobalInspectionContext.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionContext.java @@ -72,6 +72,7 @@ public interface GlobalInspectionContext extends UserDataHolder { */ boolean isSuppressed(@NotNull PsiElement element, String inspectionToolId); + @NotNull Project getProject(); T getExtension(Key key); diff --git a/platform/lang-api/src/com/intellij/codeInspection/GlobalInspectionTool.java b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java similarity index 82% rename from platform/lang-api/src/com/intellij/codeInspection/GlobalInspectionTool.java rename to platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java index 81342d07bf15..807eca1ffb04 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/GlobalInspectionTool.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java @@ -46,7 +46,7 @@ public abstract class GlobalInspectionTool extends InspectionProfileEntry { * @see #isGraphNeeded */ @Nullable - public RefGraphAnnotator getAnnotator(final RefManager refManager) { + public RefGraphAnnotator getAnnotator(@NotNull RefManager refManager) { return null; } @@ -61,10 +61,10 @@ public abstract class GlobalInspectionTool extends InspectionProfileEntry { * @param globalContext the context for the current global inspection run. * @param problemDescriptionsProcessor the collector for problems reported by the inspection */ - public void runInspection(final AnalysisScope scope, - final InspectionManager manager, - final GlobalInspectionContext globalContext, - final ProblemDescriptionsProcessor problemDescriptionsProcessor) { + public void runInspection(@NotNull final AnalysisScope scope, + @NotNull final InspectionManager manager, + @NotNull final GlobalInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) { globalContext.getRefManager().iterate(new RefVisitor() { @Override public void visitElement(@NotNull RefEntity refEntity) { if (!globalContext.shouldCheck(refEntity, GlobalInspectionTool.this)) return; @@ -86,7 +86,10 @@ public abstract class GlobalInspectionTool extends InspectionProfileEntry { * @return the problems found for the element, or null if no problems were found. */ @Nullable - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, AnalysisScope scope, InspectionManager manager, GlobalInspectionContext globalContext) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, + @NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext) { return null; } @@ -101,11 +104,11 @@ public abstract class GlobalInspectionTool extends InspectionProfileEntry { * @return the problems found for the element, or null if no problems were found. */ @Nullable - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, - AnalysisScope scope, - InspectionManager manager, - GlobalInspectionContext globalContext, - ProblemDescriptionsProcessor processor) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, + @NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor processor) { return checkElement(refEntity, scope, manager, globalContext); } @@ -145,16 +148,16 @@ public abstract class GlobalInspectionTool extends InspectionProfileEntry { * @return true if a repeated call to this method is required after the queued usage processors * have completed work, false otherwise. */ - public boolean queryExternalUsagesRequests(final InspectionManager manager, - final GlobalInspectionContext globalContext, - final ProblemDescriptionsProcessor problemDescriptionsProcessor){ + public boolean queryExternalUsagesRequests(@NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor){ return false; } /** - * Allows TeamCity plugin to reconstract quickfixes from server side data + * Allows TeamCity plugin to reconstruct quickfixes from server side data * @param hint a hint to distinguish different quick fixes for one problem - * @return quickfix to be shown in editor when server side insepctions are enabled + * @return quickfix to be shown in editor when server side inspections are enabled */ @Nullable public QuickFix getQuickFix(final String hint) { @@ -162,12 +165,12 @@ public abstract class GlobalInspectionTool extends InspectionProfileEntry { } /** - * Allows TeamCity plugin to serialize quick fixes on server in order to reconstract them in idea + * Allows TeamCity plugin to serialize quick fixes on server in order to reconstruct them in idea * @param fix fix to be serialized * @return hint to be stored on server */ @Nullable - public String getHint(final QuickFix fix) { + public String getHint(@NotNull QuickFix fix) { return null; } @@ -177,7 +180,7 @@ public abstract class GlobalInspectionTool extends InspectionProfileEntry { * @param refEntity entity to describe * @param composer provides sample api to compose html */ - public void compose(StringBuffer buf, RefEntity refEntity, HTMLComposer composer) { + public void compose(@NotNull StringBuffer buf, @NotNull RefEntity refEntity, @NotNull HTMLComposer composer) { } /** diff --git a/platform/lang-api/src/com/intellij/codeInspection/HTMLComposer.java b/platform/analysis-api/src/com/intellij/codeInspection/HTMLComposer.java similarity index 99% rename from platform/lang-api/src/com/intellij/codeInspection/HTMLComposer.java rename to platform/analysis-api/src/com/intellij/codeInspection/HTMLComposer.java index d82019d4ea2a..59c2683e5c19 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/HTMLComposer.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/HTMLComposer.java @@ -62,4 +62,4 @@ public abstract class HTMLComposer { public abstract void appendNoProblems(StringBuffer buf); public abstract T getExtension(Key key); -} \ No newline at end of file +} diff --git a/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionEP.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java rename to platform/analysis-api/src/com/intellij/codeInspection/InspectionEP.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/LocalInspectionEP.java b/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionEP.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/LocalInspectionEP.java rename to platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionEP.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/ProblemDescriptionsProcessor.java b/platform/analysis-api/src/com/intellij/codeInspection/ProblemDescriptionsProcessor.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/ProblemDescriptionsProcessor.java rename to platform/analysis-api/src/com/intellij/codeInspection/ProblemDescriptionsProcessor.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/ex/JobDescriptor.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/JobDescriptor.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/ex/JobDescriptor.java rename to platform/analysis-api/src/com/intellij/codeInspection/ex/JobDescriptor.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/ex/ScopeToolState.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java similarity index 90% rename from platform/lang-api/src/com/intellij/codeInspection/ex/ScopeToolState.java rename to platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java index 1fd9ce7ccb78..ff09859ba02d 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/ex/ScopeToolState.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java @@ -22,8 +22,6 @@ package com.intellij.codeInspection.ex; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInspection.InspectionProfileEntry; -import com.intellij.ide.DataManager; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.JDOMUtil; @@ -60,17 +58,6 @@ public class ScopeToolState { myLevel = level; } - @Nullable - public NamedScope getScope() { - if (myScope == null) { - final Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()); - if (project != null) { - myScope = NamedScopesHolder.getScope(project, myScopeName); - } - } - return myScope; - } - @Nullable public NamedScope getScope(Project project) { if (myScope == null) { diff --git a/platform/lang-api/src/com/intellij/codeInspection/ex/Tools.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/Tools.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/ex/Tools.java rename to platform/analysis-api/src/com/intellij/codeInspection/ex/Tools.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/EntryPoint.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/EntryPoint.java similarity index 99% rename from platform/lang-api/src/com/intellij/codeInspection/reference/EntryPoint.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/EntryPoint.java index 6ee0c0ddd26b..464ab9add995 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/reference/EntryPoint.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/EntryPoint.java @@ -55,4 +55,4 @@ public abstract class EntryPoint implements JDOMExternalizable , Cloneable { } return clone; } -} \ No newline at end of file +} diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefDirectory.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefDirectory.java similarity index 99% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefDirectory.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefDirectory.java index a8f2b08ec4e6..e5e44f19fc85 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/reference/RefDirectory.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefDirectory.java @@ -21,4 +21,4 @@ package com.intellij.codeInspection.reference; public interface RefDirectory extends RefElement { -} \ No newline at end of file +} diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefElement.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefElement.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefElement.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefElement.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefEntity.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefEntity.java similarity index 94% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefEntity.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefEntity.java index d7ef3e2ab1d3..0b3923abc2b3 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/reference/RefEntity.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefEntity.java @@ -16,6 +16,7 @@ package com.intellij.codeInspection.reference; import com.intellij.openapi.util.UserDataHolder; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -34,8 +35,10 @@ public interface RefEntity extends UserDataHolder { * * @return the name of the node. */ + @NotNull String getName(); + @NotNull String getQualifiedName(); /** @@ -57,7 +60,7 @@ public interface RefEntity extends UserDataHolder { * * @param refVisitor the visitor to accept. */ - void accept(final RefVisitor refVisitor); + void accept(@NotNull RefVisitor refVisitor); /** * Returns a user-readable name for the element corresponding to the node. @@ -78,6 +81,7 @@ public interface RefEntity extends UserDataHolder { * * @return the reference graph element for the instance. */ + @NotNull RefManager getRefManager(); @Nullable diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefFile.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefFile.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefFile.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefFile.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefGraphAnnotator.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefGraphAnnotator.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefGraphAnnotator.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefGraphAnnotator.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefGraphAnnotatorEx.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefGraphAnnotatorEx.java similarity index 99% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefGraphAnnotatorEx.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefGraphAnnotatorEx.java index 0d4bce9c2ee6..64fe26879e01 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/reference/RefGraphAnnotatorEx.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefGraphAnnotatorEx.java @@ -22,4 +22,4 @@ public class RefGraphAnnotatorEx extends RefGraphAnnotator { */ public void initialize(RefManager refManager) { } -} \ No newline at end of file +} diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefManager.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefManager.java similarity index 93% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefManager.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefManager.java index 584bb517b7fa..fd3fc5ff7d7d 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/reference/RefManager.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefManager.java @@ -22,6 +22,7 @@ import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiManager; import org.jdom.Element; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -39,7 +40,7 @@ public abstract class RefManager { * * @param visitor the visitor to run. */ - public abstract void iterate(RefVisitor visitor); + public abstract void iterate(@NotNull RefVisitor visitor); /** * Returns the analysis scope for which the reference graph has been built. @@ -53,6 +54,7 @@ public abstract class RefManager { * * @return the project instance. */ + @NotNull public abstract Project getProject(); /** @@ -61,6 +63,7 @@ public abstract class RefManager { * * @return the node for the project. */ + @NotNull public abstract RefProject getRefProject(); /** @@ -85,7 +88,7 @@ public abstract class RefManager { /** * Creates (if necessary) and returns the reference graph node for the PSI element specified by its type and FQName. * - * @param type {@link SmartRefElementPointer.FILE, etc.} + * @param type {@link SmartRefElementPointer#FILE, etc.} * @param fqName fully qualified name for the element * @return the node for the element, or null if the element is not found or does not have * a corresponding reference graph node type. @@ -95,7 +98,7 @@ public abstract class RefManager { public abstract int getLastUsedMask(); - public abstract T getExtension(Key key); + public abstract T getExtension(@NotNull Key key); @Nullable public abstract String getType(final RefEntity ref); @@ -113,5 +116,6 @@ public abstract class RefManager { public abstract void removeRefElement(RefElement refElement, List deletedRefs); + @NotNull public abstract PsiManager getPsiManager(); } diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefModule.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefModule.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefModule.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefModule.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefProject.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefProject.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefProject.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefProject.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefUtil.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefUtil.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefUtil.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefUtil.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/RefVisitor.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefVisitor.java similarity index 99% rename from platform/lang-api/src/com/intellij/codeInspection/reference/RefVisitor.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/RefVisitor.java index 1ef03f260035..a5f84a97ec1c 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/reference/RefVisitor.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefVisitor.java @@ -36,4 +36,4 @@ public class RefVisitor { public void visitDirectory(@NotNull RefDirectory directory) { visitElement(directory); } -} \ No newline at end of file +} diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/SmartRefElementPointer.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/SmartRefElementPointer.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/reference/SmartRefElementPointer.java rename to platform/analysis-api/src/com/intellij/codeInspection/reference/SmartRefElementPointer.java diff --git a/platform/analysis-api/src/com/intellij/profile/DefaultProjectProfileManager.java b/platform/analysis-api/src/com/intellij/profile/DefaultProjectProfileManager.java index 713b96fda95d..1ccdade0cb78 100644 --- a/platform/analysis-api/src/com/intellij/profile/DefaultProjectProfileManager.java +++ b/platform/analysis-api/src/com/intellij/profile/DefaultProjectProfileManager.java @@ -71,6 +71,7 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager LOG.assertTrue(myApplicationProfileManager != null); } + @NotNull public Project getProject() { return myProject; } diff --git a/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java b/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java new file mode 100644 index 000000000000..a8f2bd1f7a8c --- /dev/null +++ b/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java @@ -0,0 +1,220 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.search; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectFileIndex; +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiBundle; +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiManager; +import com.intellij.psi.search.scope.packageSet.*; +import org.jetbrains.annotations.NotNull; + +public class GlobalSearchScopesCore { + @NotNull + public static GlobalSearchScope projectProductionScope(@NotNull Project project) { + return new ProductionScopeFilter(project); + } + + @NotNull + public static GlobalSearchScope projectTestScope(@NotNull Project project) { + return new TestScopeFilter(project); + } + + @NotNull + public static GlobalSearchScope directoryScope(@NotNull PsiDirectory directory, final boolean withSubdirectories) { + return new DirectoryScope(directory, withSubdirectories); + } + + @NotNull + public static GlobalSearchScope directoryScope(@NotNull Project project, @NotNull VirtualFile directory, final boolean withSubdirectories) { + return new DirectoryScope(project, directory, withSubdirectories); + } + + public static GlobalSearchScope filterScope(@NotNull Project project, @NotNull NamedScope set) { + return new FilterScopeAdapter(project, set); + } + + private static class FilterScopeAdapter extends GlobalSearchScope { + private final NamedScope mySet; + private final PsiManager myManager; + + private FilterScopeAdapter(@NotNull Project project, @NotNull NamedScope set) { + super(project); + mySet = set; + myManager = PsiManager.getInstance(project); + } + + @Override + public boolean contains(VirtualFile file) { + Project project = getProject(); + NamedScopesHolder holder = NamedScopeManager.getInstance(project); + final PackageSet packageSet = mySet.getValue(); + if (packageSet != null) { + if (packageSet instanceof PackageSetBase) return ((PackageSetBase)packageSet).contains(file, project, holder); + PsiFile psiFile = myManager.findFile(file); + return psiFile != null && packageSet.contains(psiFile, holder); + } + return false; + } + + @Override + public String getDisplayName() { + return mySet.getName(); + } + + @Override + public int compare(VirtualFile file1, VirtualFile file2) { + return 0; + + } + + @Override + public boolean isSearchInModuleContent(@NotNull Module aModule) { + return true; //TODO (optimization?) + } + + @Override + public boolean isSearchInLibraries() { + return true; //TODO (optimization?) + } + } + + private static class ProductionScopeFilter extends GlobalSearchScope { + private final ProjectFileIndex myFileIndex; + + private ProductionScopeFilter(@NotNull Project project) { + super(project); + myFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); + } + + @Override + public boolean contains(VirtualFile file) { + return myFileIndex.isInSourceContent(file) && !myFileIndex.isInTestSourceContent(file); + } + + @Override + public int compare(VirtualFile file1, VirtualFile file2) { + return 0; + } + + @Override + public boolean isSearchInModuleContent(@NotNull Module aModule) { + return true; + } + + @Override + public boolean isSearchInModuleContent(@NotNull final Module aModule, final boolean testSources) { + return !testSources; + } + + @Override + public boolean isSearchInLibraries() { + return false; + } + + @Override + public String getDisplayName() { + return PsiBundle.message("psi.search.scope.production.files"); + } + } + + private static class TestScopeFilter extends GlobalSearchScope { + private final ProjectFileIndex myFileIndex; + + private TestScopeFilter(@NotNull Project project) { + super(project); + myFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); + } + + @Override + public boolean contains(VirtualFile file) { + return myFileIndex.isInTestSourceContent(file); + } + + @Override + public int compare(VirtualFile file1, VirtualFile file2) { + return 0; + } + + @Override + public boolean isSearchInModuleContent(@NotNull Module aModule) { + return true; + } + + @Override + public boolean isSearchInModuleContent(@NotNull final Module aModule, final boolean testSources) { + return testSources; + } + + @Override + public boolean isSearchInLibraries() { + return false; + } + + @Override + public String getDisplayName() { + return PsiBundle.message("psi.search.scope.test.files"); + } + } + + private static class DirectoryScope extends GlobalSearchScope { + private final VirtualFile myDirectory; + private final boolean myWithSubdirectories; + + private DirectoryScope(@NotNull PsiDirectory directory, final boolean withSubdirectories) { + super(directory.getProject()); + myWithSubdirectories = withSubdirectories; + myDirectory = directory.getVirtualFile(); + } + + private DirectoryScope(@NotNull Project project, @NotNull VirtualFile directory, final boolean withSubdirectories) { + super(project); + myWithSubdirectories = withSubdirectories; + myDirectory = directory; + } + + @Override + public boolean contains(VirtualFile file) { + return myWithSubdirectories ? VfsUtilCore.isAncestor(myDirectory, file, false) : myDirectory.equals(file.getParent()); + } + + @Override + public int compare(VirtualFile file1, VirtualFile file2) { + return 0; + } + + @Override + public boolean isSearchInModuleContent(@NotNull Module aModule) { + return true; + } + + @Override + public boolean isSearchInLibraries() { + return false; + } + + public String toString() { + //noinspection HardCodedStringLiteral + return "directory scope: " + myDirectory + "; withSubdirs:"+myWithSubdirectories; + } + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java similarity index 85% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java index e4a96c447d52..d5d456163f09 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java @@ -200,45 +200,4 @@ public interface HighlightInfoType { return myToolKey; } } - - class HighlightInfoTypeSeverityByKeyAttrBySeverity implements HighlightInfoType { - static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.HighlightInfoType.HighlightInfoTypeSeverityByKeyAttrBySeverity"); - - private final HighlightDisplayKey mySeverityKey; - - public HighlightInfoTypeSeverityByKeyAttrBySeverity(HighlightDisplayKey severityKey) { - mySeverityKey = severityKey; - } - - @Override - @NotNull - public HighlightSeverity getSeverity(final PsiElement psiElement) { - InspectionProfile profile = psiElement == null - ? (InspectionProfile)InspectionProfileManager.getInstance().getRootProfile() - : InspectionProjectProfileManager.getInstance(psiElement.getProject()).getInspectionProfile(); - HighlightDisplayLevel level = profile.getErrorLevel(mySeverityKey, psiElement); - LOG.assertTrue(level != HighlightDisplayLevel.DO_NOT_SHOW); - return level.getSeverity(); - } - - @Override - public TextAttributesKey getAttributesKey() { - final HighlightSeverity severity = getSeverity(null); - final HighlightInfoTypeImpl infoType = SeverityRegistrar.getInstance().getHighlightInfoTypeBySeverity(severity); - return infoType != null - ? infoType.getAttributesKey() - : severity == HighlightSeverity.ERROR - ? CodeInsightColors.ERRORS_ATTRIBUTES - : severity == HighlightSeverity.WARNING - ? CodeInsightColors.WARNINGS_ATTRIBUTES - : severity == HighlightSeverity.WEAK_WARNING - ? CodeInsightColors.WEAK_WARNING_ATTRIBUTES - : CodeInsightColors.INFO_ATTRIBUTES; - } - - @SuppressWarnings({"HardCodedStringLiteral"}) - public String toString() { - return "HighlightInfoTypeSeverityByKeyAttrBySeverity[severity=" + mySeverityKey + "]"; - } - } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeveritiesProvider.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeveritiesProvider.java similarity index 100% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeveritiesProvider.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeveritiesProvider.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java similarity index 71% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java index b11864b912e1..52e964c2f510 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java @@ -18,20 +18,12 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.lang.annotation.HighlightSeverity; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.project.Project; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizable; import com.intellij.openapi.util.JDOMExternalizableStringList; import com.intellij.openapi.util.WriteExternalException; -import com.intellij.profile.codeInspection.InspectionProfileManager; -import com.intellij.profile.codeInspection.InspectionProfileManagerImpl; -import com.intellij.profile.codeInspection.InspectionProjectProfileManager; -import com.intellij.profile.codeInspection.InspectionProjectProfileManagerImpl; import com.intellij.util.containers.ContainerUtil; import gnu.trove.THashMap; import gnu.trove.TObjectIntHashMap; @@ -52,8 +44,8 @@ import java.util.List; */ public class SeverityRegistrar implements JDOMExternalizable, Comparator { @NonNls private static final String INFO = "info"; - private final Map ourMap = new THashMap(); - private final Map ourRendererColors = new THashMap(); + private final Map myMap = new THashMap(); + private final Map myRendererColors = new THashMap(); @NonNls private static final String COLOR = "color"; private final OrderMap myOrder = new OrderMap(); @@ -61,64 +53,32 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator STANDARD_SEVERITIES = new THashMap(); + public SeverityRegistrar() { + } + static { - STANDARD_SEVERITIES.put(HighlightSeverity.ERROR.toString(), HighlightInfoType.ERROR); - STANDARD_SEVERITIES.put(HighlightSeverity.WARNING.toString(), HighlightInfoType.WARNING); - STANDARD_SEVERITIES.put(HighlightSeverity.INFO.toString(), HighlightInfoType.INFO); - STANDARD_SEVERITIES.put(HighlightSeverity.WEAK_WARNING.toString(), HighlightInfoType.WEAK_WARNING); - STANDARD_SEVERITIES.put(HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING.toString(), HighlightInfoType.GENERIC_WARNINGS_OR_ERRORS_FROM_SERVER); - final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); - for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) { - for (HighlightInfoType highlightInfoType : provider.getSeveritiesHighlightInfoTypes()) { - final HighlightSeverity highlightSeverity = highlightInfoType.getSeverity(null); - STANDARD_SEVERITIES.put(highlightSeverity.toString(), highlightInfoType); - final TextAttributesKey attributesKey = highlightInfoType.getAttributesKey(); - TextAttributes textAttributes = scheme.getAttributes(attributesKey); - if (textAttributes == null) { - textAttributes = attributesKey.getDefaultAttributes(); - } - HighlightDisplayLevel.registerSeverity(highlightSeverity, provider.getTrafficRendererColor(textAttributes)); - } - } + registerStandard(HighlightInfoType.ERROR, HighlightSeverity.ERROR); + registerStandard(HighlightInfoType.WARNING, HighlightSeverity.WARNING); + registerStandard(HighlightInfoType.INFO, HighlightSeverity.INFO); + registerStandard(HighlightInfoType.WEAK_WARNING, HighlightSeverity.WEAK_WARNING); + registerStandard(HighlightInfoType.GENERIC_WARNINGS_OR_ERRORS_FROM_SERVER, HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING); } - public static SeverityRegistrar getInstance() { - return ((InspectionProfileManagerImpl)InspectionProfileManager.getInstance()).getSeverityRegistrar(); - } - - public static SeverityRegistrar getInstance(@Nullable Project project) { - return project != null ? InspectionProjectProfileManagerImpl.getInstanceImpl(project).getSeverityRegistrar() : getInstance(); + public static void registerStandard(@NotNull HighlightInfoType highlightInfoType, @NotNull HighlightSeverity highlightSeverity) { + STANDARD_SEVERITIES.put(highlightSeverity.toString(), highlightInfoType); } public void registerSeverity(@NotNull SeverityBasedTextAttributes info, Color renderColor){ final HighlightSeverity severity = info.getType().getSeverity(null); - ourMap.put(severity.toString(), info); - ourRendererColors.put(severity.toString(), renderColor); + myMap.put(severity.toString(), info); + myRendererColors.put(severity.toString(), renderColor); myOrder.clear(); HighlightDisplayLevel.registerSeverity(severity, renderColor); } - @NotNull - public Collection getRegisteredHighlightingInfoTypes() { - final Collection collection = new ArrayList(ourMap.values()); - for (HighlightInfoType type : STANDARD_SEVERITIES.values()) { - collection.add(getSeverityBasedTextAttributes(type)); - } - return collection; - } - - private SeverityBasedTextAttributes getSeverityBasedTextAttributes(@NotNull HighlightInfoType type) { - final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); - final TextAttributes textAttributes = scheme.getAttributes(type.getAttributesKey()); - if (textAttributes != null) { - return new SeverityBasedTextAttributes(textAttributes, (HighlightInfoType.HighlightInfoTypeImpl)type); - } - return new SeverityBasedTextAttributes(getTextAttributesBySeverity(type.getSeverity(null)), (HighlightInfoType.HighlightInfoTypeImpl)type); - } - public SeverityBasedTextAttributes unregisterSeverity(@NotNull HighlightSeverity severity){ - return ourMap.remove(severity.toString()); + return myMap.remove(severity.toString()); } @NotNull @@ -132,13 +92,13 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator createCurrentSeverities() { List list = new ArrayList(); list.addAll(STANDARD_SEVERITIES.keySet()); - list.addAll(ourMap.keySet()); + list.addAll(myMap.keySet()); ContainerUtil.sort(list); return list; } @@ -301,7 +259,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator getDefaultOrder() { - Collection values = ourMap.values(); + Collection values = myMap.values(); List order = new ArrayList(STANDARD_SEVERITIES.size() + values.size()); for (HighlightInfoType type : STANDARD_SEVERITIES.values()) { order.add(type.getSeverity(null)); @@ -368,6 +326,13 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator { + private int getOrder(@NotNull HighlightSeverity severity, int defaultOrder) { + int index = index(severity); + return index < 0 ? defaultOrder : _values[index]; + } + } + public static class SeverityBasedTextAttributes implements JDOMExternalizable { private final TextAttributes myAttributes; private final HighlightInfoType.HighlightInfoTypeImpl myType; @@ -426,10 +391,13 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator { - private int getOrder(@NotNull HighlightSeverity severity, int defaultOrder) { - int index = index(severity); - return index < 0 ? defaultOrder : _values[index]; - } + @NotNull + Collection allRegisteredAttributes() { + return new ArrayList(myMap.values()); } + @NotNull + Collection standardSeverities() { + return STANDARD_SEVERITIES.values(); + } + } diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/SeverityProvider.java b/platform/analysis-impl/src/com/intellij/profile/codeInspection/SeverityProvider.java similarity index 100% rename from platform/lang-impl/src/com/intellij/profile/codeInspection/SeverityProvider.java rename to platform/analysis-impl/src/com/intellij/profile/codeInspection/SeverityProvider.java diff --git a/platform/core-api/src/com/intellij/codeInsight/FileModificationService.java b/platform/core-api/src/com/intellij/codeInsight/FileModificationService.java index 680ea24d09fa..f10d55c71fa9 100644 --- a/platform/core-api/src/com/intellij/codeInsight/FileModificationService.java +++ b/platform/core-api/src/com/intellij/codeInsight/FileModificationService.java @@ -16,6 +16,8 @@ package com.intellij.codeInsight; import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; @@ -40,4 +42,6 @@ public abstract class FileModificationService { public boolean preparePsiElementsForWrite(@NotNull PsiElement... elements) { return preparePsiElementsForWrite(Arrays.asList(elements)); } + + public abstract boolean prepareVirtualFilesForWrite(@NotNull Project project, @NotNull Collection files); } diff --git a/platform/platform-api/src/com/intellij/ide/plugins/HelpSetPath.java b/platform/core-api/src/com/intellij/ide/plugins/HelpSetPath.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/plugins/HelpSetPath.java rename to platform/core-api/src/com/intellij/ide/plugins/HelpSetPath.java diff --git a/platform/platform-api/src/com/intellij/ide/plugins/IdeaPluginDescriptor.java b/platform/core-api/src/com/intellij/ide/plugins/IdeaPluginDescriptor.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/plugins/IdeaPluginDescriptor.java rename to platform/core-api/src/com/intellij/ide/plugins/IdeaPluginDescriptor.java diff --git a/platform/platform-api/src/com/intellij/lang/LanguageExtensionPoint.java b/platform/core-api/src/com/intellij/lang/LanguageExtensionPoint.java similarity index 99% rename from platform/platform-api/src/com/intellij/lang/LanguageExtensionPoint.java rename to platform/core-api/src/com/intellij/lang/LanguageExtensionPoint.java index 318a31ea3d29..6a3fbbf39328 100644 --- a/platform/platform-api/src/com/intellij/lang/LanguageExtensionPoint.java +++ b/platform/core-api/src/com/intellij/lang/LanguageExtensionPoint.java @@ -56,4 +56,4 @@ public class LanguageExtensionPoint extends CustomLoadingExtensionPointBean i public String getKey() { return language; } -} \ No newline at end of file +} diff --git a/platform/lang-api/src/com/intellij/analysis/AnalysisScopeUtil.java b/platform/lang-api/src/com/intellij/analysis/AnalysisScopeUtil.java new file mode 100644 index 000000000000..8f53d25b6bbd --- /dev/null +++ b/platform/lang-api/src/com/intellij/analysis/AnalysisScopeUtil.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.analysis; + +import com.intellij.openapi.actionSystem.DataKey; + +public class AnalysisScopeUtil { + public static final DataKey KEY = DataKey.create("analysisScope"); +} diff --git a/platform/lang-api/src/com/intellij/codeInspection/GlobalSimpleInspectionTool.java b/platform/lang-api/src/com/intellij/codeInspection/GlobalSimpleInspectionTool.java index d302b82b5f18..dd6fbf91f770 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/GlobalSimpleInspectionTool.java +++ b/platform/lang-api/src/com/intellij/codeInspection/GlobalSimpleInspectionTool.java @@ -38,10 +38,10 @@ public abstract class GlobalSimpleInspectionTool extends GlobalInspectionTool { @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor); @Override - public final void runInspection(AnalysisScope scope, - InspectionManager manager, - GlobalInspectionContext globalContext, - ProblemDescriptionsProcessor problemDescriptionsProcessor) { + public final void runInspection(@NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) { throw new IncorrectOperationException("You must override checkFile() instead"); } diff --git a/platform/lang-api/src/com/intellij/codeInspection/ex/ScopeToolStateUtil.java b/platform/lang-api/src/com/intellij/codeInspection/ex/ScopeToolStateUtil.java new file mode 100644 index 000000000000..099ed1dc0d47 --- /dev/null +++ b/platform/lang-api/src/com/intellij/codeInspection/ex/ScopeToolStateUtil.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInspection.ex; + +import com.intellij.ide.DataManager; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.project.Project; +import com.intellij.psi.search.scope.packageSet.NamedScope; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ScopeToolStateUtil { + @Nullable + public static NamedScope getScope(@NotNull ScopeToolState toolState) { + Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()); + return toolState.getScope(project); + } +} diff --git a/platform/lang-api/src/com/intellij/codeInspection/lang/RefManagerExtension.java b/platform/lang-api/src/com/intellij/codeInspection/lang/RefManagerExtension.java index d6c267251bf2..f129b5357771 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/lang/RefManagerExtension.java +++ b/platform/lang-api/src/com/intellij/codeInspection/lang/RefManagerExtension.java @@ -27,14 +27,17 @@ import com.intellij.lang.Language; import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; import org.jdom.Element; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public interface RefManagerExtension { + @NotNull Key getID(); + @NotNull Language getLanguage(); - void iterate(RefVisitor visitor); + void iterate(@NotNull RefVisitor visitor); void cleanup(); diff --git a/platform/lang-api/src/com/intellij/openapi/project/ProjectUtil.java b/platform/lang-api/src/com/intellij/openapi/project/ProjectUtil.java index 507ce096b74c..98d4ccd68385 100644 --- a/platform/lang-api/src/com/intellij/openapi/project/ProjectUtil.java +++ b/platform/lang-api/src/com/intellij/openapi/project/ProjectUtil.java @@ -21,14 +21,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileEditor.UniqueVFilePathBuilder; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.InternalFileType; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleUtil; -import com.intellij.openapi.roots.JdkOrderEntry; -import com.intellij.openapi.roots.OrderEntry; -import com.intellij.openapi.roots.libraries.LibraryUtil; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFilePathWrapper; import org.jetbrains.annotations.NonNls; @@ -66,7 +59,7 @@ public class ProjectUtil { final boolean keepModuleAlwaysOnTheLeft) { if (file instanceof VirtualFilePathWrapper) { return includeFilePath ? ((VirtualFilePathWrapper)file).getPresentablePath() : file.getName(); - } + } String url; if (includeFilePath) { url = file.getPresentableUrl(); @@ -81,36 +74,7 @@ public class ProjectUtil { return url; } else { - final VirtualFile baseDir = project.getBaseDir(); - if (baseDir != null && includeFilePath) { - //noinspection ConstantConditions - final String projectHomeUrl = baseDir.getPresentableUrl(); - if (url.startsWith(projectHomeUrl)) { - url = "..." + url.substring(projectHomeUrl.length()); - } - } - - if (SystemInfo.isMac && file.getFileSystem() instanceof JarFileSystem) { - final VirtualFile fileForJar = ((JarFileSystem)file.getFileSystem()).getVirtualFileForJar(file); - if (fileForJar != null) { - final OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(file, project); - if (libraryEntry != null) { - if (libraryEntry instanceof JdkOrderEntry) { - url = url + " - [" + ((JdkOrderEntry)libraryEntry).getJdkName() + "]"; - } else { - url = url + " - [" + libraryEntry.getPresentableName() + "]"; - } - } else { - url = url + " - [" + fileForJar.getName() + "]"; - } - } - } - - final Module module = ModuleUtil.findModuleForFile(file, project); - if (module == null) return url; - return !keepModuleAlwaysOnTheLeft && SystemInfo.isMac ? - url + " - [" + module.getName() + "]" : - "[" + module.getName() + "] - " + url; + return ProjectUtilCore.displayUrlRelativeToProject(file, url, project, includeFilePath, keepModuleAlwaysOnTheLeft); } } diff --git a/platform/lang-api/src/com/intellij/psi/search/GlobalSearchScopes.java b/platform/lang-api/src/com/intellij/psi/search/GlobalSearchScopes.java index 2ee705e8365f..3acfe338d499 100644 --- a/platform/lang-api/src/com/intellij/psi/search/GlobalSearchScopes.java +++ b/platform/lang-api/src/com/intellij/psi/search/GlobalSearchScopes.java @@ -16,17 +16,8 @@ package com.intellij.psi.search; import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ProjectFileIndex; -import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiBundle; -import com.intellij.psi.PsiDirectory; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiManager; -import com.intellij.psi.search.scope.packageSet.*; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -34,7 +25,7 @@ import java.util.Arrays; /** * @author yole */ -public class GlobalSearchScopes { +public class GlobalSearchScopes extends GlobalSearchScopesCore { private GlobalSearchScopes() { } @@ -43,193 +34,4 @@ public class GlobalSearchScopes { final VirtualFile[] files = FileEditorManager.getInstance(project).getOpenFiles(); return GlobalSearchScope.filesScope(project, Arrays.asList(files), "Open Files"); } - - @NotNull - public static GlobalSearchScope projectProductionScope(@NotNull Project project) { - return new ProductionScopeFilter(project); - } - - @NotNull - public static GlobalSearchScope projectTestScope(@NotNull Project project) { - return new TestScopeFilter(project); - } - - @NotNull - public static GlobalSearchScope directoryScope(@NotNull PsiDirectory directory, final boolean withSubdirectories) { - return new DirectoryScope(directory, withSubdirectories); - } - - @NotNull - public static GlobalSearchScope directoryScope(@NotNull Project project, @NotNull VirtualFile directory, final boolean withSubdirectories) { - return new DirectoryScope(project, directory, withSubdirectories); - } - - private static class FilterScopeAdapter extends GlobalSearchScope { - private final NamedScope mySet; - private final PsiManager myManager; - - private FilterScopeAdapter(@NotNull Project project, @NotNull NamedScope set) { - super(project); - mySet = set; - myManager = PsiManager.getInstance(project); - } - - @Override - public boolean contains(VirtualFile file) { - Project project = getProject(); - NamedScopesHolder holder = NamedScopeManager.getInstance(project); - final PackageSet packageSet = mySet.getValue(); - if (packageSet != null) { - if (packageSet instanceof PackageSetBase) return ((PackageSetBase)packageSet).contains(file, project, holder); - PsiFile psiFile = myManager.findFile(file); - return psiFile != null && packageSet.contains(psiFile, holder); - } - return false; - } - - @Override - public String getDisplayName() { - return mySet.getName(); - } - - @Override - public int compare(VirtualFile file1, VirtualFile file2) { - return 0; - - } - - @Override - public boolean isSearchInModuleContent(@NotNull Module aModule) { - return true; //TODO (optimization?) - } - - @Override - public boolean isSearchInLibraries() { - return true; //TODO (optimization?) - } - } - - public static GlobalSearchScope filterScope(@NotNull Project project, @NotNull NamedScope set) { - return new FilterScopeAdapter(project, set); - } - - private static class ProductionScopeFilter extends GlobalSearchScope { - private final ProjectFileIndex myFileIndex; - - private ProductionScopeFilter(@NotNull Project project) { - super(project); - myFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); - } - - @Override - public boolean contains(VirtualFile file) { - return myFileIndex.isInSourceContent(file) && !myFileIndex.isInTestSourceContent(file); - } - - @Override - public int compare(VirtualFile file1, VirtualFile file2) { - return 0; - } - - @Override - public boolean isSearchInModuleContent(@NotNull Module aModule) { - return true; - } - - @Override - public boolean isSearchInModuleContent(@NotNull final Module aModule, final boolean testSources) { - return !testSources; - } - - @Override - public boolean isSearchInLibraries() { - return false; - } - - @Override - public String getDisplayName() { - return PsiBundle.message("psi.search.scope.production.files"); - } - } - - private static class TestScopeFilter extends GlobalSearchScope { - private final ProjectFileIndex myFileIndex; - - private TestScopeFilter(@NotNull Project project) { - super(project); - myFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); - } - - @Override - public boolean contains(VirtualFile file) { - return myFileIndex.isInTestSourceContent(file); - } - - @Override - public int compare(VirtualFile file1, VirtualFile file2) { - return 0; - } - - @Override - public boolean isSearchInModuleContent(@NotNull Module aModule) { - return true; - } - - @Override - public boolean isSearchInModuleContent(@NotNull final Module aModule, final boolean testSources) { - return testSources; - } - - @Override - public boolean isSearchInLibraries() { - return false; - } - - @Override - public String getDisplayName() { - return PsiBundle.message("psi.search.scope.test.files"); - } - } - - private static class DirectoryScope extends GlobalSearchScope { - private final VirtualFile myDirectory; - private final boolean myWithSubdirectories; - - private DirectoryScope(@NotNull PsiDirectory directory, final boolean withSubdirectories) { - super(directory.getProject()); - myWithSubdirectories = withSubdirectories; - myDirectory = directory.getVirtualFile(); - } - - private DirectoryScope(@NotNull Project project, @NotNull VirtualFile directory, final boolean withSubdirectories) { - super(project); - myWithSubdirectories = withSubdirectories; - myDirectory = directory; - } - - @Override - public boolean contains(VirtualFile file) { - return myWithSubdirectories ? VfsUtilCore.isAncestor(myDirectory, file, false) : myDirectory.equals(file.getParent()); - } - - @Override - public int compare(VirtualFile file1, VirtualFile file2) { - return 0; - } - - @Override - public boolean isSearchInModuleContent(@NotNull Module aModule) { - return true; - } - - @Override - public boolean isSearchInLibraries() { - return false; - } - - public String toString() { - //noinspection HardCodedStringLiteral - return "directory scope: " + myDirectory + "; withSubdirs:"+myWithSubdirectories; - } - } } diff --git a/platform/lang-impl/src/com/intellij/analysis/BaseAnalysisAction.java b/platform/lang-impl/src/com/intellij/analysis/BaseAnalysisAction.java index e9cb78e3a864..c6ffa8e35d58 100644 --- a/platform/lang-impl/src/com/intellij/analysis/BaseAnalysisAction.java +++ b/platform/lang-impl/src/com/intellij/analysis/BaseAnalysisAction.java @@ -144,7 +144,7 @@ public abstract class BaseAnalysisAction extends AnAction { return new AnalysisScope(projectContext); } - final AnalysisScope analysisScope = AnalysisScope.KEY.getData(dataContext); + final AnalysisScope analysisScope = AnalysisScopeUtil.KEY.getData(dataContext); if (analysisScope != null) { return analysisScope; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightUtilBase.java b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightUtilBase.java index 3c430fa47973..f788b0478a33 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightUtilBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightUtilBase.java @@ -100,6 +100,12 @@ public class CodeInsightUtilBase extends CodeInsightUtilCore { return true; } + @Override + public boolean prepareVirtualFilesForWrite(@NotNull Project project, @NotNull Collection files) { + ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); + return !status.hasReadonlyFiles(); + } + // returns true on success public static boolean prepareEditorForWrite(@NotNull Editor editor) { if (!editor.isViewer()) return true; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java index 33a8ceefb76b..94cba5493be4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java @@ -539,7 +539,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx @NotNull final Processor processor) { LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed()); - final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); + final SeverityRegistrar severityRegistrar = SeverityUtil.getSeverityRegistrar(project); MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true); return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor() { @Override @@ -562,7 +562,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx @NotNull final Processor processor) { LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed()); - final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); + final SeverityRegistrar severityRegistrar = SeverityUtil.getSeverityRegistrar(project); MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true); return model.processRangeHighlightersOutside(startOffset, endOffset, new Processor() { @Override diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java index 4ded193ba905..a6b6dcbd4c1b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java @@ -84,7 +84,7 @@ public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererP ContainerUtil.quickSort(infos, new Comparator() { @Override public int compare(final HighlightInfo o1, final HighlightInfo o2) { - int i = SeverityRegistrar.getInstance(myProject).compare(o2.getSeverity(), o1.getSeverity()); + int i = SeverityUtil.getSeverityRegistrar(myProject).compare(o2.getSeverity(), o1.getSeverity()); if (i != 0) return i; return o1.getToolTip().compareTo(o2.getToolTip()); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java index a306fe807116..1831fa93de78 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java @@ -51,7 +51,7 @@ public class GotoNextErrorHandler implements CodeInsightActionHandler { } private void gotoNextError(Project project, Editor editor, PsiFile file, int caretOffset) { - final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); + final SeverityRegistrar severityRegistrar = SeverityUtil.getSeverityRegistrar(project); DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance(); int maxSeverity = settings.NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST ? severityRegistrar.getSeveritiesCount() - 1 : 0; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java index 77ee703d4fcd..4be279f2c328 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java @@ -189,7 +189,8 @@ public class HighlightInfo implements Segment { public static TextAttributes getAttributesByType(@Nullable final PsiElement element, @NotNull HighlightInfoType type, @NotNull EditorColorsScheme colorsScheme) { - final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(element != null ? element.getProject() : null); + final SeverityRegistrar severityRegistrar = SeverityUtil + .getSeverityRegistrar(element != null ? element.getProject() : null); final TextAttributes textAttributes = severityRegistrar.getTextAttributesBySeverity(type.getSeverity(element)); if (textAttributes != null) { return textAttributes; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityUtil.java new file mode 100644 index 000000000000..6faadd215ff3 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityUtil.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl; + +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.project.Project; +import com.intellij.profile.codeInspection.InspectionProfileManager; +import com.intellij.profile.codeInspection.InspectionProfileManagerImpl; +import com.intellij.profile.codeInspection.InspectionProjectProfileManagerImpl; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; + +public class SeverityUtil { + @NotNull + public static Collection getRegisteredHighlightingInfoTypes(@NotNull SeverityRegistrar registrar) { + Collection collection = registrar.allRegisteredAttributes(); + for (HighlightInfoType type : registrar.standardSeverities()) { + collection.add(getSeverityBasedTextAttributes(registrar, type)); + } + return collection; + } + + private static SeverityRegistrar.SeverityBasedTextAttributes getSeverityBasedTextAttributes(@NotNull SeverityRegistrar registrar, @NotNull HighlightInfoType type) { + final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); + final TextAttributes textAttributes = scheme.getAttributes(type.getAttributesKey()); + if (textAttributes != null) { + return new SeverityRegistrar.SeverityBasedTextAttributes(textAttributes, (HighlightInfoType.HighlightInfoTypeImpl)type); + } + return new SeverityRegistrar.SeverityBasedTextAttributes(registrar.getTextAttributesBySeverity(type.getSeverity(null)), (HighlightInfoType.HighlightInfoTypeImpl)type); + } + + @NotNull + public static SeverityRegistrar getSeverityRegistrar(@Nullable Project project) { + return project == null + ? ((InspectionProfileManagerImpl)InspectionProfileManager.getInstance()).getSeverityRegistrar() + : InspectionProjectProfileManagerImpl.getInstanceImpl(project).getSeverityRegistrar(); + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java index 00da39ec8407..3f8e595fbcfc 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java @@ -80,7 +80,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable { myDaemonCodeAnalyzer = project == null ? null : (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project); myDocument = document; myFile = file; - mySeverityRegistrar = SeverityRegistrar.getInstance(myProject); + mySeverityRegistrar = SeverityUtil.getSeverityRegistrar(myProject); refresh(); if (project != null) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java index fb39014811f3..0a85456c743c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java @@ -224,7 +224,7 @@ public class TrafficProgressPanel extends JPanel { String text = ""; for (int i = status.errorCount.length - 1; i >= 0; i--) { if (status.errorCount[i] > 0) { - final HighlightSeverity severity = SeverityRegistrar.getInstance(myTrafficLightRenderer.getProject()).getSeverityByIndex(i); + final HighlightSeverity severity = SeverityUtil.getSeverityRegistrar(myTrafficLightRenderer.getProject()).getSeverityByIndex(i); String name = status.errorCount[i] > 1 ? StringUtil.pluralize(severity.toString().toLowerCase()) : severity.toString().toLowerCase(); text += status.errorAnalyzingFinished diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficTooltipRendererImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficTooltipRendererImpl.java index dc71bcbbc14e..98ef16311c6c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficTooltipRendererImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficTooltipRendererImpl.java @@ -47,7 +47,7 @@ public class TrafficTooltipRendererImpl extends ComparableObject.Impl implements @Override public void repaintTooltipWindow() { if (myPanel != null) { - SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(myTrafficLightRenderer.getProject()); + SeverityRegistrar severityRegistrar = SeverityUtil.getSeverityRegistrar(myTrafficLightRenderer.getProject()); TrafficLightRenderer.DaemonCodeAnalyzerStatus status = myTrafficLightRenderer.getDaemonCodeAnalyzerStatus(true, severityRegistrar); myPanel.updatePanel(status, false); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java index f205399fd31d..ba25f6289084 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java @@ -163,7 +163,7 @@ public class UpdateHighlightersUtil { if (info.getStartOffset() < startOffset || info.getEndOffset() > endOffset) return; MarkupModel markup = DocumentMarkupModel.forDocument(document, project, true); - final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); + final SeverityRegistrar severityRegistrar = SeverityUtil.getSeverityRegistrar(project); final boolean myInfoIsError = isSevere(info, severityRegistrar); Processor otherHighlightInTheWayProcessor = new Processor() { @Override @@ -235,7 +235,7 @@ public class UpdateHighlightersUtil { final MarkupModel markup = DocumentMarkupModel.forDocument(document, project, true); assertMarkupConsistent(markup, project); - final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); + final SeverityRegistrar severityRegistrar = SeverityUtil.getSeverityRegistrar(project); final HighlightersRecycler infosToRemove = new HighlightersRecycler(); ContainerUtil.quickSort(infos, BY_START_OFFSET_NODUPS); @@ -308,7 +308,7 @@ public class UpdateHighlightersUtil { final int group) { ApplicationManager.getApplication().assertIsDispatchThread(); - final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); + final SeverityRegistrar severityRegistrar = SeverityUtil.getSeverityRegistrar(project); final HighlightersRecycler infosToRemove = new HighlightersRecycler(); DaemonCodeAnalyzerImpl.processHighlights(document, project, null, range.getStartOffset(), range.getEndOffset(), new Processor() { @Override diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/FileLevelIntentionComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/FileLevelIntentionComponent.java index 009ca7f10a0e..f912221943c9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/FileLevelIntentionComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/FileLevelIntentionComponent.java @@ -17,7 +17,7 @@ package com.intellij.codeInsight.intention.impl; import com.intellij.codeInsight.daemon.impl.HighlightInfo; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.codeInsight.daemon.impl.ShowIntentionsPass; import com.intellij.codeInsight.intention.EmptyIntentionAction; import com.intellij.codeInsight.intention.IntentionAction; @@ -72,7 +72,7 @@ public class FileLevelIntentionComponent extends EditorNotificationPanel { } myLabel.setText(description); - myLabel.setIcon(SeverityRegistrar.getInstance(project).compare(severity, HighlightSeverity.ERROR) >= 0 ? AllIcons.Actions.QuickfixBulb : AllIcons.Actions.IntentionBulb); + myLabel.setIcon(SeverityUtil.getSeverityRegistrar(project).compare(severity, HighlightSeverity.ERROR) >= 0 ? AllIcons.Actions.QuickfixBulb : AllIcons.Actions.IntentionBulb); new ClickListener() { @Override @@ -97,11 +97,11 @@ public class FileLevelIntentionComponent extends EditorNotificationPanel { } private Color getColor(HighlightSeverity severity) { - if (SeverityRegistrar.getInstance(myProject).compare(severity, HighlightSeverity.ERROR) >= 0) { + if (SeverityUtil.getSeverityRegistrar(myProject).compare(severity, HighlightSeverity.ERROR) >= 0) { return LightColors.RED; } - if (SeverityRegistrar.getInstance(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) { + if (SeverityUtil.getSeverityRegistrar(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) { return LightColors.YELLOW; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java index 2f39fd568d4c..dac36ac1d258 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java @@ -44,18 +44,18 @@ public class Descriptor { private final ScopeToolState myState; private final InspectionProfileImpl myInspectionProfile; - public Descriptor(ScopeToolState pair, InspectionProfileImpl inspectionProfile) { - myState = pair; + public Descriptor(@NotNull ScopeToolState state, @NotNull InspectionProfileImpl inspectionProfile) { + myState = state; myInspectionProfile = inspectionProfile; - final InspectionProfileEntry tool = pair.getTool(); + final InspectionProfileEntry tool = state.getTool(); myText = tool.getDisplayName(); final String[] groupPath = tool.getGroupPath(); myGroup = groupPath.length == 0 ? new String[]{InspectionProfileEntry.GENERAL_GROUP_NAME} : groupPath; myKey = HighlightDisplayKey.find(tool.getShortName()); - myLevel = inspectionProfile.getErrorLevel(myKey, pair.getScope()); - myEnabled = inspectionProfile.isToolEnabled(myKey, pair.getScope()); + myLevel = inspectionProfile.getErrorLevel(myKey, ScopeToolStateUtil.getScope(state)); + myEnabled = inspectionProfile.isToolEnabled(myKey, ScopeToolStateUtil.getScope(state)); myTool = tool; - myScope = pair.getScope(); + myScope = ScopeToolStateUtil.getScope(state); } public boolean equals(Object obj) { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java index 225bb23d2a44..a0d62cff9c66 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java @@ -26,6 +26,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.util.text.CharArrayUtil; import com.intellij.injected.editor.VirtualFileWindow; +import org.jetbrains.annotations.NotNull; import java.net.MalformedURLException; import java.net.URL; @@ -69,7 +70,7 @@ public class DescriptorComposer extends HTMLComposerImpl { } } - protected void composeAdditionalDescription(final StringBuffer buf, final RefEntity refEntity) {} + protected void composeAdditionalDescription(@NotNull StringBuffer buf, @NotNull RefEntity refEntity) {} @Override public void compose(StringBuffer buf, RefEntity refElement, CommonProblemDescriptor descriptor) { @@ -123,7 +124,7 @@ public class DescriptorComposer extends HTMLComposerImpl { } } - protected void composeDescription(final CommonProblemDescriptor description, int i, StringBuffer buf, final RefEntity refElement) { + protected void composeDescription(@NotNull CommonProblemDescriptor description, int i, @NotNull StringBuffer buf, @NotNull RefEntity refElement) { PsiElement expression = description instanceof ProblemDescriptor ? ((ProblemDescriptor)description).getPsiElement() : null; StringBuffer anchor = new StringBuffer(); VirtualFile vFile = null; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java index 5e47b380ef51..9736683e111f 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java @@ -126,6 +126,7 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem } } + @NotNull public Collection getProblemDescriptors() { return getProblemToElements().keySet(); } @@ -143,7 +144,6 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem @Override public void ignoreElement(@NotNull final RefEntity refEntity) { - if (refEntity == null) return; getProblemElements().remove(refEntity); getQuickFixActions().remove(refEntity); } 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 e56386b5e52f..e8549bd7f37a 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -799,7 +799,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G return myTools; } - private void appendJobDescriptor(@NotNull JobDescriptor job) { + public void appendJobDescriptor(@NotNull JobDescriptor job) { if (!myJobDescriptors.contains(job)) { myJobDescriptors.add(job); job.setDoneAmount(0); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java index d4e9a1cd91eb..0ef2dac69269 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java @@ -75,9 +75,9 @@ public class GlobalInspectionToolWrapper extends InspectionToolWrapper> myInspectionToolFactories = new ArrayList>(); + private final List> myInspectionToolFactories = new ArrayList>(); private final AtomicBoolean myToolsAreInitialized = new AtomicBoolean(false); private final AtomicBoolean myInspectionComponentsLoaded = new AtomicBoolean(false); @@ -108,6 +108,7 @@ public class InspectionToolRegistrar { } } + @NotNull public static InspectionToolWrapper wrapTool(@NotNull InspectionProfileEntry profileEntry) { if (profileEntry instanceof InspectionToolWrapper) { return (InspectionToolWrapper)profileEntry; @@ -240,7 +241,7 @@ public class InspectionToolRegistrar { @Override public void run() { List tools = createTools(); - for (InspectionTool tool : tools) { + for (InspectionToolWrapper tool : tools) { processText(tool.getDisplayName().toLowerCase(), tool); final String description = tool.loadDescription(); @@ -254,7 +255,7 @@ public class InspectionToolRegistrar { } } - private void processText(@NotNull @NonNls String descriptionText, @NotNull InspectionTool tool) { + private void processText(@NotNull @NonNls String descriptionText, @NotNull InspectionToolWrapper tool) { if (ApplicationManager.getApplication().isDisposed()) return; LOG.assertTrue(myOptionsRegistrar != null); final Set words = myOptionsRegistrar.getProcessedWordsWithoutStemming(descriptionText); @@ -263,7 +264,7 @@ public class InspectionToolRegistrar { } } - private static boolean checkTool(@NotNull final InspectionTool toolWrapper) { + private static boolean checkTool(@NotNull final InspectionToolWrapper toolWrapper) { if (toolWrapper instanceof LocalInspectionToolWrapper) { String message = null; try { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java index 640e455be36c..f87f56aaba8b 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java @@ -22,6 +22,7 @@ import com.intellij.application.options.colors.InspectionColorSettingsPage; import com.intellij.application.options.colors.TextAttributesDescription; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.ide.DataManager; import com.intellij.lang.annotation.HighlightSeverity; @@ -265,9 +266,9 @@ public class SeverityEditorDialog extends DialogWrapper { private void fillList(final HighlightSeverity severity) { DefaultListModel model = new DefaultListModel(); model.removeAllElements(); - final List infoTypes = new ArrayList(); - infoTypes.addAll(mySeverityRegistrar.getRegisteredHighlightingInfoTypes()); - Collections.sort(infoTypes, new Comparator() { + final List infoTypes = new ArrayList(); + infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar)); + Collections.sort(infoTypes, new Comparator() { @Override public int compare(SeverityBasedTextAttributes attributes1, SeverityBasedTextAttributes attributes2) { @@ -317,8 +318,8 @@ public class SeverityEditorDialog extends DialogWrapper { @Override protected void doOKAction() { apply((SeverityBasedTextAttributes)myOptionsList.getSelectedValue()); - final Collection infoTypes = - new HashSet(mySeverityRegistrar.getRegisteredHighlightingInfoTypes()); + final Collection infoTypes = + new HashSet(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar)); final ListModel listModel = myOptionsList.getModel(); final List order = new ArrayList(); for (int i = listModel.getSize() - 1; i >= 0; i--) { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java index 63eaae83b888..a4c23d726f5d 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java @@ -152,7 +152,7 @@ public class ToolsImpl implements Tools { myDefaultState.getTool().writeSettings(inspectionElement); } - void readExternal(Element toolElement, InspectionProfileImpl profile) throws InvalidDataException { + void readExternal(@NotNull Element toolElement, @NotNull InspectionProfileImpl profile) throws InvalidDataException { final String levelName = toolElement.getAttributeValue(LEVEL_ATTRIBUTE); final ProfileManager profileManager = profile.getProfileManager(); final SeverityRegistrar registrar = ((SeverityProvider)profileManager).getOwnSeverityRegistrar(); @@ -243,7 +243,7 @@ public class ToolsImpl implements Tools { final List result = new ArrayList(); if (myTools != null) { for (ScopeToolState state : myTools) { - result.add(state.getScope()); + result.add(ScopeToolStateUtil.getScope(state)); } } else { @@ -287,7 +287,7 @@ public class ToolsImpl implements Tools { if (!myEnabled) return false; if (namedScope != null && myTools != null) { for (ScopeToolState state : myTools) { - if (Comparing.equal(namedScope, state.getScope())) return state.isEnabled(); + if (Comparing.equal(namedScope, ScopeToolStateUtil.getScope(state))) return state.isEnabled(); } } return myDefaultState.isEnabled(); @@ -365,7 +365,7 @@ public class ToolsImpl implements Tools { public void enableTool(NamedScope namedScope) { if (myTools != null) { for (ScopeToolState state : myTools) { - if (Comparing.equal(state.getScope(), namedScope)) { + if (Comparing.equal(ScopeToolStateUtil.getScope(state), namedScope)) { state.setEnabled(true); } } @@ -376,7 +376,7 @@ public class ToolsImpl implements Tools { public void disableTool(NamedScope namedScope) { if (myTools != null) { for (ScopeToolState state : myTools) { - if (Comparing.equal(state.getScope(), namedScope)) { + if (Comparing.equal(ScopeToolStateUtil.getScope(state), namedScope)) { state.setEnabled(false); } } @@ -413,7 +413,7 @@ public class ToolsImpl implements Tools { public HighlightDisplayLevel getLevel(final NamedScope scope) { if (myTools != null && scope != null){ for (ScopeToolState state : myTools) { - if (Comparing.equal(state.getScope(), scope)) { + if (Comparing.equal(ScopeToolStateUtil.getScope(state), scope)) { return state.getLevel(); } } @@ -441,7 +441,7 @@ public class ToolsImpl implements Tools { if (myTools != null && myTools.size() > idx && idx >= 0) { final ScopeToolState scopeToolState = myTools.get(idx); myTools.remove(idx); - final NamedScope scope = scopeToolState.getScope(); + final NamedScope scope = ScopeToolStateUtil.getScope(scopeToolState); if (scope != null) { myTools.add(idx, new ScopeToolState(scope, scopeToolState.getTool(), scopeToolState.isEnabled(), level)); } else { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefDirectoryImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefDirectoryImpl.java index 1bb5fdc0135c..9d28c74b92c0 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefDirectoryImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefDirectoryImpl.java @@ -25,6 +25,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; public class RefDirectoryImpl extends RefElementImpl implements RefDirectory{ protected RefDirectoryImpl(PsiDirectory psiElement, RefManager refManager) { @@ -49,7 +50,7 @@ public class RefDirectoryImpl extends RefElementImpl implements RefDirectory{ } @Override - public void accept(final RefVisitor visitor) { + public void accept(@NotNull final RefVisitor visitor) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { @@ -62,6 +63,7 @@ public class RefDirectoryImpl extends RefElementImpl implements RefDirectory{ protected void initialize() { } + @NotNull @Override public String getQualifiedName() { return getName(); //todo relative name diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java index 51e0c421900e..24388dd0ed08 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java @@ -36,7 +36,6 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.SmartPointerManager; import com.intellij.psi.SmartPsiElementPointer; -import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -46,9 +45,10 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; +import java.util.List; public abstract class RefElementImpl extends RefEntityImpl implements RefElement { - private static final ArrayList EMPTY_REFERNCES_LIST = new ArrayList(0); + private static final List EMPTY_REFERNCES_LIST = new ArrayList(0); protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.reference.RefElement"); private static final int IS_ENTRY_MASK = 0x80; @@ -57,8 +57,8 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement private final SmartPsiElementPointer myID; - private ArrayList myOutReferences; - private ArrayList myInReferences; + private List myOutReferences; + private List myInReferences; private String[] mySuppressions = null; @@ -66,7 +66,7 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement private final Module myModule; protected static final int IS_REACHABLE_MASK = 0x40; - protected RefElementImpl(String name, RefElement owner) { + protected RefElementImpl(String name, @NotNull RefElement owner) { super(name, owner.getRefManager()); myID = null; myFlags = 0; @@ -77,7 +77,7 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement this(file.getName(), file, manager); } - protected RefElementImpl(String name, PsiElement element, RefManager manager) { + protected RefElementImpl(String name, @NotNull PsiElement element, @NotNull RefManager manager) { super(name, manager); myID = SmartPointerManager.getInstance(manager.getProject()).createSmartPsiElementPointer(element); myFlags = 0; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefEntityImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefEntityImpl.java index e3142ecccc80..6734b767a01b 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefEntityImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefEntityImpl.java @@ -37,24 +37,26 @@ import java.util.List; public abstract class RefEntityImpl implements RefEntity { private static final String NO_NAME = InspectionsBundle.message("inspection.reference.noname"); private RefEntityImpl myOwner; - protected ArrayList myChildren; + protected List myChildren; private final String myName; private THashMap myUserMap = null; protected int myFlags = 0; protected final RefManagerImpl myManager; - protected RefEntityImpl(String name, final RefManager manager) { + protected RefEntityImpl(String name, @NotNull RefManager manager) { myManager = (RefManagerImpl)manager; myName = name != null ? name : NO_NAME; myOwner = null; myChildren = null; } + @NotNull @Override public String getName() { return myName; } + @NotNull @Override public String getQualifiedName() { return myName; @@ -105,7 +107,7 @@ public abstract class RefEntityImpl implements RefEntity { } @Override - public void accept(final RefVisitor refVisitor) { + public void accept(@NotNull final RefVisitor refVisitor) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { @@ -152,6 +154,7 @@ public abstract class RefEntityImpl implements RefEntity { return myName; } + @NotNull @Override public RefManagerImpl getRefManager() { return myManager; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefFileImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefFileImpl.java index 0c753775b191..444e69632114 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefFileImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefFileImpl.java @@ -22,6 +22,7 @@ import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,7 +48,7 @@ public class RefFileImpl extends RefElementImpl implements RefFile { } @Override - public void accept(final RefVisitor visitor) { + public void accept(@NotNull final RefVisitor visitor) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java index a449c5a14711..6aae98448baa 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java @@ -19,7 +19,7 @@ * User: max * Date: Oct 22, 2001 * Time: 8:21:36 PM - * To change template for new class use + * To change template for new class use * Code Style | Class Templates options (Tools | IDE Options). */ package com.intellij.codeInspection.reference; @@ -62,6 +62,7 @@ public class RefManagerImpl extends RefManager { private int myLastUsedMask = 256 * 256 * 256 * 4; + @NotNull private final Project myProject; private AnalysisScope myScope; private RefProject myRefProject; @@ -82,7 +83,7 @@ public class RefManagerImpl extends RefManager { private final ReentrantReadWriteLock myLock = new ReentrantReadWriteLock(); - public RefManagerImpl(Project project, AnalysisScope scope, GlobalInspectionContextImpl context) { + public RefManagerImpl(@NotNull Project project, AnalysisScope scope, GlobalInspectionContextImpl context) { myDeclarationsFound = false; myProject = project; myScope = scope; @@ -104,7 +105,7 @@ public class RefManagerImpl extends RefManager { } @Override - public void iterate(RefVisitor visitor) { + public void iterate(@NotNull RefVisitor visitor) { myLock.readLock().lock(); try { for (RefElement refElement : getSortedElements()) { @@ -176,7 +177,7 @@ public class RefManagerImpl extends RefManager { } @Override - public T getExtension(final Key key) { + public T getExtension(@NotNull final Key key) { return (T)myExtensions.get(key); } @@ -306,11 +307,13 @@ public class RefManagerImpl extends RefManager { return myIsInProcess; } + @NotNull @Override public Project getProject() { return myProject; } + @NotNull @Override public RefProject getRefProject() { return myRefProject; @@ -338,6 +341,7 @@ public class RefManagerImpl extends RefManager { return answer; } + @NotNull @Override public PsiManager getPsiManager() { return myPsiManager; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefModuleImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefModuleImpl.java index 206fc6abfa5a..175da7b92081 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefModuleImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefModuleImpl.java @@ -17,7 +17,7 @@ import java.util.ArrayList; public class RefModuleImpl extends RefEntityImpl implements RefModule { private final Module myModule; - protected RefModuleImpl(Module module, final RefManager manager) { + protected RefModuleImpl(Module module, @NotNull RefManager manager) { super(module.getName(), manager); myModule = module; ((RefProjectImpl)manager.getRefProject()).add(this); @@ -43,7 +43,7 @@ public class RefModuleImpl extends RefEntityImpl implements RefModule { } @Override - public void accept(final RefVisitor refVisitor) { + public void accept(@NotNull final RefVisitor refVisitor) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefProjectImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefProjectImpl.java index 030d1b2f9adb..57dab12475c0 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefProjectImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefProjectImpl.java @@ -25,11 +25,12 @@ package com.intellij.codeInspection.reference; import com.intellij.util.PlatformIcons; +import org.jetbrains.annotations.NotNull; import javax.swing.*; public class RefProjectImpl extends RefEntityImpl implements RefProject { - public RefProjectImpl(RefManager refManager) { + public RefProjectImpl(@NotNull RefManager refManager) { super(refManager.getProject().getName(), refManager); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java index 29240572f08f..e49ab6c1b380 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java @@ -20,6 +20,7 @@ import com.intellij.codeInspection.ex.InspectionTool; import com.intellij.icons.AllIcons; import com.intellij.ui.LayeredIcon; import com.intellij.util.IconUtil; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.util.Enumeration; @@ -44,6 +45,7 @@ public class InspectionNode extends InspectionTreeNode { return getTool().getDisplayName(); } + @NotNull public InspectionTool getTool() { return (InspectionTool)getUserObject(); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java index c982cbd607fd..49cc04b91774 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java @@ -24,7 +24,7 @@ */ package com.intellij.codeInspection.ui; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.codeInspection.CommonProblemDescriptor; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.codeInspection.offline.OfflineProblemDescriptor; @@ -56,7 +56,7 @@ public class InspectionResultsViewComparator implements Comparator { if (node1 instanceof InspectionSeverityGroupNode && node2 instanceof InspectionSeverityGroupNode) { final InspectionSeverityGroupNode groupNode1 = (InspectionSeverityGroupNode)node1; final InspectionSeverityGroupNode groupNode2 = (InspectionSeverityGroupNode)node2; - return -SeverityRegistrar.getInstance(groupNode1.getProject()).compare(groupNode1.getSeverityLevel().getSeverity(), groupNode2.getSeverityLevel().getSeverity()); + return -SeverityUtil.getSeverityRegistrar(groupNode1.getProject()).compare(groupNode1.getSeverityLevel().getSeverity(), groupNode2.getSeverityLevel().getSeverity()); } if (node1 instanceof InspectionSeverityGroupNode) return -1; if (node2 instanceof InspectionSeverityGroupNode) return 1; diff --git a/platform/lang-impl/src/com/intellij/openapi/vcs/impl/CodeSmellDetectorImpl.java b/platform/lang-impl/src/com/intellij/openapi/vcs/impl/CodeSmellDetectorImpl.java index b7f906939fd8..f05dea6f77fe 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vcs/impl/CodeSmellDetectorImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/vcs/impl/CodeSmellDetectorImpl.java @@ -21,7 +21,7 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.application.ApplicationManager; @@ -175,7 +175,7 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector { if (highlights == null) return; for (HighlightInfo highlightInfo : highlights) { final HighlightSeverity severity = highlightInfo.getSeverity(); - if (SeverityRegistrar.getInstance(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) { + if (SeverityUtil.getSeverityRegistrar(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) { result.add(new CodeSmellInfo(document, getDescription(highlightInfo), new TextRange(highlightInfo.startOffset, highlightInfo.endOffset), severity)); } diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java index c45a62ad9fcd..c53a300ad842 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java @@ -15,18 +15,27 @@ */ package com.intellij.profile.codeInspection; +import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.daemon.InspectionProfileConvertor; +import com.intellij.codeInsight.daemon.impl.HighlightInfoType; +import com.intellij.codeInsight.daemon.impl.SeveritiesProvider; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; import com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.codeInspection.ex.InspectionToolRegistrar; +import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ExportableComponent; import com.intellij.openapi.components.NamedComponent; import com.intellij.openapi.components.RoamingType; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.options.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; @@ -72,6 +81,8 @@ public class InspectionProfileManagerImpl extends InspectionProfileManager imple public InspectionProfileManagerImpl(InspectionToolRegistrar registrar, SchemesManagerFactory schemesManagerFactory) { myRegistrar = registrar; mySeverityRegistrar = new SeverityRegistrar(); + registerProvidedSeverities(); + SchemeProcessor processor = new BaseSchemeProcessor() { @Override public InspectionProfileImpl readScheme(final Document document) { @@ -114,13 +125,28 @@ public class InspectionProfileManagerImpl extends InspectionProfileManager imple }; mySchemesManager = schemesManagerFactory.createSchemesManager(FILE_SPEC, processor, RoamingType.PER_USER); - } private static InspectionProfileImpl createSampleProfile() { return new InspectionProfileImpl("Default"); } + public static void registerProvidedSeverities() { + final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); + for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) { + for (HighlightInfoType highlightInfoType : provider.getSeveritiesHighlightInfoTypes()) { + final HighlightSeverity highlightSeverity = highlightInfoType.getSeverity(null); + SeverityRegistrar.registerStandard(highlightInfoType, highlightSeverity); + final TextAttributesKey attributesKey = highlightInfoType.getAttributesKey(); + TextAttributes textAttributes = scheme.getAttributes(attributesKey); + if (textAttributes == null) { + textAttributes = attributesKey.getDefaultAttributes(); + } + HighlightDisplayLevel.registerSeverity(highlightSeverity, provider.getTrafficRendererColor(textAttributes)); + } + } + } + @Override @NotNull public File[] getExportFiles() { diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java index 71d93e77a167..86144b0741a5 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java @@ -17,6 +17,7 @@ package com.intellij.profile.codeInspection.ui; import com.intellij.codeInspection.ex.Descriptor; import com.intellij.codeInspection.ex.ScopeToolState; +import com.intellij.codeInspection.ex.ScopeToolStateUtil; import com.intellij.openapi.util.ClearableLazyValue; import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.ui.CheckedTreeNode; @@ -71,7 +72,7 @@ public class InspectionConfigTreeNode extends CheckedTreeNode { @Nullable public NamedScope getScope() { - return myState != null ? myState.getScope() : null; + return myState != null ? ScopeToolStateUtil.getScope(myState) : null; } public boolean isByDefault() { diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/LevelChooser.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/LevelChooser.java index 1c35eb100465..66cee5f48771 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/LevelChooser.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/LevelChooser.java @@ -23,6 +23,7 @@ package com.intellij.profile.codeInspection.ui; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.codeInspection.ex.SeverityEditorDialog; import com.intellij.ui.ListCellRendererWrapper; import com.intellij.lang.annotation.HighlightSeverity; @@ -73,7 +74,7 @@ public class LevelChooser extends ComboboxWithBrowseButton { private static void fillModel(DefaultComboBoxModel model, final SeverityRegistrar severityRegistrar) { model.removeAllElements(); final TreeSet severities = new TreeSet(severityRegistrar); - for (SeverityRegistrar.SeverityBasedTextAttributes type : severityRegistrar.getRegisteredHighlightingInfoTypes()) { + for (SeverityRegistrar.SeverityBasedTextAttributes type : SeverityUtil.getRegisteredHighlightingInfoTypes(severityRegistrar)) { severities.add(type.getSeverity()); } severities.add(HighlightSeverity.ERROR); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index 7a15fa9fd39a..4d6c9c13798f 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -21,15 +21,13 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.codeInsight.hint.HintUtil; import com.intellij.codeInspection.InspectionProfile; import com.intellij.codeInspection.InspectionProfileEntry; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.codeInspection.ModifiableModel; -import com.intellij.codeInspection.ex.Descriptor; -import com.intellij.codeInspection.ex.InspectionProfileImpl; -import com.intellij.codeInspection.ex.InspectionToolRegistrar; -import com.intellij.codeInspection.ex.ScopeToolState; +import com.intellij.codeInspection.ex.*; import com.intellij.icons.AllIcons; import com.intellij.ide.CommonActionsManager; import com.intellij.ide.DefaultTreeExpander; @@ -578,7 +576,7 @@ public class SingleInspectionProfilePanel extends JPanel { severities.add(HighlightSeverity.WARNING); severities.add(HighlightSeverity.WEAK_WARNING); final Collection infoTypes = - severityRegistrar.getRegisteredHighlightingInfoTypes(); + SeverityUtil.getRegisteredHighlightingInfoTypes(severityRegistrar); for (SeverityRegistrar.SeverityBasedTextAttributes info : infoTypes) { severities.add(info.getSeverity()); } @@ -1044,7 +1042,7 @@ public class SingleInspectionProfilePanel extends JPanel { } for (int i = 0, toolsSize = tools.size(); i < toolsSize; i++) { final ScopeToolState pair = tools.get(i); - if (!Comparing.equal(pair.getScope(), descriptors.get(i).getScope())) { + if (!Comparing.equal(ScopeToolStateUtil.getScope(pair), descriptors.get(i).getScope())) { return true; } } diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java b/platform/platform-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java index 65173fd66c17..50954b986d33 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java @@ -199,7 +199,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { if (dependency.optional) { optionalDependentPlugins.add(id); if (dependency.configFile != null && !dependency.configFile.isEmpty()) { - myOptionalConfigs.put(id, dependency.configFile); + myOptionalConfigs.put(id, dependency.configFile); } } } @@ -208,14 +208,14 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myDependencies = dependentPlugins.isEmpty() ? PluginId.EMPTY_ARRAY : dependentPlugins.toArray(new PluginId[dependentPlugins.size()]); myOptionalDependencies = optionalDependentPlugins.isEmpty() ? PluginId.EMPTY_ARRAY : optionalDependentPlugins.toArray(new PluginId[optionalDependentPlugins.size()]); - List hsPathes = new ArrayList(); + List hsPaths = new ArrayList(); if (pluginBean.helpSets != null) { for (PluginHelpSet pluginHelpSet : pluginBean.helpSets) { HelpSetPath hsPath = new HelpSetPath(pluginHelpSet.file, pluginHelpSet.path); - hsPathes.add(hsPath); + hsPaths.add(hsPath); } } - myHelpSets = !hsPathes.isEmpty() ? hsPathes.toArray(new HelpSetPath[hsPathes.size()]) : HelpSetPath.EMPTY; + myHelpSets = hsPaths.isEmpty() ? HelpSetPath.EMPTY : hsPaths.toArray(new HelpSetPath[hsPaths.size()]); myAppComponents = pluginBean.applicationComponents; myProjectComponents = pluginBean.projectComponents; diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginNode.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginNode.java index 9b835f4f85e5..036ff1cfb5f8 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginNode.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginNode.java @@ -100,7 +100,7 @@ public class PluginNode implements IdeaPluginDescriptor { } /** - * Be carefull when comparing Plugins versions. Use + * Be careful when comparing Plugins versions. Use * PluginManagerColumnInfo.compareVersion() for version comparing. * * @return Return plugin version @@ -281,24 +281,24 @@ public class PluginNode implements IdeaPluginDescriptor { return null; } - @Nullable + @NotNull public ComponentConfig[] getAppComponents() { - return null; + throw new IllegalStateException(); } - @Nullable + @NotNull public ComponentConfig[] getProjectComponents() { - return null; + throw new IllegalStateException(); } - @Nullable + @NotNull public ComponentConfig[] getModuleComponents() { - return null; + throw new IllegalStateException(); } - @Nullable + @NotNull public HelpSetPath[] getHelpSets() { - return null; + throw new IllegalStateException(); } @Nullable diff --git a/platform/projectModel-api/src/com/intellij/openapi/project/ProjectUtilCore.java b/platform/projectModel-api/src/com/intellij/openapi/project/ProjectUtilCore.java new file mode 100644 index 000000000000..5dedb2dc093a --- /dev/null +++ b/platform/projectModel-api/src/com/intellij/openapi/project/ProjectUtilCore.java @@ -0,0 +1,67 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.project; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtilCore; +import com.intellij.openapi.roots.JdkOrderEntry; +import com.intellij.openapi.roots.OrderEntry; +import com.intellij.openapi.roots.libraries.LibraryUtil; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.vfs.LocalFileProvider; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +public class ProjectUtilCore { + public static String displayUrlRelativeToProject(@NotNull VirtualFile file, + @NotNull String url, + @NotNull Project project, + boolean includeFilePath, + boolean keepModuleAlwaysOnTheLeft) { + final VirtualFile baseDir = project.getBaseDir(); + if (baseDir != null && includeFilePath) { + //noinspection ConstantConditions + final String projectHomeUrl = baseDir.getPresentableUrl(); + if (url.startsWith(projectHomeUrl)) { + url = "..." + url.substring(projectHomeUrl.length()); + } + } + + if (SystemInfo.isMac && file.getFileSystem() instanceof LocalFileProvider) { + final VirtualFile fileForJar = ((LocalFileProvider)file.getFileSystem()).getLocalVirtualFileFor(file); + if (fileForJar != null) { + final OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(file, project); + if (libraryEntry != null) { + if (libraryEntry instanceof JdkOrderEntry) { + url = url + " - [" + ((JdkOrderEntry)libraryEntry).getJdkName() + "]"; + } + else { + url = url + " - [" + libraryEntry.getPresentableName() + "]"; + } + } + else { + url = url + " - [" + fileForJar.getName() + "]"; + } + } + } + + final Module module = ModuleUtilCore.findModuleForFile(file, project); + if (module == null) return url; + return !keepModuleAlwaysOnTheLeft && SystemInfo.isMac ? + url + " - [" + module.getName() + "]" : + "[" + module.getName() + "] - " + url; + } +} diff --git a/platform/lang-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java b/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java similarity index 98% rename from platform/lang-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java rename to platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java index f18fb630d361..dba8d85f4c08 100644 --- a/platform/lang-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java +++ b/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java @@ -24,7 +24,7 @@ import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.Ref; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; @@ -133,7 +133,7 @@ public class LibraryUtil { } } } - return VfsUtil.toVirtualFileArray(roots); + return VfsUtilCore.toVirtualFileArray(roots); } @Nullable diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeImpl.java index 6b18210173ed..f3c0bab1f6c2 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeImpl.java @@ -306,7 +306,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { for (Map.Entry> entry : myDirtyFiles.entrySet()) { final VirtualFile groupRoot = entry.getKey(); - if (VfsUtilCore.isAncestor(vcsRoot, groupRoot, false)) { + if (groupRoot != null && VfsUtilCore.isAncestor(vcsRoot, groupRoot, false)) { final THashSet files = entry.getValue(); if (files != null) { for (Iterator it = files.iterator(); it.hasNext();) { diff --git a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java index e0396ee6d402..48a5a9d06624 100644 --- a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java +++ b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java @@ -47,15 +47,15 @@ public class BooleanMethodIsAlwaysInvertedInspection extends GlobalJavaInspectio @Override @Nullable - public RefGraphAnnotator getAnnotator(final RefManager refManager) { + public RefGraphAnnotator getAnnotator(@NotNull final RefManager refManager) { return new BooleanInvertedAnnotator(); } @Override - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, - AnalysisScope scope, - final InspectionManager manager, - final GlobalInspectionContext globalContext) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, + @NotNull AnalysisScope scope, + @NotNull final InspectionManager manager, + @NotNull final GlobalInspectionContext globalContext) { if (refEntity instanceof RefMethod) { RefMethod refMethod = (RefMethod)refEntity; if (!refMethod.isReferenced()) return null; @@ -87,8 +87,8 @@ public class BooleanMethodIsAlwaysInvertedInspection extends GlobalJavaInspectio } @Override - protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext context, - final ProblemDescriptionsProcessor descriptionsProcessor) { + protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext context, + @NotNull final ProblemDescriptionsProcessor descriptionsProcessor) { manager.iterate(new RefJavaVisitor() { @Override public void visitMethod(@NotNull final RefMethod refMethod) { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/FieldCanBeMovedToSubclassInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/FieldCanBeMovedToSubclassInspection.java index cc1c4efc348e..77030cec7721 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/FieldCanBeMovedToSubclassInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/FieldCanBeMovedToSubclassInspection.java @@ -42,9 +42,9 @@ public class FieldCanBeMovedToSubclassInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefField)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/MethodReturnAlwaysConstantInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/MethodReturnAlwaysConstantInspection.java index 733f52b2fa7e..4948498513bd 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/MethodReturnAlwaysConstantInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/MethodReturnAlwaysConstantInspection.java @@ -45,8 +45,8 @@ public class MethodReturnAlwaysConstantInspection extends BaseGlobalInspection { @Override public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, AnalysisScope scope, InspectionManager manager, - GlobalInspectionContext globalContext) { + @NotNull RefEntity refEntity, @NotNull AnalysisScope scope, @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext) { if (!(refEntity instanceof RefMethod)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/StaticFieldCanBeMovedToUseInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/StaticFieldCanBeMovedToUseInspection.java index b5e749b6c1f9..6580acdaba1c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/StaticFieldCanBeMovedToUseInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/StaticFieldCanBeMovedToUseInspection.java @@ -43,9 +43,9 @@ public class StaticFieldCanBeMovedToUseInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefField)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyDependenciesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyDependenciesInspection.java index af23a468c2a2..74a7abc00439 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyDependenciesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyDependenciesInspection.java @@ -47,10 +47,10 @@ public class ClassWithTooManyDependenciesInspection @Override public void runInspection( - AnalysisScope scope, - final InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext, - final ProblemDescriptionsProcessor problemDescriptionsProcessor) { + @NotNull AnalysisScope scope, + @NotNull final InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext, + @NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) { final RefManager refManager = globalInspectionContext.getRefManager(); refManager.iterate(new RefJavaVisitor() { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyDependentsInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyDependentsInspection.java index 6eae1d24d47f..6f79a8a8a84a 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyDependentsInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyDependentsInspection.java @@ -47,10 +47,10 @@ public class ClassWithTooManyDependentsInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefClass)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyTransitiveDependenciesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyTransitiveDependenciesInspection.java index 19deae5818c1..62d3a47d4dfe 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyTransitiveDependenciesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyTransitiveDependenciesInspection.java @@ -48,10 +48,10 @@ public class ClassWithTooManyTransitiveDependenciesInspection @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefClass)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyTransitiveDependentsInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyTransitiveDependentsInspection.java index b1818783fc8c..3856e37ae373 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyTransitiveDependentsInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/ClassWithTooManyTransitiveDependentsInspection.java @@ -48,10 +48,10 @@ public class ClassWithTooManyTransitiveDependentsInspection @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefClass)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicClassDependencyInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicClassDependencyInspection.java index 8f6a4405fb52..0a74e0277dc4 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicClassDependencyInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicClassDependencyInspection.java @@ -42,10 +42,10 @@ public class CyclicClassDependencyInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefClass)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicClassInitializationInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicClassInitializationInspection.java index 363944457113..18331fec4382 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicClassInitializationInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicClassInitializationInspection.java @@ -42,10 +42,10 @@ public class CyclicClassInitializationInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefClass)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicPackageDependencyInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicPackageDependencyInspection.java index 8b1bcdc68961..1c96efe2d466 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicPackageDependencyInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dependency/CyclicPackageDependencyInspection.java @@ -41,10 +41,10 @@ public class CyclicPackageDependencyInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefPackage)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ClassIndependentOfModuleInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ClassIndependentOfModuleInspection.java index e7814458a6a5..94ef39be9280 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ClassIndependentOfModuleInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ClassIndependentOfModuleInspection.java @@ -45,10 +45,10 @@ public class ClassIndependentOfModuleInspection extends BaseGlobalInspection { @Nullable @Override public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope scope, - InspectionManager manager, - GlobalInspectionContext globalContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext) { if (!(refEntity instanceof RefClass)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ClassOnlyUsedInOneModuleInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ClassOnlyUsedInOneModuleInspection.java index a64708bd3e0c..b1697848c3d9 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ClassOnlyUsedInOneModuleInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ClassOnlyUsedInOneModuleInspection.java @@ -48,10 +48,10 @@ public class ClassOnlyUsedInOneModuleInspection extends BaseGlobalInspection { @Nullable @Override public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope scope, - InspectionManager manager, - GlobalInspectionContext globalContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext) { if (!(refEntity instanceof RefClass)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ModuleWithTooFewClassesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ModuleWithTooFewClassesInspection.java index 1893ff6e5add..9f5932824a5a 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ModuleWithTooFewClassesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ModuleWithTooFewClassesInspection.java @@ -47,8 +47,8 @@ public class ModuleWithTooFewClassesInspection extends BaseGlobalInspection { @Override @Nullable - public CommonProblemDescriptor[] checkElement(RefEntity refEntity, AnalysisScope analysisScope, InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope, @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefModule)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ModuleWithTooManyClassesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ModuleWithTooManyClassesInspection.java index f7f997416269..57dd6b0350ac 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ModuleWithTooManyClassesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/modularization/ModuleWithTooManyClassesInspection.java @@ -46,10 +46,10 @@ public class ModuleWithTooManyClassesInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefModule)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/PackageNamingConventionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/PackageNamingConventionInspection.java index 8f98b4daf78a..8a3d9bb24097 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/PackageNamingConventionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/PackageNamingConventionInspection.java @@ -76,9 +76,9 @@ public class PackageNamingConventionInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefPackage)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/ClassOnlyUsedInOnePackageInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/ClassOnlyUsedInOnePackageInspection.java index fd8b30f25e26..1f53a74f239f 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/ClassOnlyUsedInOnePackageInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/ClassOnlyUsedInOnePackageInspection.java @@ -43,10 +43,10 @@ public class ClassOnlyUsedInOnePackageInspection extends BaseGlobalInspection { @Nullable @Override public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope scope, - InspectionManager manager, - GlobalInspectionContext globalContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext) { if (!(refEntity instanceof RefClass)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/ClassUnconnectedToPackageInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/ClassUnconnectedToPackageInspection.java index cd191e13b8b8..a333739180a6 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/ClassUnconnectedToPackageInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/ClassUnconnectedToPackageInspection.java @@ -45,10 +45,10 @@ public class ClassUnconnectedToPackageInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager manager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefClass)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/DisjointPackageInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/DisjointPackageInspection.java index cc193166e218..7c73800a5267 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/DisjointPackageInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/DisjointPackageInspection.java @@ -47,9 +47,9 @@ public class DisjointPackageInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefPackage)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/EmptyDirectoryInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/EmptyDirectoryInspection.java index 68fd50f9cc94..a6d481633eb8 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/EmptyDirectoryInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/EmptyDirectoryInspection.java @@ -61,9 +61,9 @@ public class EmptyDirectoryInspection extends BaseGlobalInspection { } @Override - public void runInspection(final AnalysisScope scope, final InspectionManager manager, - final GlobalInspectionContext context, - final ProblemDescriptionsProcessor processor) { + public void runInspection(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager, + @NotNull final GlobalInspectionContext context, + @NotNull final ProblemDescriptionsProcessor processor) { final Project project = context.getProject(); final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); final SearchScope searchScope = scope.toSearchScope(); diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageInMultipleModulesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageInMultipleModulesInspection.java index ce69ce03547a..5f982ba93920 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageInMultipleModulesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageInMultipleModulesInspection.java @@ -44,9 +44,9 @@ public class PackageInMultipleModulesInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefPackage)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageWithTooFewClassesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageWithTooFewClassesInspection.java index c72f37d7ed91..49f24660af8e 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageWithTooFewClassesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageWithTooFewClassesInspection.java @@ -46,10 +46,10 @@ public class PackageWithTooFewClassesInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefPackage)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageWithTooManyClassesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageWithTooManyClassesInspection.java index ae410bdcc5fc..18b30b3ce63b 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageWithTooManyClassesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/packaging/PackageWithTooManyClassesInspection.java @@ -46,10 +46,10 @@ public class PackageWithTooManyClassesInspection extends BaseGlobalInspection { @Override @Nullable public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, - AnalysisScope analysisScope, - InspectionManager inspectionManager, - GlobalInspectionContext globalInspectionContext) { + @NotNull RefEntity refEntity, + @NotNull AnalysisScope analysisScope, + @NotNull InspectionManager inspectionManager, + @NotNull GlobalInspectionContext globalInspectionContext) { if (!(refEntity instanceof RefPackage)) { return null; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/redundancy/ElementOnlyUsedFromTestCodeInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/redundancy/ElementOnlyUsedFromTestCodeInspection.java index 9797af853f5d..7cb49d1bae51 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/redundancy/ElementOnlyUsedFromTestCodeInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/redundancy/ElementOnlyUsedFromTestCodeInspection.java @@ -43,16 +43,16 @@ public class ElementOnlyUsedFromTestCodeInspection @Override @Nullable - public RefGraphAnnotator getAnnotator(RefManager refManager) { + public RefGraphAnnotator getAnnotator(@NotNull RefManager refManager) { return new ElementOnlyUsedFromTestCodeAnnotator(); } @Nullable @Override public CommonProblemDescriptor[] checkElement( - RefEntity refEntity, AnalysisScope scope, InspectionManager manager, - GlobalInspectionContext globalContext, - ProblemDescriptionsProcessor processor) { + @NotNull RefEntity refEntity, @NotNull AnalysisScope scope, @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor processor) { if (!isOnlyUsedFromTestCode(refEntity)) { return null; } diff --git a/plugins/ui-designer-core/src/com/intellij/designer/componentTree/ComponentTree.java b/plugins/ui-designer-core/src/com/intellij/designer/componentTree/ComponentTree.java index 9a31de27901a..79f935c5181d 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/componentTree/ComponentTree.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/componentTree/ComponentTree.java @@ -17,6 +17,7 @@ package com.intellij.designer.componentTree; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.designer.actions.DesignerActionPanel; import com.intellij.designer.actions.StartInplaceEditing; import com.intellij.designer.designSurface.DesignerEditorPanel; @@ -158,7 +159,7 @@ public final class ComponentTree extends Tree implements DataProvider { @Nullable private static HighlightDisplayLevel getHighlightDisplayLevel(Project project, RadComponent component) { HighlightDisplayLevel displayLevel = null; - SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); + SeverityRegistrar severityRegistrar = SeverityUtil.getSeverityRegistrar(project); for (ErrorInfo errorInfo : RadComponent.getError(component)) { if (displayLevel == null || severityRegistrar.compare(errorInfo.getLevel().getSeverity(), displayLevel.getSeverity()) > 0) { displayLevel = errorInfo.getLevel(); @@ -173,7 +174,7 @@ public final class ComponentTree extends Tree implements DataProvider { if (level != null) { TextAttributesKey attributesKey = - SeverityRegistrar.getInstance(myDesigner.getProject()).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey(); + SeverityUtil.getSeverityRegistrar(myDesigner.getProject()).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey(); final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey); wrapper = new AttributeWrapper() { diff --git a/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/RadPropertyTable.java b/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/RadPropertyTable.java index a0f96c41f87b..f9975f929662 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/RadPropertyTable.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/RadPropertyTable.java @@ -15,7 +15,7 @@ */ package com.intellij.designer.propertyTable; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.designer.DesignerBundle; import com.intellij.designer.designSurface.ComponentSelectionListener; import com.intellij.designer.designSurface.DesignerEditorPanel; @@ -104,7 +104,7 @@ public class RadPropertyTable extends PropertyTable implements DataProvider, Com @NotNull protected TextAttributesKey getErrorAttributes(@NotNull HighlightSeverity severity) { - return SeverityRegistrar.getInstance(myProject).getHighlightInfoTypeBySeverity(severity).getAttributesKey(); + return SeverityUtil.getSeverityRegistrar(myProject).getHighlightInfoTypeBySeverity(severity).getAttributesKey(); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/ErrorAnalyzer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/ErrorAnalyzer.java index 8eef6609d08a..c6c96814723d 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/ErrorAnalyzer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/ErrorAnalyzer.java @@ -16,7 +16,7 @@ package com.intellij.uiDesigner; import com.intellij.codeHighlighting.HighlightDisplayLevel; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; @@ -392,7 +392,7 @@ public final class ErrorAnalyzer { public static HighlightDisplayLevel getHighlightDisplayLevel(final Project project, @NotNull final RadComponent component) { HighlightDisplayLevel displayLevel = null; for(ErrorInfo errInfo: getAllErrorsForComponent(component)) { - if (displayLevel == null || SeverityRegistrar.getInstance(project).compare(errInfo.getHighlightDisplayLevel().getSeverity(), displayLevel.getSeverity()) > 0) { + if (displayLevel == null || SeverityUtil.getSeverityRegistrar(project).compare(errInfo.getHighlightDisplayLevel().getSeverity(), displayLevel.getSeverity()) > 0) { displayLevel = errInfo.getHighlightDisplayLevel(); } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/componentTree/ComponentTree.java b/plugins/ui-designer/src/com/intellij/uiDesigner/componentTree/ComponentTree.java index 323a3ead0de8..875d3930a914 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/componentTree/ComponentTree.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/componentTree/ComponentTree.java @@ -16,7 +16,7 @@ package com.intellij.uiDesigner.componentTree; import com.intellij.codeHighlighting.HighlightDisplayLevel; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.icons.AllIcons; import com.intellij.ide.DeleteProvider; import com.intellij.ide.util.EditSourceUtil; @@ -328,7 +328,7 @@ public final class ComponentTree extends Tree implements DataProvider { SimpleTextAttributes result = highlightMap.get(attrs); if (result == null) { - final TextAttributesKey attrKey = SeverityRegistrar.getInstance(myProject).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey(); + final TextAttributesKey attrKey = SeverityUtil.getSeverityRegistrar(myProject).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey(); TextAttributes textAttrs = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attrKey); textAttrs = TextAttributes.merge(attrs.toTextAttributes(), textAttrs); result = SimpleTextAttributes.fromTextAttributes(textAttrs); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/PropertyInspectorTable.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/PropertyInspectorTable.java index 9cd2d0fbbd69..22d95ba4d781 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/PropertyInspectorTable.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/PropertyInspectorTable.java @@ -15,7 +15,7 @@ */ package com.intellij.uiDesigner.propertyInspector; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.icons.AllIcons; import com.intellij.ide.ui.LafManager; import com.intellij.ide.ui.LafManagerListener; @@ -806,7 +806,7 @@ public final class PropertyInspectorTable extends Table implements DataProvider{ for(IntrospectedProperty otherProperty: props) { if (otherProperty.getName().equals(property.getName())) { otherValue = otherProperty.getValue(mySelection.get(i)); - break; + break; } } } @@ -1028,7 +1028,7 @@ public final class PropertyInspectorTable extends Table implements DataProvider{ background = table.getBackground(); } else { - // syntetic property + // syntetic property background = parent == null ? SYNTETIC_PROPERTY_BACKGROUND : SYNTETIC_SUBPROPERTY_BACKGROUND; } @@ -1131,7 +1131,7 @@ public final class PropertyInspectorTable extends Table implements DataProvider{ Map cache = modified ? myModifiedHighlightAttributes : myHighlightAttributes; result = cache.get(severity); if (result == null) { - final TextAttributesKey attrKey = SeverityRegistrar.getInstance(myProject).getHighlightInfoTypeBySeverity(severity).getAttributesKey(); + final TextAttributesKey attrKey = SeverityUtil.getSeverityRegistrar(myProject).getHighlightInfoTypeBySeverity(severity).getAttributesKey(); TextAttributes textAttrs = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attrKey); if (modified) { textAttrs = textAttrs.clone(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsErrorPanel.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsErrorPanel.java index ff02ad049798..4842c4c0fe86 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsErrorPanel.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsErrorPanel.java @@ -17,6 +17,7 @@ package com.intellij.util.xml.highlighting; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.codeInsight.daemon.impl.TrafficLightRenderer; import com.intellij.icons.AllIcons; import com.intellij.lang.annotation.HighlightSeverity; @@ -170,7 +171,7 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H int sum = 0; for (DomElement element : myDomElements) { final DomElementsProblemsHolder holder = myAnnotationsManager.getCachedProblemHolder(element); - sum += (SeverityRegistrar.getInstance(getProject()).compare(minSeverity, HighlightSeverity.WARNING) >= 0 ? holder + sum += (SeverityUtil.getSeverityRegistrar(getProject()).compare(minSeverity, HighlightSeverity.WARNING) >= 0 ? holder .getProblems(element, true, true) : holder.getProblems(element, true, minSeverity)).size(); } status.errorCount[i] = sum; diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsProblemsHolderImpl.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsProblemsHolderImpl.java index dfa6f5c81c47..840a75a82add 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsProblemsHolderImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsProblemsHolderImpl.java @@ -16,7 +16,7 @@ package com.intellij.util.xml.highlighting; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.lang.annotation.Annotation; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.util.Condition; @@ -129,7 +129,7 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder public List getProblems(final DomElement domElement, final boolean withChildren, final HighlightSeverity minSeverity) { return ContainerUtil.findAll(getProblems(domElement, true, withChildren), new Condition() { public boolean value(final DomElementProblemDescriptor object) { - return SeverityRegistrar.getInstance(domElement.getManager().getProject()).compare(object.getHighlightSeverity(), minSeverity) >= 0; + return SeverityUtil.getSeverityRegistrar(domElement.getManager().getProject()).compare(object.getHighlightSeverity(), minSeverity) >= 0; } }); diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java index d4860becbf13..dba2b285a16e 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java @@ -20,7 +20,7 @@ import com.intellij.codeInsight.daemon.*; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.HighlightVisitor; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; +import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixActionRegistrarImpl; import com.intellij.codeInsight.intention.IntentionAction; @@ -360,7 +360,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV localizedMessage, isInjectedHtmlTagForWhichNoProblemsReporting((HtmlTag)tag) ? HighlightInfoType.INFORMATION : - SeverityRegistrar.getInstance(tag.getProject()).getHighlightInfoTypeBySeverity(profile.getErrorLevel(key, tag).getSeverity()), + SeverityUtil.getSeverityRegistrar(tag.getProject()).getHighlightInfoTypeBySeverity(profile.getErrorLevel(key, tag).getSeverity()), intentionAction, basicIntention); } else if (!htmlTag) {