mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-194133 Introduce ScheduledForRemovalInspection
This commit is contained in:
@@ -15,6 +15,11 @@
|
||||
enabledByDefault="true" level="WARNING"
|
||||
key="jvm.inspections.blocking.method.display.name" bundle="com.intellij.jvm.analysis.JvmAnalysisBundle"
|
||||
implementationClass="com.intellij.codeInspection.blockingCallsDetection.BlockingMethodInNonBlockingContextInspection"/>
|
||||
<!-- TODO enable by default -->
|
||||
<localInspection language="UAST" enabledByDefault="false" level="WARNING" shortName="ScheduledForRemoval"
|
||||
groupBundle="com.intellij.jvm.analysis.JvmAnalysisBundle" bundle="com.intellij.jvm.analysis.JvmAnalysisBundle"
|
||||
groupKey="jvm.inspections.group.name" key="jvm.inspections.scheduled.for.removal.display.name"
|
||||
implementationClass="com.intellij.codeInspection.ScheduledForRemovalInspection"/>
|
||||
</extensions>
|
||||
<extensions defaultExtensionNs="com.intellij.codeInsight">
|
||||
<blockingMethodChecker implementation="com.intellij.codeInspection.blockingCallsDetection.ThrowsTypeBlockingMethodChecker"/>
|
||||
|
||||
@@ -4,6 +4,8 @@ jvm.inspections.unstable.api.usage.display.name=Unstable API Usage
|
||||
jvm.inspections.unstable.api.usage.annotations.list=Unstable API annotations
|
||||
jvm.inspections.unstable.api.usage.ignore.inside.imports=Ignore inside imports
|
||||
jvm.inspections.unstable.api.usage.description=''{0}'' is marked unstable
|
||||
jvm.inspections.scheduled.for.removal.display.name=Usage of API scheduled for removal
|
||||
jvm.inspections.scheduled.for.removal.description=''{0}'' is scheduled for removal
|
||||
jvm.inspections.blocking.method.problem.descriptor=Inappropriate blocking method call
|
||||
jvm.inspections.blocking.method.display.name=Inappropriate thread-blocking method call
|
||||
jvm.inspections.blocking.method.annotation.blocking=Blocking Annotations
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
This inspection reports usages of API scheduled for removal (annotated with
|
||||
<code>@ApiStatus.ScheduledForRemoval</code>)
|
||||
<small>New in 2018.3</small>
|
||||
</body>
|
||||
</html>
|
||||
+13
@@ -4,6 +4,7 @@ package com.intellij.codeInspection;
|
||||
import com.intellij.analysis.JvmAnalysisBundle;
|
||||
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -113,4 +114,16 @@ public abstract class AnnotatedElementInspectionBase extends LocalInspectionTool
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static String getReferenceText(@NotNull PsiReference reference) {
|
||||
if (reference instanceof PsiQualifiedReference) {
|
||||
String referenceName = ((PsiQualifiedReference)reference).getReferenceName();
|
||||
if (referenceName != null) {
|
||||
return referenceName;
|
||||
}
|
||||
}
|
||||
// references are not PsiQualifiedReference for annotation attributes
|
||||
return StringUtil.getShortName(reference.getCanonicalText());
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.analysis.JvmAnalysisBundle;
|
||||
import com.intellij.psi.PsiModifierListOwner;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
//TODO quickfix like in deprecation inspection?
|
||||
public class ScheduledForRemovalInspection extends AnnotatedElementInspectionBase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<String> getAnnotations() {
|
||||
return Collections.singletonList(ApiStatus.ScheduledForRemoval.class.getCanonicalName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createProblem(@NotNull PsiReference reference, @NotNull ProblemsHolder holder) {
|
||||
//TODO determine highlight severity like in MarkedForRemovalInspection (and extend the description)?
|
||||
String message = JvmAnalysisBundle.message("jvm.inspections.scheduled.for.removal.description", getReferenceText(reference));
|
||||
holder.registerProblem(reference, message, ProblemHighlightType.LIKE_MARKED_FOR_REMOVAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldProcessElement(@NotNull PsiModifierListOwner element) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import com.intellij.analysis.JvmAnalysisBundle;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.ig.ui.ExternalizableStringSet;
|
||||
@@ -74,16 +73,4 @@ public class UnstableApiUsageInspection extends AnnotatedElementInspectionBase {
|
||||
}
|
||||
return ProjectFileIndex.getInstance(element.getProject()).isInLibraryClasses(containingVirtualFile);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getReferenceText(@NotNull PsiReference reference) {
|
||||
if (reference instanceof PsiQualifiedReference) {
|
||||
String referenceName = ((PsiQualifiedReference)reference).getReferenceName();
|
||||
if (referenceName != null) {
|
||||
return referenceName;
|
||||
}
|
||||
}
|
||||
// references are not PsiQualifiedReference for annotation attributes
|
||||
return StringUtil.getShortName(reference.getCanonicalText());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user