mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -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<PsiElement, Collection<String>> suppressedScopes = new THashMap<PsiElement, Collection<String>>();
|
||||
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<String> list = myQuickFixes.getKeysByValue(fix);
|
||||
if (list != null) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -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<Boolean> list = myQuickFixes.getKeysByValue(fix);
|
||||
if (list != null) {
|
||||
LOG.assertTrue(list.size() == 1);
|
||||
|
||||
+10
-21
@@ -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<Module> modules = new THashSet<Module>();
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+5
-5
@@ -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<ProblemDescriptor> 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();
|
||||
}
|
||||
|
||||
+4
-4
@@ -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) {
|
||||
|
||||
+2
-2
@@ -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();
|
||||
|
||||
@@ -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<String> hints = myQuickFixes.getKeysByValue(fix);
|
||||
LOG.assertTrue(hints != null && hints.size() == 1);
|
||||
return hints.get(0);
|
||||
|
||||
+51
-40
@@ -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<VirtualFile> libraryRoots = new ArrayList<VirtualFile>();
|
||||
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<PsiFile, Set<PsiFile>> dependencies = builder.getDependencies();
|
||||
for (PsiFile file : dependencies.keySet()) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
LOG.assertTrue(virtualFile != null);
|
||||
for (Iterator<VirtualFile> i = libraryRoots.iterator(); i.hasNext();) {
|
||||
for (Iterator<VirtualFile> 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<VirtualFile, String>() {
|
||||
@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;
|
||||
|
||||
+10
-10
@@ -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);
|
||||
|
||||
+7
-7
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class ConstructorReferencesSearcher extends QueryExecutorBase<PsiReferenc
|
||||
return aClass;
|
||||
}
|
||||
});
|
||||
if (aClass == null) {
|
||||
if (manager[0] == null) {
|
||||
return;
|
||||
}
|
||||
new ConstructorReferencesSearchHelper(manager[0])
|
||||
|
||||
@@ -28,13 +28,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class GlobalJavaInspectionTool extends GlobalInspectionTool implements CustomSuppressableInspectionTool {
|
||||
@Override
|
||||
public boolean queryExternalUsagesRequests(final InspectionManager manager,
|
||||
final GlobalInspectionContext globalContext,
|
||||
final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
|
||||
public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager,
|
||||
@NotNull final GlobalInspectionContext globalContext,
|
||||
@NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
|
||||
return queryExternalUsagesRequests(globalContext.getRefManager(), globalContext.getExtension(GlobalJavaInspectionContext.CONTEXT), problemDescriptionsProcessor);
|
||||
}
|
||||
|
||||
protected boolean queryExternalUsagesRequests(RefManager manager, GlobalJavaInspectionContext globalContext, ProblemDescriptionsProcessor processor) {
|
||||
protected boolean queryExternalUsagesRequests(@NotNull RefManager manager, @NotNull GlobalJavaInspectionContext globalContext, @NotNull ProblemDescriptionsProcessor processor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class RefJavaManager implements RefManagerExtension<RefJavaManager> {
|
||||
@NonNls public static final String CLASS = "class";
|
||||
@@ -70,11 +71,13 @@ public abstract class RefJavaManager implements RefManagerExtension<RefJavaManag
|
||||
|
||||
public abstract EntryPointsManager getEntryPointsManager();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return StdLanguages.JAVA;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Key<RefJavaManager> getID() {
|
||||
return MANAGER;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
+23
-49
@@ -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<AnalysisScope> 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<VirtualFile> myFilesSet;
|
||||
protected Set<VirtualFile> 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<String> result,
|
||||
@NotNull final ProjectProfileManager profileManager) {
|
||||
for (final PsiDirectory directory : psiDirectories) {
|
||||
final PsiFile[] psiFiles = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile[]>() {
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiFile[] compute() {
|
||||
return directory.getFiles();
|
||||
}
|
||||
});
|
||||
for (PsiFile file : psiFiles) {
|
||||
result.add(profileManager.getProfileName());
|
||||
}
|
||||
processDirectories(ApplicationManager.getApplication().runReadAction(new Computable<PsiDirectory[]>() {
|
||||
@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
|
||||
+1
@@ -72,6 +72,7 @@ public interface GlobalInspectionContext extends UserDataHolder {
|
||||
*/
|
||||
boolean isSuppressed(@NotNull PsiElement element, String inspectionToolId);
|
||||
|
||||
@NotNull
|
||||
Project getProject();
|
||||
|
||||
<T> T getExtension(Key<T> key);
|
||||
+22
-19
@@ -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) {
|
||||
}
|
||||
|
||||
/**
|
||||
+1
-1
@@ -62,4 +62,4 @@ public abstract class HTMLComposer {
|
||||
public abstract void appendNoProblems(StringBuffer buf);
|
||||
|
||||
public abstract <T> T getExtension(Key<T> key);
|
||||
}
|
||||
}
|
||||
-13
@@ -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) {
|
||||
+1
-1
@@ -55,4 +55,4 @@ public abstract class EntryPoint implements JDOMExternalizable , Cloneable {
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -21,4 +21,4 @@
|
||||
package com.intellij.codeInspection.reference;
|
||||
|
||||
public interface RefDirectory extends RefElement {
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -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
|
||||
+1
-1
@@ -22,4 +22,4 @@ public class RefGraphAnnotatorEx extends RefGraphAnnotator {
|
||||
*/
|
||||
public void initialize(RefManager refManager) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -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> T getExtension(Key<T> key);
|
||||
public abstract <T> T getExtension(@NotNull Key<T> key);
|
||||
|
||||
@Nullable
|
||||
public abstract String getType(final RefEntity ref);
|
||||
@@ -113,5 +116,6 @@ public abstract class RefManager {
|
||||
|
||||
public abstract void removeRefElement(RefElement refElement, List<RefElement> deletedRefs);
|
||||
|
||||
@NotNull
|
||||
public abstract PsiManager getPsiManager();
|
||||
}
|
||||
+1
-1
@@ -36,4 +36,4 @@ public class RefVisitor {
|
||||
public void visitDirectory(@NotNull RefDirectory directory) {
|
||||
visitElement(directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,7 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
LOG.assertTrue(myApplicationProfileManager != null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
-41
@@ -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 + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
+49
-81
@@ -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<HighlightSeverity> {
|
||||
@NonNls private static final String INFO = "info";
|
||||
private final Map<String, SeverityBasedTextAttributes> ourMap = new THashMap<String, SeverityBasedTextAttributes>();
|
||||
private final Map<String, Color> ourRendererColors = new THashMap<String, Color>();
|
||||
private final Map<String, SeverityBasedTextAttributes> myMap = new THashMap<String, SeverityBasedTextAttributes>();
|
||||
private final Map<String, Color> myRendererColors = new THashMap<String, Color>();
|
||||
@NonNls private static final String COLOR = "color";
|
||||
|
||||
private final OrderMap myOrder = new OrderMap();
|
||||
@@ -61,64 +53,32 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
|
||||
private static final Map<String, HighlightInfoType> STANDARD_SEVERITIES = new THashMap<String, HighlightInfoType>();
|
||||
|
||||
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<SeverityBasedTextAttributes> getRegisteredHighlightingInfoTypes() {
|
||||
final Collection<SeverityBasedTextAttributes> collection = new ArrayList<SeverityBasedTextAttributes>(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<Highlig
|
||||
return (HighlightInfoType.HighlightInfoTypeImpl)HighlightInfoType.INFORMATION;
|
||||
}
|
||||
|
||||
final SeverityBasedTextAttributes type = ourMap.get(severity.toString());
|
||||
final SeverityBasedTextAttributes type = myMap.get(severity.toString());
|
||||
return (HighlightInfoType.HighlightInfoTypeImpl)(type != null ? type.getType() : HighlightInfoType.WARNING);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TextAttributes getTextAttributesBySeverity(@NotNull HighlightSeverity severity) {
|
||||
final SeverityBasedTextAttributes infoType = ourMap.get(severity.toString());
|
||||
final SeverityBasedTextAttributes infoType = myMap.get(severity.toString());
|
||||
if (infoType != null) {
|
||||
return infoType.getAttributes();
|
||||
}
|
||||
@@ -148,23 +108,21 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
ourMap.clear();
|
||||
ourRendererColors.clear();
|
||||
myMap.clear();
|
||||
myRendererColors.clear();
|
||||
final List children = element.getChildren(INFO);
|
||||
if (children != null){
|
||||
for (Object child : children) {
|
||||
final Element infoElement = (Element)child;
|
||||
for (Object child : children) {
|
||||
final Element infoElement = (Element)child;
|
||||
|
||||
final SeverityBasedTextAttributes highlightInfo = new SeverityBasedTextAttributes();
|
||||
highlightInfo.readExternal(infoElement);
|
||||
final SeverityBasedTextAttributes highlightInfo = new SeverityBasedTextAttributes();
|
||||
highlightInfo.readExternal(infoElement);
|
||||
|
||||
Color color = null;
|
||||
final String colorStr = infoElement.getAttributeValue(COLOR);
|
||||
if (colorStr != null){
|
||||
color = new Color(Integer.parseInt(colorStr, 16));
|
||||
}
|
||||
registerSeverity(highlightInfo, color);
|
||||
Color color = null;
|
||||
final String colorStr = infoElement.getAttributeValue(COLOR);
|
||||
if (colorStr != null){
|
||||
color = new Color(Integer.parseInt(colorStr, 16));
|
||||
}
|
||||
registerSeverity(highlightInfo, color);
|
||||
}
|
||||
myOrder.clear();
|
||||
|
||||
@@ -212,10 +170,10 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
for (HighlightSeverity s : list) {
|
||||
Element info = new Element(INFO);
|
||||
String severity = s.toString();
|
||||
final SeverityBasedTextAttributes infoType = ourMap.get(severity);
|
||||
final SeverityBasedTextAttributes infoType = myMap.get(severity);
|
||||
if (infoType != null) {
|
||||
infoType.writeExternal(info);
|
||||
final Color color = ourRendererColors.get(severity);
|
||||
final Color color = myRendererColors.get(severity);
|
||||
if (color != null) {
|
||||
info.setAttribute(COLOR, Integer.toString(color.getRGB() & 0xFFFFFF, 16));
|
||||
}
|
||||
@@ -280,7 +238,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
public HighlightSeverity getSeverity(@NotNull String name) {
|
||||
final HighlightInfoType type = STANDARD_SEVERITIES.get(name);
|
||||
if (type != null) return type.getSeverity(null);
|
||||
final SeverityBasedTextAttributes attributes = ourMap.get(name);
|
||||
final SeverityBasedTextAttributes attributes = myMap.get(name);
|
||||
if (attributes != null) return attributes.getSeverity();
|
||||
return null;
|
||||
}
|
||||
@@ -289,7 +247,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
private List<String> createCurrentSeverities() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
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<Highlig
|
||||
return level.getIcon();
|
||||
}
|
||||
|
||||
return HighlightDisplayLevel.createIconByMask(ourRendererColors.get(severity.toString()));
|
||||
return HighlightDisplayLevel.createIconByMask(myRendererColors.get(severity.toString()));
|
||||
}
|
||||
|
||||
public boolean isSeverityValid(@NotNull String severity) {
|
||||
@@ -336,7 +294,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
|
||||
@NotNull
|
||||
private List<HighlightSeverity> getDefaultOrder() {
|
||||
Collection<SeverityBasedTextAttributes> values = ourMap.values();
|
||||
Collection<SeverityBasedTextAttributes> values = myMap.values();
|
||||
List<HighlightSeverity> order = new ArrayList<HighlightSeverity>(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<Highlig
|
||||
return minSeverity != HighlightSeverity.INFORMATION;
|
||||
}
|
||||
|
||||
private static class OrderMap extends TObjectIntHashMap<HighlightSeverity> {
|
||||
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<Highlig
|
||||
}
|
||||
}
|
||||
|
||||
private static class OrderMap extends TObjectIntHashMap<HighlightSeverity> {
|
||||
private int getOrder(@NotNull HighlightSeverity severity, int defaultOrder) {
|
||||
int index = index(severity);
|
||||
return index < 0 ? defaultOrder : _values[index];
|
||||
}
|
||||
@NotNull
|
||||
Collection<SeverityBasedTextAttributes> allRegisteredAttributes() {
|
||||
return new ArrayList<SeverityBasedTextAttributes>(myMap.values());
|
||||
}
|
||||
@NotNull
|
||||
Collection<HighlightInfoType> standardSeverities() {
|
||||
return STANDARD_SEVERITIES.values();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<VirtualFile> files);
|
||||
}
|
||||
|
||||
+1
-1
@@ -56,4 +56,4 @@ public class LanguageExtensionPoint<T> extends CustomLoadingExtensionPointBean i
|
||||
public String getKey() {
|
||||
return language;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<AnalysisScope> KEY = DataKey.create("analysisScope");
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<T> {
|
||||
@NotNull
|
||||
Key<T> getID();
|
||||
|
||||
@NotNull
|
||||
Language getLanguage();
|
||||
|
||||
void iterate(RefVisitor visitor);
|
||||
void iterate(@NotNull RefVisitor visitor);
|
||||
|
||||
void cleanup();
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,12 @@ public class CodeInsightUtilBase extends CodeInsightUtilCore {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepareVirtualFilesForWrite(@NotNull Project project, @NotNull Collection<VirtualFile> 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;
|
||||
|
||||
+2
-2
@@ -539,7 +539,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
@NotNull final Processor<HighlightInfo> 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<RangeHighlighterEx>() {
|
||||
@Override
|
||||
@@ -562,7 +562,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
@NotNull final Processor<HighlightInfo> 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<RangeHighlighterEx>() {
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererP
|
||||
ContainerUtil.quickSort(infos, new Comparator<HighlightInfo>() {
|
||||
@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());
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<SeverityRegistrar.SeverityBasedTextAttributes> getRegisteredHighlightingInfoTypes(@NotNull SeverityRegistrar registrar) {
|
||||
Collection<SeverityRegistrar.SeverityBasedTextAttributes> 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();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
+1
-1
@@ -224,7 +224,7 @@ public class TrafficProgressPanel extends JPanel {
|
||||
String text = "<html><body>";
|
||||
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
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+3
-3
@@ -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<HighlightInfo> otherHighlightInTheWayProcessor = new Processor<HighlightInfo>() {
|
||||
@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<HighlightInfo>() {
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -126,6 +126,7 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<CommonProblemDescriptor> 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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+4
-4
@@ -75,9 +75,9 @@ public class GlobalInspectionToolWrapper extends InspectionToolWrapper<GlobalIns
|
||||
return getTool().isGraphNeeded();
|
||||
}
|
||||
|
||||
public void processFile(final AnalysisScope analysisScope,
|
||||
final InspectionManager manager,
|
||||
final GlobalInspectionContext context,
|
||||
public void processFile(@NotNull final AnalysisScope analysisScope,
|
||||
@NotNull final InspectionManager manager,
|
||||
@NotNull final GlobalInspectionContext context,
|
||||
final boolean filterSuppressed) {
|
||||
context.getRefManager().iterate(new RefVisitor() {
|
||||
@Override public void visitElement(@NotNull RefEntity refEntity) {
|
||||
@@ -95,7 +95,7 @@ public class GlobalInspectionToolWrapper extends InspectionToolWrapper<GlobalIns
|
||||
public HTMLComposerImpl getComposer() {
|
||||
return new DescriptorComposer(this) {
|
||||
@Override
|
||||
protected void composeAdditionalDescription(final StringBuffer buf, final RefEntity refEntity) {
|
||||
protected void composeAdditionalDescription(@NotNull final StringBuffer buf, @NotNull final RefEntity refEntity) {
|
||||
getTool().compose(buf, refEntity, this);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -621,7 +621,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
if (nonDefaultToolStates != null) {
|
||||
for (ScopeToolState state : nonDefaultToolStates) {
|
||||
final InspectionTool inspectionTool = copyToolSettings((InspectionToolWrapper)state.getTool());
|
||||
final NamedScope scope = project != null ? state.getScope(project) : state.getScope();
|
||||
final NamedScope scope = project != null ? state.getScope(project) : ScopeToolStateUtil.getScope(state);
|
||||
if (scope != null) {
|
||||
tools.addTool(scope, inspectionTool, state.isEnabled(), state.getLevel());
|
||||
} else {
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.intellij.analysis.AnalysisScope;
|
||||
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.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.reference.*;
|
||||
@@ -206,7 +206,7 @@ public abstract class InspectionTool extends InspectionProfileEntry {
|
||||
if (highlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
|
||||
return HighlightInfoType.UNUSED_SYMBOL.getAttributesKey().getExternalName();
|
||||
}
|
||||
return SeverityRegistrar.getInstance(project).getHighlightInfoTypeBySeverity(severity).getAttributesKey().getExternalName();
|
||||
return SeverityUtil.getSeverityRegistrar(project).getHighlightInfoTypeBySeverity(severity).getAttributesKey().getExternalName();
|
||||
}
|
||||
|
||||
public static void setOutputPath(final String output) {
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.regex.Pattern;
|
||||
public class InspectionToolRegistrar {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionToolRegistrar");
|
||||
|
||||
private final ArrayList<Factory<InspectionToolWrapper>> myInspectionToolFactories = new ArrayList<Factory<InspectionToolWrapper>>();
|
||||
private final List<Factory<InspectionToolWrapper>> myInspectionToolFactories = new ArrayList<Factory<InspectionToolWrapper>>();
|
||||
|
||||
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<InspectionToolWrapper> 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<String> 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 {
|
||||
|
||||
@@ -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<SeverityRegistrar.SeverityBasedTextAttributes> infoTypes = new ArrayList<SeverityRegistrar.SeverityBasedTextAttributes>();
|
||||
infoTypes.addAll(mySeverityRegistrar.getRegisteredHighlightingInfoTypes());
|
||||
Collections.sort(infoTypes, new Comparator<SeverityRegistrar.SeverityBasedTextAttributes>() {
|
||||
final List<SeverityBasedTextAttributes> infoTypes = new ArrayList<SeverityBasedTextAttributes>();
|
||||
infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
|
||||
Collections.sort(infoTypes, new Comparator<SeverityBasedTextAttributes>() {
|
||||
@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<SeverityRegistrar.SeverityBasedTextAttributes> infoTypes =
|
||||
new HashSet<SeverityRegistrar.SeverityBasedTextAttributes>(mySeverityRegistrar.getRegisteredHighlightingInfoTypes());
|
||||
final Collection<SeverityBasedTextAttributes> infoTypes =
|
||||
new HashSet<SeverityBasedTextAttributes>(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
|
||||
final ListModel listModel = myOptionsList.getModel();
|
||||
final List<HighlightSeverity> order = new ArrayList<HighlightSeverity>();
|
||||
for (int i = listModel.getSize() - 1; i >= 0; i--) {
|
||||
|
||||
@@ -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<NamedScope> result = new ArrayList<NamedScope>();
|
||||
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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<RefElement> EMPTY_REFERNCES_LIST = new ArrayList<RefElement>(0);
|
||||
private static final List<RefElement> EMPTY_REFERNCES_LIST = new ArrayList<RefElement>(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<RefElement> myOutReferences;
|
||||
private ArrayList<RefElement> myInReferences;
|
||||
private List<RefElement> myOutReferences;
|
||||
private List<RefElement> 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;
|
||||
|
||||
@@ -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<RefEntity> myChildren;
|
||||
protected List<RefEntity> 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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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> T getExtension(final Key<T> key) {
|
||||
public <T> T getExtension(@NotNull final Key<T> 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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user