mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
simplify inspection warning and cleanup
This commit is contained in:
@@ -1345,8 +1345,7 @@ unnecessarily.qualified.static.usage.problem.descriptor1=Unnecessarily qualified
|
||||
unnecessarily.qualified.static.usage.ignore.field.option=Ignore unnecessarily qualified field accesses
|
||||
unnecessarily.qualified.static.usage.ignore.method.option=Ignore unnecessarily qualified method calls
|
||||
unnecessary.interface.modifier.problem.descriptor=Modifier <code>#ref</code> is redundant for interfaces #loc
|
||||
unnecessary.interface.modifier.inner.interface.of.interface.problem.descriptor=Modifier <code>#ref</code> is redundant for inner interfaces of interfaces #loc
|
||||
unnecessary.interface.modifier.inner.interface.of.class.problem.descriptor=Modifier <code>#ref</code> is redundant for inner interfaces of classes #loc
|
||||
unnecessary.interface.modifier.inner.interface.of.interface.problem.descriptor=Modifier <code>#ref</code> is redundant for inner interfaces #loc
|
||||
unnecessary.interface.modifier.problem.descriptor2=Modifier <code>#ref</code> is redundant for interface methods #loc
|
||||
unnecessary.interface.modifier.problem.descriptor3=Modifier <code>#ref</code> is redundant for inner classes of interfaces #loc
|
||||
unnecessary.interface.modifier.problem.descriptor4=Modifier <code>#ref</code> is redundant for interface fields #loc
|
||||
|
||||
+21
-48
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package com.siyeh.ig.style;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
@@ -33,26 +32,20 @@ import java.util.Set;
|
||||
public class UnnecessaryInterfaceModifierInspection extends BaseInspection {
|
||||
|
||||
private static final Set<String> INTERFACE_REDUNDANT_MODIFIERS =
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.ABSTRACT,
|
||||
PsiModifier.STATIC));
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.ABSTRACT, PsiModifier.STATIC));
|
||||
private static final Set<String> INNER_CLASS_REDUNDANT_MODIFIERS =
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.PUBLIC,
|
||||
PsiModifier.STATIC));
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.PUBLIC, PsiModifier.STATIC));
|
||||
private static final Set<String> INNER_INTERFACE_REDUNDANT_MODIFIERS =
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.PUBLIC,
|
||||
PsiModifier.ABSTRACT, PsiModifier.STATIC));
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.PUBLIC, PsiModifier.ABSTRACT, PsiModifier.STATIC));
|
||||
private static final Set<String> FIELD_REDUNDANT_MODIFIERS =
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.PUBLIC,
|
||||
PsiModifier.STATIC, PsiModifier.FINAL));
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.PUBLIC, PsiModifier.STATIC, PsiModifier.FINAL));
|
||||
private static final Set<String> METHOD_REDUNDANT_MODIFIERS =
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.PUBLIC,
|
||||
PsiModifier.ABSTRACT));
|
||||
new HashSet<String>(Arrays.asList(PsiModifier.PUBLIC, PsiModifier.ABSTRACT));
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.interface.modifier.display.name");
|
||||
return InspectionGadgetsBundle.message("unnecessary.interface.modifier.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,32 +58,21 @@ public class UnnecessaryInterfaceModifierInspection extends BaseInspection {
|
||||
final PsiClass containingClass = aClass.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
if (aClass.isInterface()) {
|
||||
if (containingClass.isInterface()) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.interface.modifier.inner.interface.of.interface.problem.descriptor");
|
||||
}
|
||||
else {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.interface.modifier.inner.interface.of.class.problem.descriptor");
|
||||
}
|
||||
return InspectionGadgetsBundle.message("unnecessary.interface.modifier.inner.interface.of.interface.problem.descriptor");
|
||||
}
|
||||
else {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.interface.modifier.problem.descriptor3");
|
||||
return InspectionGadgetsBundle.message("unnecessary.interface.modifier.problem.descriptor3");
|
||||
}
|
||||
}
|
||||
else {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.interface.modifier.problem.descriptor");
|
||||
return InspectionGadgetsBundle.message("unnecessary.interface.modifier.problem.descriptor");
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiMethod) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.interface.modifier.problem.descriptor2");
|
||||
return InspectionGadgetsBundle.message("unnecessary.interface.modifier.problem.descriptor2");
|
||||
}
|
||||
else {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"unnecessary.interface.modifier.problem.descriptor4");
|
||||
return InspectionGadgetsBundle.message("unnecessary.interface.modifier.problem.descriptor4");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +86,7 @@ public class UnnecessaryInterfaceModifierInspection extends BaseInspection {
|
||||
return new UnnecessaryInterfaceModifiersFix((String)infos[0]);
|
||||
}
|
||||
|
||||
private static class UnnecessaryInterfaceModifiersFix
|
||||
extends InspectionGadgetsFix {
|
||||
private static class UnnecessaryInterfaceModifiersFix extends InspectionGadgetsFix {
|
||||
|
||||
private final String modifiersText;
|
||||
|
||||
@@ -115,13 +96,11 @@ public class UnnecessaryInterfaceModifierInspection extends BaseInspection {
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"smth.unnecessary.remove.quickfix", modifiersText);
|
||||
return InspectionGadgetsBundle.message("smth.unnecessary.remove.quickfix", modifiersText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFix(Project project, ProblemDescriptor descriptor)
|
||||
throws IncorrectOperationException {
|
||||
public void doFix(Project project, ProblemDescriptor descriptor) {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
final PsiModifierList modifierList;
|
||||
if (element instanceof PsiModifierList) {
|
||||
@@ -142,8 +121,7 @@ public class UnnecessaryInterfaceModifierInspection extends BaseInspection {
|
||||
if (aClass.isInterface()) {
|
||||
modifierList.setModifierProperty(PsiModifier.ABSTRACT, false);
|
||||
}
|
||||
final PsiClass containingClass =
|
||||
ClassUtils.getContainingClass(modifierOwner);
|
||||
final PsiClass containingClass = ClassUtils.getContainingClass(modifierOwner);
|
||||
if (containingClass != null && containingClass.isInterface()) {
|
||||
// do the inner classes
|
||||
modifierList.setModifierProperty(PsiModifier.PUBLIC, false);
|
||||
@@ -160,8 +138,7 @@ public class UnnecessaryInterfaceModifierInspection extends BaseInspection {
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnnecessaryInterfaceModifierVisitor
|
||||
extends BaseInspectionVisitor {
|
||||
private static class UnnecessaryInterfaceModifierVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitClass(@NotNull PsiClass aClass) {
|
||||
@@ -169,18 +146,15 @@ public class UnnecessaryInterfaceModifierInspection extends BaseInspection {
|
||||
if (parent != null && parent.isInterface()) {
|
||||
final PsiModifierList modifiers = aClass.getModifierList();
|
||||
if (aClass.isInterface()) {
|
||||
checkForRedundantModifiers(modifiers,
|
||||
INNER_INTERFACE_REDUNDANT_MODIFIERS);
|
||||
checkForRedundantModifiers(modifiers, INNER_INTERFACE_REDUNDANT_MODIFIERS);
|
||||
}
|
||||
else {
|
||||
checkForRedundantModifiers(modifiers,
|
||||
INNER_CLASS_REDUNDANT_MODIFIERS);
|
||||
checkForRedundantModifiers(modifiers, INNER_CLASS_REDUNDANT_MODIFIERS);
|
||||
}
|
||||
}
|
||||
else if (aClass.isInterface()) {
|
||||
final PsiModifierList modifiers = aClass.getModifierList();
|
||||
checkForRedundantModifiers(modifiers,
|
||||
INTERFACE_REDUNDANT_MODIFIERS);
|
||||
checkForRedundantModifiers(modifiers, INTERFACE_REDUNDANT_MODIFIERS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,8 +186,7 @@ public class UnnecessaryInterfaceModifierInspection extends BaseInspection {
|
||||
checkForRedundantModifiers(modifiers, METHOD_REDUNDANT_MODIFIERS);
|
||||
}
|
||||
|
||||
public void checkForRedundantModifiers(PsiModifierList list,
|
||||
Set<String> modifiers) {
|
||||
public void checkForRedundantModifiers(PsiModifierList list, Set<String> modifiers) {
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user