mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[java] reuse primitive types from PsiTypes
GitOrigin-RevId: ed85ff9e35ae755b1307203e81acbdf56a2fa11a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
48fc0dcf51
commit
ce0c710c4a
@@ -75,10 +75,6 @@ public final class ExpectedTypesProvider {
|
||||
return ArrayUtil.mergeArrays(sourceMethods, libraryMethods);
|
||||
}
|
||||
};
|
||||
private static final PsiType[] PRIMITIVE_TYPES = {PsiTypes.byteType(), PsiTypes.charType(), PsiTypes.shortType(), PsiTypes.intType(),
|
||||
PsiTypes.longType(),
|
||||
PsiTypes.floatType(),
|
||||
PsiTypes.doubleType()};
|
||||
|
||||
public static @NotNull ExpectedTypeInfo createInfo(@NotNull PsiType type, @ExpectedTypeInfo.Type int kind, PsiType defaultType, @NotNull TailType tailType) {
|
||||
return createInfoImpl(type, kind, defaultType, tailType);
|
||||
@@ -221,10 +217,9 @@ public final class ExpectedTypesProvider {
|
||||
@NotNull Set<? super PsiType> set) {
|
||||
if (type.equals(PsiTypes.booleanType()) || type.equals(PsiTypes.voidType()) || type.equals(PsiTypes.nullType())) return;
|
||||
|
||||
for (int i = 0; ; i++) {
|
||||
final PsiType primitive = PRIMITIVE_TYPES[i];
|
||||
processType(primitive, visitor, set);
|
||||
if (primitive.equals(type)) return;
|
||||
for (PsiPrimitiveType primitiveType : PsiTypes.primitiveTypes()) {
|
||||
processType(primitiveType, visitor, set);
|
||||
if (primitiveType.equals(type)) return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,11 +229,16 @@ public final class ExpectedTypesProvider {
|
||||
if (type instanceof PsiPrimitiveType) {
|
||||
if (type.equals(PsiTypes.booleanType()) || type.equals(PsiTypes.voidType()) || type.equals(PsiTypes.nullType())) return;
|
||||
|
||||
List<PsiPrimitiveType> primitiveTypes = PsiTypes.primitiveTypes();
|
||||
Stack<PsiType> stack = new Stack<>();
|
||||
for (int i = PRIMITIVE_TYPES.length - 1; !PRIMITIVE_TYPES[i].equals(type); i--) {
|
||||
stack.push(PRIMITIVE_TYPES[i]);
|
||||
for (int i = primitiveTypes.size() - 1; i >= 0; i--) {
|
||||
PsiPrimitiveType primitiveType = primitiveTypes.get(i);
|
||||
if (primitiveTypes.get(i).equals(type)) break;
|
||||
//it is already processed before
|
||||
if (primitiveType.equals(PsiTypes.booleanType())) continue;
|
||||
stack.push(primitiveType);
|
||||
}
|
||||
while(!stack.empty()) {
|
||||
while (!stack.empty()) {
|
||||
processType(stack.pop(), visitor, set);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,18 +40,6 @@ import static org.jetbrains.plugins.groovy.lang.psi.GroovyElementTypes.*;
|
||||
|
||||
public final class TypesUtil implements TypeConstants {
|
||||
|
||||
public static final PsiPrimitiveType[] PRIMITIVES = {
|
||||
PsiTypes.byteType(),
|
||||
PsiTypes.charType(),
|
||||
PsiTypes.doubleType(),
|
||||
PsiTypes.floatType(),
|
||||
PsiTypes.intType(),
|
||||
PsiTypes.shortType(),
|
||||
PsiTypes.longType(),
|
||||
PsiTypes.booleanType(),
|
||||
PsiTypes.voidType()
|
||||
};
|
||||
|
||||
private TypesUtil() {
|
||||
}
|
||||
|
||||
@@ -553,17 +541,12 @@ public final class TypesUtil implements TypeConstants {
|
||||
|
||||
@NotNull
|
||||
public static PsiPrimitiveType getPrimitiveTypeByText(String typeText) {
|
||||
for (final PsiPrimitiveType primitive : PRIMITIVES) {
|
||||
if (PsiTypes.voidType().equals(primitive)) {
|
||||
return primitive;
|
||||
}
|
||||
if (primitive.getCanonicalText().equals(typeText)) {
|
||||
return primitive;
|
||||
for (PsiPrimitiveType primitiveType : PsiTypes.primitiveTypes()) {
|
||||
if (primitiveType.getCanonicalText().equals(typeText)) {
|
||||
return primitiveType;
|
||||
}
|
||||
}
|
||||
|
||||
assert false : "Unknown primitive type";
|
||||
return null;
|
||||
return PsiTypes.voidType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user