mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-21 14:37:45 +07:00
CommonClassNames.JAVA_UTIL_ITERATOR
This commit is contained in:
@@ -30,6 +30,7 @@ public interface CommonClassNames {
|
||||
@NonNls String JAVA_LANG_RUNTIME_EXCEPTION = "java.lang.RuntimeException";
|
||||
@NonNls String JAVA_LANG_ENUM = "java.lang.Enum";
|
||||
@NonNls String JAVA_LANG_ITERABLE = "java.lang.Iterable";
|
||||
@NonNls String JAVA_UTIL_ITERATOR = "java.util.Iterator";
|
||||
|
||||
@NonNls String JAVA_LANG_DEPRECATED = "java.lang.Deprecated";
|
||||
@NonNls String JAVA_LANG_ANNOTATION_INHERITED = "java.lang.annotation.Inherited";
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.siyeh.ig.bugs;
|
||||
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.siyeh.HardcodedMethodConstants;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
@@ -50,7 +51,7 @@ public class IteratorHasNextCallsIteratorNextInspection
|
||||
@Override public void visitMethod(@NotNull PsiMethod method){
|
||||
// note: no call to super
|
||||
@NonNls final String name = method.getName();
|
||||
if (!MethodUtils.methodMatches(method, "java.util.Iterator", null,
|
||||
if (!MethodUtils.methodMatches(method, CommonClassNames.JAVA_UTIL_ITERATOR, null,
|
||||
HardcodedMethodConstants.HAS_NEXT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class IteratorNextDoesNotThrowNoSuchElementExceptionInspection
|
||||
|
||||
@Override public void visitMethod(@NotNull PsiMethod method){
|
||||
// note: no call to super
|
||||
if (!MethodUtils.methodMatches(method, "java.util.Iterator", null,
|
||||
if (!MethodUtils.methodMatches(method, CommonClassNames.JAVA_UTIL_ITERATOR, null,
|
||||
HardcodedMethodConstants.NEXT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ public class ForLoopWithMissingComponentInspection extends BaseInspection {
|
||||
if(declaredClass == null){
|
||||
return false;
|
||||
}
|
||||
if(!ClassUtils.isSubclass(declaredClass, "java.util.Iterator")){
|
||||
if(!ClassUtils.isSubclass(declaredClass, CommonClassNames.JAVA_UTIL_ITERATOR)){
|
||||
return false;
|
||||
}
|
||||
final PsiExpression initialValue = variable.getInitializer();
|
||||
|
||||
+2
-2
@@ -187,7 +187,7 @@ public class EnumerationCanBeIterationInspection extends BaseInspection {
|
||||
if (codeStyleSettings.GENERATE_FINAL_LOCALS) {
|
||||
newStatementText.append("final ");
|
||||
}
|
||||
newStatementText.append("java.util.Iterator");
|
||||
newStatementText.append(CommonClassNames.JAVA_UTIL_ITERATOR);
|
||||
if (parameterType != null) {
|
||||
final String typeText = parameterType.getCanonicalText();
|
||||
newStatementText.append('<');
|
||||
@@ -318,7 +318,7 @@ public class EnumerationCanBeIterationInspection extends BaseInspection {
|
||||
final PsiElementFactory factory = facade.getElementFactory();
|
||||
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
|
||||
final PsiClass iteratorClass =
|
||||
facade.findClass("java.util.Iterator", scope);
|
||||
facade.findClass(CommonClassNames.JAVA_UTIL_ITERATOR, scope);
|
||||
if (iteratorClass == null) {
|
||||
return "iterator";
|
||||
}
|
||||
|
||||
@@ -1067,7 +1067,7 @@ public class ForCanBeForeachInspection extends BaseInspection{
|
||||
if(declaredClass == null){
|
||||
return false;
|
||||
}
|
||||
if(!ClassUtils.isSubclass(declaredClass, "java.util.Iterator")){
|
||||
if(!ClassUtils.isSubclass(declaredClass, CommonClassNames.JAVA_UTIL_ITERATOR)){
|
||||
return false;
|
||||
}
|
||||
final PsiExpression initialValue = variable.getInitializer();
|
||||
|
||||
@@ -430,7 +430,7 @@ public class WhileCanBeForeachInspection extends BaseInspection {
|
||||
final PsiVariable variable = (PsiVariable)declaredElement;
|
||||
final PsiType variableType = variable.getType();
|
||||
final PsiType iteratorType =
|
||||
TypeUtils.getType("java.util.Iterator", whileStatement);
|
||||
TypeUtils.getType(CommonClassNames.JAVA_UTIL_ITERATOR, whileStatement);
|
||||
if (iteratorType == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ public class IteratorUtils {
|
||||
public static boolean isCallToHasNext(
|
||||
PsiMethodCallExpression methodCallExpression) {
|
||||
return MethodCallUtils.isCallToMethod(methodCallExpression,
|
||||
"java.util.Iterator", PsiType.BOOLEAN, "hasNext");
|
||||
CommonClassNames.JAVA_UTIL_ITERATOR, PsiType.BOOLEAN, "hasNext");
|
||||
}
|
||||
|
||||
public static boolean isIterator(PsiClass aClass) {
|
||||
return ClassUtils.isSubclass(aClass, "java.util.Iterator");
|
||||
return ClassUtils.isSubclass(aClass, CommonClassNames.JAVA_UTIL_ITERATOR);
|
||||
}
|
||||
|
||||
private static class CallsIteratorNextVisitor
|
||||
@@ -91,12 +91,12 @@ public class IteratorUtils {
|
||||
super.visitMethodCallExpression(expression);
|
||||
if (checkScanner) {
|
||||
if (!MethodCallUtils.isCallToMethod(expression,
|
||||
"java.util.Iterator", null, SCANNER_PATTERN)) {
|
||||
CommonClassNames.JAVA_UTIL_ITERATOR, null, SCANNER_PATTERN)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!MethodCallUtils.isCallToMethod(expression,
|
||||
"java.util.Iterator", null,
|
||||
CommonClassNames.JAVA_UTIL_ITERATOR, null,
|
||||
HardcodedMethodConstants.NEXT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user