mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
cleanup: get rid of usages of deprecated constants from PsiType (IDEA-309438)
GitOrigin-RevId: 3373eb8b47af51b9f6dd71e565f773d69e8a3218
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0a1df5c00a
commit
8ce3039acf
@@ -3,6 +3,7 @@ package de.plushnikov.intellij.plugin.action.lombok;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.PsiTypes;
|
||||
import de.plushnikov.intellij.plugin.LombokClassNames;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -10,13 +11,13 @@ public class LombokEqualsAndHashcodeHandler extends BaseLombokHandler {
|
||||
|
||||
@Override
|
||||
protected void processClass(@NotNull PsiClass psiClass) {
|
||||
final PsiMethod equalsMethod = findPublicNonStaticMethod(psiClass, "equals", PsiType.BOOLEAN,
|
||||
PsiType.getJavaLangObject(psiClass.getManager(), psiClass.getResolveScope()));
|
||||
final PsiMethod equalsMethod = findPublicNonStaticMethod(psiClass, "equals", PsiTypes.booleanType(),
|
||||
PsiType.getJavaLangObject(psiClass.getManager(), psiClass.getResolveScope()));
|
||||
if (null != equalsMethod) {
|
||||
equalsMethod.delete();
|
||||
}
|
||||
|
||||
final PsiMethod hashCodeMethod = findPublicNonStaticMethod(psiClass, "hashCode", PsiType.INT);
|
||||
final PsiMethod hashCodeMethod = findPublicNonStaticMethod(psiClass, "hashCode", PsiTypes.intType());
|
||||
if (null != hashCodeMethod) {
|
||||
hashCodeMethod.delete();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class LombokRenameFieldReferenceProcessor extends RenameJavaVariableProce
|
||||
final PsiClass containingClass = psiField.getContainingClass();
|
||||
final String currentFieldName = psiField.getName();
|
||||
if (null != containingClass) {
|
||||
final boolean isBoolean = PsiType.BOOLEAN.equals(psiField.getType());
|
||||
final boolean isBoolean = PsiTypes.booleanType().equals(psiField.getType());
|
||||
|
||||
final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField);
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public final class EqualsAndHashCodeProcessor extends AbstractClassProcessor {
|
||||
|
||||
final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(psiManager, EQUALS_METHOD_NAME)
|
||||
.withModifier(PsiModifier.PUBLIC)
|
||||
.withMethodReturnType(PsiType.BOOLEAN)
|
||||
.withMethodReturnType(PsiTypes.booleanType())
|
||||
.withContainingClass(psiClass)
|
||||
.withNavigationElement(psiAnnotation)
|
||||
.withFinalParameter("o", PsiType.getJavaLangObject(psiManager, psiClass.getResolveScope()));
|
||||
@@ -208,7 +208,7 @@ public final class EqualsAndHashCodeProcessor extends AbstractClassProcessor {
|
||||
|
||||
return new LombokLightMethodBuilder(psiManager, HASH_CODE_METHOD_NAME)
|
||||
.withModifier(PsiModifier.PUBLIC)
|
||||
.withMethodReturnType(PsiType.INT)
|
||||
.withMethodReturnType(PsiTypes.intType())
|
||||
.withContainingClass(psiClass)
|
||||
.withNavigationElement(psiAnnotation)
|
||||
.withBodyText(m -> {
|
||||
@@ -227,7 +227,7 @@ public final class EqualsAndHashCodeProcessor extends AbstractClassProcessor {
|
||||
final String blockText = String.format("return other instanceof %s;", PsiTypesUtil.getClassType(psiClass).getCanonicalText());
|
||||
final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(psiManager, CAN_EQUAL_METHOD_NAME)
|
||||
.withModifier(PsiModifier.PROTECTED)
|
||||
.withMethodReturnType(PsiType.BOOLEAN)
|
||||
.withMethodReturnType(PsiTypes.booleanType())
|
||||
.withContainingClass(psiClass)
|
||||
.withNavigationElement(psiAnnotation)
|
||||
.withFinalParameter("other", PsiType.getJavaLangObject(psiManager, psiClass.getResolveScope()));
|
||||
@@ -275,11 +275,11 @@ public final class EqualsAndHashCodeProcessor extends AbstractClassProcessor {
|
||||
|
||||
final PsiType memberType = memberInfo.getType();
|
||||
if (memberType instanceof PsiPrimitiveType) {
|
||||
if (PsiType.FLOAT.equals(memberType)) {
|
||||
if (PsiTypes.floatType().equals(memberType)) {
|
||||
builder.append("if (java.lang.Float.compare(this.").append(memberAccessor).append(", other.").append(memberAccessor)
|
||||
.append(") != 0) return false;\n");
|
||||
}
|
||||
else if (PsiType.DOUBLE.equals(memberType)) {
|
||||
else if (PsiTypes.doubleType().equals(memberType)) {
|
||||
builder.append("if (java.lang.Double.compare(this.").append(memberAccessor).append(", other.").append(memberAccessor)
|
||||
.append(") != 0) return false;\n");
|
||||
}
|
||||
@@ -343,18 +343,18 @@ public final class EqualsAndHashCodeProcessor extends AbstractClassProcessor {
|
||||
|
||||
final PsiType classFieldType = memberInfo.getType();
|
||||
if (classFieldType instanceof PsiPrimitiveType) {
|
||||
if (PsiType.BOOLEAN.equals(classFieldType)) {
|
||||
if (PsiTypes.booleanType().equals(classFieldType)) {
|
||||
builder.append("result = result * PRIME + (this.").append(memberAccessor).append(" ? ").append(PRIME_FOR_TRUE).append(" : ")
|
||||
.append(PRIME_FOR_FALSE).append(");\n");
|
||||
}
|
||||
else if (PsiType.LONG.equals(classFieldType)) {
|
||||
else if (PsiTypes.longType().equals(classFieldType)) {
|
||||
builder.append("final long $").append(memberName).append(" = this.").append(memberAccessor).append(";\n");
|
||||
builder.append("result = result * PRIME + (int)($").append(memberName).append(" >>> 32 ^ $").append(memberName).append(");\n");
|
||||
}
|
||||
else if (PsiType.FLOAT.equals(classFieldType)) {
|
||||
else if (PsiTypes.floatType().equals(classFieldType)) {
|
||||
builder.append("result = result * PRIME + java.lang.Float.floatToIntBits(this.").append(memberAccessor).append(");\n");
|
||||
}
|
||||
else if (PsiType.DOUBLE.equals(classFieldType)) {
|
||||
else if (PsiTypes.doubleType().equals(classFieldType)) {
|
||||
builder.append("final long $").append(memberName).append(" = java.lang.Double.doubleToLongBits(this.").append(memberAccessor)
|
||||
.append(");\n");
|
||||
builder.append("result = result * PRIME + (int)($").append(memberName).append(" >>> 32 ^ $").append(memberName).append(");\n");
|
||||
|
||||
@@ -99,7 +99,7 @@ public final class GetterProcessor extends AbstractClassProcessor {
|
||||
//Skip fields if a method with same name and arguments count already exists
|
||||
final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField, classAccessorsValues);
|
||||
final Collection<String> methodNames =
|
||||
LombokUtils.toAllGetterNames(accessorsInfo, psiField.getName(), PsiType.BOOLEAN.equals(psiField.getType()));
|
||||
LombokUtils.toAllGetterNames(accessorsInfo, psiField.getName(), PsiTypes.booleanType().equals(psiField.getType()));
|
||||
for (String methodName : methodNames) {
|
||||
createGetter &= !PsiMethodUtil.hasSimilarMethod(classMethods, methodName, 0);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public final class SetterProcessor extends AbstractClassProcessor {
|
||||
//Skip fields that start with $
|
||||
createSetter &= !psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER);
|
||||
//Skip fields if a method with same name already exists
|
||||
final Collection<String> methodNames = fieldProcessor.getAllSetterNames(psiField, PsiType.BOOLEAN.equals(psiField.getType()));
|
||||
final Collection<String> methodNames = fieldProcessor.getAllSetterNames(psiField, PsiTypes.booleanType().equals(psiField.getType()));
|
||||
for (String methodName : methodNames) {
|
||||
createSetter &= !PsiMethodUtil.hasSimilarMethod(classMethods, methodName, 1);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public abstract class AbstractFieldProcessor extends AbstractProcessor implement
|
||||
|
||||
final List<MethodSignatureBackedByPsiMethod> classMethods = new ArrayList<>(ownSignatures);
|
||||
|
||||
final boolean isBoolean = PsiType.BOOLEAN.equals(psiField.getType());
|
||||
final boolean isBoolean = PsiTypes.booleanType().equals(psiField.getType());
|
||||
final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField);
|
||||
final String fieldName = psiField.getName();
|
||||
String accessorName = isGetter ? LombokUtils.toGetterName(accessorsInfo, fieldName, isBoolean)
|
||||
|
||||
@@ -148,7 +148,7 @@ public final class SetterFieldProcessor extends AbstractFieldProcessor {
|
||||
blockText = String.format("%s.%s = %s; ", thisOrClass, psiField.getName(), methodParameter.getName());
|
||||
|
||||
String codeBlockText = blockText;
|
||||
if (!isStatic && !PsiType.VOID.equals(returnType)) {
|
||||
if (!isStatic && !PsiTypes.voidType().equals(returnType)) {
|
||||
codeBlockText += "return this;";
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public final class SetterFieldProcessor extends AbstractFieldProcessor {
|
||||
}
|
||||
|
||||
private static PsiType getReturnType(@NotNull PsiField psiField, boolean isChained) {
|
||||
PsiType result = PsiType.VOID;
|
||||
PsiType result = PsiTypes.voidType();
|
||||
if (!psiField.hasModifierProperty(PsiModifier.STATIC) && isChained) {
|
||||
final PsiClass fieldClass = psiField.getContainingClass();
|
||||
if (null != fieldClass) {
|
||||
|
||||
@@ -106,7 +106,7 @@ public final class WitherFieldProcessor extends AbstractFieldProcessor {
|
||||
final AccessorsInfo accessorsInfo = buildAccessorsInfo(psiField);
|
||||
final String psiFieldName = psiField.getName();
|
||||
final Collection<String> possibleWitherNames =
|
||||
LombokUtils.toAllWitherNames(accessorsInfo, psiFieldName, PsiType.BOOLEAN.equals(psiField.getType()));
|
||||
LombokUtils.toAllWitherNames(accessorsInfo, psiFieldName, PsiTypes.booleanType().equals(psiField.getType()));
|
||||
for (String witherName : possibleWitherNames) {
|
||||
if (PsiMethodUtil.hasSimilarMethod(classMethods, witherName, 1)) {
|
||||
builder.addWarningMessage("inspection.message.not.generating.s.method.with.that.name.already.exists", witherName);
|
||||
|
||||
@@ -639,7 +639,7 @@ public class BuilderHandler {
|
||||
|
||||
private static boolean isNotBuilderDefaultSetterFields(@NotNull PsiField psiField) {
|
||||
boolean isBuilderDefaultSetter = false;
|
||||
if (psiField.getName().endsWith("$set") && PsiType.BOOLEAN.equals(psiField.getType())) {
|
||||
if (psiField.getName().endsWith("$set") && PsiTypes.booleanType().equals(psiField.getType())) {
|
||||
PsiElement navigationElement = psiField.getNavigationElement();
|
||||
if (navigationElement instanceof PsiField) {
|
||||
isBuilderDefaultSetter = PsiAnnotationSearchUtil.isAnnotatedWith((PsiField)navigationElement, LombokClassNames.BUILDER_DEFAULT);
|
||||
@@ -764,7 +764,7 @@ public class BuilderHandler {
|
||||
callExpressionText = buildMethodReturnType.getPresentableText();
|
||||
}
|
||||
else {
|
||||
if (PsiType.VOID.equals(buildMethodReturnType)) {
|
||||
if (PsiTypes.voidType().equals(buildMethodReturnType)) {
|
||||
codeBlockFormat = "%s\n %s(%s);";
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -241,7 +241,7 @@ public final class DelegateHandler {
|
||||
|
||||
final boolean isMethodCall = psiElement instanceof PsiMethod;
|
||||
blockText = String.format("%sthis.%s%s.%s(%s);",
|
||||
PsiType.VOID.equals(returnType) ? "" : "return ",
|
||||
PsiTypes.voidType().equals(returnType) ? "" : "return ",
|
||||
psiElement.getName(),
|
||||
isMethodCall ? "()" : "",
|
||||
psiMethod.getName(),
|
||||
|
||||
@@ -305,7 +305,7 @@ public class SuperBuilderHandler extends BuilderHandler {
|
||||
if (!existedMethodNames.contains(STATIC_FILL_VALUES_METHOD_NAME)) {
|
||||
// create '$fillValuesFromInstanceIntoBuilder' method
|
||||
final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(psiManager, STATIC_FILL_VALUES_METHOD_NAME)
|
||||
.withMethodReturnType(PsiType.VOID)
|
||||
.withMethodReturnType(PsiTypes.voidType())
|
||||
.withParameter(INSTANCE_VARIABLE_NAME, PsiClassUtil.getTypeWithGenerics(psiClass))
|
||||
.withParameter(BUILDER_VARIABLE_NAME, getTypeWithWildcardsForSuperBuilderTypeParameters(baseClassBuilder))
|
||||
.withContainingClass(baseClassBuilder)
|
||||
|
||||
@@ -27,7 +27,7 @@ class NonSingularHandler implements BuilderElementHandler {
|
||||
.withModifier(PsiModifier.PRIVATE)
|
||||
.withNavigationElement(info.getVariable()));
|
||||
if (info.hasBuilderDefaultAnnotation()) {
|
||||
result.add(new LombokLightFieldBuilder(info.getManager(), info.renderFieldDefaultSetName(), PsiType.BOOLEAN)
|
||||
result.add(new LombokLightFieldBuilder(info.getManager(), info.renderFieldDefaultSetName(), PsiTypes.booleanType())
|
||||
.withContainingClass(info.getBuilderClass())
|
||||
.withModifier(PsiModifier.PRIVATE)
|
||||
.withNavigationElement(info.getVariable()));
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.plushnikov.intellij.plugin.thirdparty;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.PsiTypes;
|
||||
import de.plushnikov.intellij.plugin.processor.field.AccessorsInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -381,7 +381,7 @@ public final class LombokUtils {
|
||||
|
||||
public static String getGetterName(@NotNull PsiField psiField, @NotNull AccessorsInfo accessorsInfo) {
|
||||
final String psiFieldName = psiField.getName();
|
||||
final boolean isBoolean = PsiType.BOOLEAN.equals(psiField.getType());
|
||||
final boolean isBoolean = PsiTypes.booleanType().equals(psiField.getType());
|
||||
|
||||
return toGetterName(accessorsInfo, psiFieldName, isBoolean);
|
||||
}
|
||||
@@ -392,11 +392,11 @@ public final class LombokUtils {
|
||||
}
|
||||
|
||||
public static String getSetterName(@NotNull PsiField psiField, @NotNull AccessorsInfo accessorsInfo) {
|
||||
return toSetterName(accessorsInfo, psiField.getName(), PsiType.BOOLEAN.equals(psiField.getType()));
|
||||
return toSetterName(accessorsInfo, psiField.getName(), PsiTypes.booleanType().equals(psiField.getType()));
|
||||
}
|
||||
|
||||
public static String getWitherName(@NotNull PsiField psiField, @NotNull AccessorsInfo accessorsInfo) {
|
||||
return toWitherName(accessorsInfo.withFluent(false), psiField.getName(), PsiType.BOOLEAN.equals(psiField.getType()));
|
||||
return toWitherName(accessorsInfo.withFluent(false), psiField.getName(), PsiTypes.booleanType().equals(psiField.getType()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ public final class PsiElementUtil {
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
final PsiType type = parameters[i].getType();
|
||||
final PsiType parameterType = parameterTypes.get(i);
|
||||
if (PsiType.NULL.equals(parameterType)) {
|
||||
if (PsiTypes.nullType().equals(parameterType)) {
|
||||
continue;
|
||||
}
|
||||
if (parameterType != null && !typesAreEquivalent(type, parameterType)) {
|
||||
@@ -99,7 +99,7 @@ public final class PsiElementUtil {
|
||||
for (int i = 0; i < firstMethodParameterListParameters.length; i++) {
|
||||
PsiType firstMethodParameterListParameterType = firstSubstitutor.substitute(firstMethodParameterListParameters[i].getType());
|
||||
PsiType secondMethodParameterListParameterType = secondSubstitutor.substitute(secondMethodParameterListParameters[i].getType());
|
||||
if (PsiType.NULL.equals(firstMethodParameterListParameterType)) {
|
||||
if (PsiTypes.nullType().equals(firstMethodParameterListParameterType)) {
|
||||
continue;
|
||||
}
|
||||
if (!typesAreEquivalent(firstMethodParameterListParameterType, secondMethodParameterListParameterType)) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class VarModifierTest extends AbstractLombokLightCodeInsightTestCase {
|
||||
myFixture.type('1');
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
assertTrue(var.isValid());
|
||||
assertEquals(PsiType.INT, var.getType());
|
||||
assertEquals(PsiTypes.intType(), var.getType());
|
||||
|
||||
assertNotNull(var.getModifierList());
|
||||
boolean isFinal = var.getModifierList().hasModifierProperty(PsiModifier.FINAL);
|
||||
|
||||
Reference in New Issue
Block a user