mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Cleanup (common constant)
This commit is contained in:
+2
-16
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 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.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
@@ -1043,7 +1029,7 @@ public class GenericsHighlightUtil {
|
||||
@Nullable
|
||||
static HighlightInfo checkSafeVarargsAnnotation(PsiMethod method, LanguageLevel languageLevel) {
|
||||
PsiModifierList list = method.getModifierList();
|
||||
final PsiAnnotation safeVarargsAnnotation = list.findAnnotation("java.lang.SafeVarargs");
|
||||
final PsiAnnotation safeVarargsAnnotation = list.findAnnotation(CommonClassNames.JAVA_LANG_SAFE_VARARGS);
|
||||
if (safeVarargsAnnotation == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+3
-3
@@ -92,7 +92,7 @@ public class PossibleHeapPollutionVarargsInspection extends AbstractBaseJavaLoca
|
||||
if (psiElement instanceof PsiIdentifier) {
|
||||
final PsiMethod psiMethod = (PsiMethod)psiElement.getParent();
|
||||
if (psiMethod != null) {
|
||||
new AddAnnotationPsiFix("java.lang.SafeVarargs", psiMethod, PsiNameValuePair.EMPTY_ARRAY).applyFix(project, descriptor);
|
||||
new AddAnnotationPsiFix(CommonClassNames.JAVA_LANG_SAFE_VARARGS, psiMethod, PsiNameValuePair.EMPTY_ARRAY).applyFix(project, descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class PossibleHeapPollutionVarargsInspection extends AbstractBaseJavaLoca
|
||||
if (psiElement instanceof PsiIdentifier) {
|
||||
final PsiMethod psiMethod = (PsiMethod)psiElement.getParent();
|
||||
WriteAction.run(() -> psiMethod.getModifierList().setModifierProperty(PsiModifier.FINAL, true));
|
||||
new AddAnnotationPsiFix("java.lang.SafeVarargs", psiMethod, PsiNameValuePair.EMPTY_ARRAY).applyFix(project, descriptor);
|
||||
new AddAnnotationPsiFix(CommonClassNames.JAVA_LANG_SAFE_VARARGS, psiMethod, PsiNameValuePair.EMPTY_ARRAY).applyFix(project, descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class PossibleHeapPollutionVarargsInspection extends AbstractBaseJavaLoca
|
||||
public void visitMethod(PsiMethod method) {
|
||||
super.visitMethod(method);
|
||||
if (!PsiUtil.getLanguageLevel(method).isAtLeast(LanguageLevel.JDK_1_7)) return;
|
||||
if (AnnotationUtil.isAnnotated(method, "java.lang.SafeVarargs", 0)) return;
|
||||
if (AnnotationUtil.isAnnotated(method, CommonClassNames.JAVA_LANG_SAFE_VARARGS, 0)) return;
|
||||
if (!method.isVarArgs()) return;
|
||||
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ public class JavaGenericsUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AnnotationUtil.isAnnotated(psiMethod, "java.lang.SafeVarargs", CHECK_EXTERNAL)) {
|
||||
if (AnnotationUtil.isAnnotated(psiMethod, CommonClassNames.JAVA_LANG_SAFE_VARARGS, CHECK_EXTERNAL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,9 @@ public interface CommonClassNames {
|
||||
String JAVA_LANG_CLONEABLE = "java.lang.Cloneable";
|
||||
String JAVA_LANG_COMPARABLE = "java.lang.Comparable";
|
||||
|
||||
String JAVA_LANG_SAFE_VARARGS = "java.lang.SafeVarargs";
|
||||
String JAVA_LANG_FUNCTIONAL_INTERFACE = "java.lang.FunctionalInterface";
|
||||
|
||||
String JAVA_LANG_NULL_POINTER_EXCEPTION = "java.lang.NullPointerException";
|
||||
|
||||
String JAVA_UTIL_CONCURRENT_FUTURE = "java.util.concurrent.Future";
|
||||
@@ -103,7 +106,6 @@ public interface CommonClassNames {
|
||||
String JAVA_LANG_INVOKE_MH_POLYMORPHIC = "java.lang.invoke.MethodHandle.PolymorphicSignature";
|
||||
|
||||
String CLASS_FILE_EXTENSION = ".class";
|
||||
String JAVA_LANG_FUNCTIONAL_INTERFACE = "java.lang.FunctionalInterface";
|
||||
|
||||
//<editor-fold desc="Deprecated stuff.">
|
||||
/** @deprecated use {@link #JAVA_UTIL_FUNCTION_BI_FUNCTION} (to be removed in IDEA 2019) */
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package com.siyeh.ig.classlayout;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
@@ -61,7 +62,7 @@ public class FinalMethodInFinalClassInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
if (!method.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
AnnotationUtil.findAnnotation(method, true, "java.lang.SafeVarargs") != null) {
|
||||
AnnotationUtil.findAnnotation(method, true, CommonClassNames.JAVA_LANG_SAFE_VARARGS) != null) {
|
||||
return;
|
||||
}
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package com.siyeh.ig.classlayout;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
@@ -66,7 +67,7 @@ public class FinalPrivateMethodInspection extends BaseInspection {
|
||||
|| !method.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
return;
|
||||
}
|
||||
if (AnnotationUtil.isAnnotated(method, "java.lang.SafeVarargs", 0) && method.isVarArgs()) {
|
||||
if (AnnotationUtil.isAnnotated(method, CommonClassNames.JAVA_LANG_SAFE_VARARGS, 0) && method.isVarArgs()) {
|
||||
return;
|
||||
}
|
||||
registerModifierError(PsiModifier.FINAL, method, PsiModifier.FINAL);
|
||||
|
||||
+1
-2
@@ -34,7 +34,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -118,7 +117,7 @@ public class VarargParameterInspection extends BaseInspection {
|
||||
}
|
||||
final PsiType arrayType = type.toArrayType();
|
||||
final PsiTypeElement newTypeElement = JavaPsiFacade.getElementFactory(lastParameter.getProject()).createTypeElement(arrayType);
|
||||
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, "java.lang.SafeVarargs");
|
||||
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, CommonClassNames.JAVA_LANG_SAFE_VARARGS);
|
||||
if (annotation != null) {
|
||||
annotation.delete();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user