mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: cleanup and test
This commit is contained in:
+8
-15
@@ -37,15 +37,13 @@ public class UnnecessarySuperConstructorInspection extends BaseInspection implem
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.super.constructor.display.name");
|
||||
return InspectionGadgetsBundle.message("unnecessary.super.constructor.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected String buildErrorString(Object... infos) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.super.constructor.problem.descriptor");
|
||||
return InspectionGadgetsBundle.message("unnecessary.super.constructor.problem.descriptor");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,14 +51,12 @@ public class UnnecessarySuperConstructorInspection extends BaseInspection implem
|
||||
return new UnnecessarySuperConstructorFix();
|
||||
}
|
||||
|
||||
private static class UnnecessarySuperConstructorFix
|
||||
extends InspectionGadgetsFix {
|
||||
private static class UnnecessarySuperConstructorFix extends InspectionGadgetsFix {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.super.constructor.remove.quickfix");
|
||||
return InspectionGadgetsBundle.message("unnecessary.super.constructor.remove.quickfix");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,19 +73,16 @@ public class UnnecessarySuperConstructorInspection extends BaseInspection implem
|
||||
return new UnnecessarySuperConstructorVisitor();
|
||||
}
|
||||
|
||||
private static class UnnecessarySuperConstructorVisitor
|
||||
extends BaseInspectionVisitor {
|
||||
private static class UnnecessarySuperConstructorVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitMethodCallExpression(
|
||||
@NotNull PsiMethodCallExpression call) {
|
||||
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
|
||||
super.visitMethodCallExpression(call);
|
||||
PsiReferenceExpression methodExpression = call.getMethodExpression();
|
||||
final PsiReferenceExpression methodExpression = call.getMethodExpression();
|
||||
if (methodExpression.isQualified() || !PsiKeyword.SUPER.equals(methodExpression.getReferenceName())) {
|
||||
return;
|
||||
}
|
||||
PsiExpression[] args = call.getArgumentList().getExpressions();
|
||||
if (args.length != 0) {
|
||||
if (!call.getArgumentList().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
registerError(call, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// 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.siyeh.ig.style;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class UnnecessarySuperConstructorInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testQualifiedSuper() {
|
||||
doTest("class Outer {" +
|
||||
" class Super {}" +
|
||||
" class Inner extends Super {" +
|
||||
" Inner(Outer outer) {" +
|
||||
" outer.super();" +
|
||||
" }" +
|
||||
" }" +
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testSimple() {
|
||||
doTest("class Simple {" +
|
||||
" Simple() {" +
|
||||
" /*'super()' is unnecessary*/super()/**/;" +
|
||||
" }" +
|
||||
"}");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new UnnecessarySuperConstructorInspection();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user