mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
guava type migration: use only one problem descriptor
This commit is contained in:
+5
-6
@@ -53,8 +53,7 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
|
||||
//public class GuavaInspection extends BaseJavaBatchLocalInspectionTool {
|
||||
private final static Logger LOG = Logger.getInstance(GuavaInspection.class);
|
||||
|
||||
public final static String PROBLEM_DESCRIPTION_FOR_VARIABLE = "Guava's functional primitives can be replaced by Java API";
|
||||
public final static String PROBLEM_DESCRIPTION_FOR_METHOD_CHAIN = "Guava's FluentIterable method chain can be replaced by Java API";
|
||||
public final static String PROBLEM_DESCRIPTION = "Guava's functional primitives can be replaced by Java API";
|
||||
|
||||
private final static SoftLazyValue<Set<String>> FLUENT_ITERABLE_STOP_METHODS = new SoftLazyValue<Set<String>>() {
|
||||
@NotNull
|
||||
@@ -116,7 +115,7 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
|
||||
PsiType targetType = getConversionClassType(type);
|
||||
if (targetType != null) {
|
||||
holder.registerProblem(variable.getNameIdentifier(),
|
||||
PROBLEM_DESCRIPTION_FOR_VARIABLE,
|
||||
PROBLEM_DESCRIPTION,
|
||||
new MigrateGuavaTypeFix(variable, targetType));
|
||||
}
|
||||
}
|
||||
@@ -130,7 +129,7 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
|
||||
final PsiTypeElement typeElement = method.getReturnTypeElement();
|
||||
if (typeElement != null) {
|
||||
holder.registerProblem(typeElement,
|
||||
PROBLEM_DESCRIPTION_FOR_VARIABLE,
|
||||
PROBLEM_DESCRIPTION,
|
||||
new MigrateGuavaTypeFix(method, targetType));
|
||||
}
|
||||
}
|
||||
@@ -148,7 +147,7 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
|
||||
PsiClassType targetType = createTargetType(initialType);
|
||||
if (targetType == null) return;
|
||||
holder.registerProblem(expression.getMethodExpression().getReferenceNameElement(),
|
||||
PROBLEM_DESCRIPTION_FOR_VARIABLE,
|
||||
PROBLEM_DESCRIPTION,
|
||||
new MigrateGuavaTypeFix(expression, targetType));
|
||||
}
|
||||
}
|
||||
@@ -171,7 +170,7 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
|
||||
if (chain.getParent() instanceof PsiReferenceExpression && chain.getParent().getParent() instanceof PsiMethodCallExpression) {
|
||||
highlightedElement = chain.getParent().getParent();
|
||||
}
|
||||
holder.registerProblem(highlightedElement, PROBLEM_DESCRIPTION_FOR_METHOD_CHAIN, new MigrateGuavaTypeFix(chain, targetType));
|
||||
holder.registerProblem(highlightedElement, PROBLEM_DESCRIPTION, new MigrateGuavaTypeFix(chain, targetType));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-2
@@ -289,8 +289,7 @@ public class GuavaInspectionTest extends JavaCodeInsightFixtureTestCase {
|
||||
myFixture.configureByFile(getTestName(true) + ".java");
|
||||
myFixture.enableInspections(new GuavaInspection());
|
||||
for (HighlightInfo info : myFixture.doHighlighting())
|
||||
if (GuavaInspection.PROBLEM_DESCRIPTION_FOR_METHOD_CHAIN.equals(info.getDescription()) ||
|
||||
GuavaInspection.PROBLEM_DESCRIPTION_FOR_VARIABLE.equals(info.getDescription())) {
|
||||
if (GuavaInspection.PROBLEM_DESCRIPTION.equals(info.getDescription())) {
|
||||
final Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> marker = info.quickFixActionMarkers.get(0);
|
||||
final PsiElement someElement = myFixture.getFile().findElementAt(0);
|
||||
assertNotNull(someElement);
|
||||
|
||||
Reference in New Issue
Block a user