mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[java] "any" type parsing (early Valhalla prototype) dropped
It's unlikely that the final version of value types in Java will use this syntax. GitOrigin-RevId: 382ec771eaac29c079cf48819f98fd155775b283
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f6e04c6545
commit
5b6191dd34
@@ -792,7 +792,7 @@ public final class GenericsHighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
static HighlightInfo.Builder checkReferenceTypeUsedAsTypeArgument(@NotNull PsiTypeElement typeElement, @NotNull LanguageLevel level) {
|
||||
static HighlightInfo.Builder checkReferenceTypeUsedAsTypeArgument(@NotNull PsiTypeElement typeElement) {
|
||||
PsiType type = typeElement.getType();
|
||||
PsiType wildCardBind = type instanceof PsiWildcardType ? ((PsiWildcardType)type).getBound() : null;
|
||||
if (type != PsiTypes.nullType() && type instanceof PsiPrimitiveType || wildCardBind instanceof PsiPrimitiveType) {
|
||||
@@ -802,8 +802,6 @@ public final class GenericsHighlightUtil {
|
||||
.getElement();
|
||||
if (element == null) return null;
|
||||
|
||||
if (level.isAtLeast(LanguageLevel.JDK_X)) return null;
|
||||
|
||||
String text = JavaErrorBundle.message("generics.type.argument.cannot.be.of.primitive.type");
|
||||
HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(text);
|
||||
|
||||
|
||||
@@ -1830,7 +1830,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
public void visitTypeElement(@NotNull PsiTypeElement type) {
|
||||
if (!hasErrorResults()) add(HighlightUtil.checkIllegalType(type, myFile));
|
||||
if (!hasErrorResults()) add(HighlightUtil.checkVarTypeApplicability(type));
|
||||
if (!hasErrorResults()) add(GenericsHighlightUtil.checkReferenceTypeUsedAsTypeArgument(type, myLanguageLevel));
|
||||
if (!hasErrorResults()) add(GenericsHighlightUtil.checkReferenceTypeUsedAsTypeArgument(type));
|
||||
if (!hasErrorResults()) add(GenericsHighlightUtil.checkWildcardUsage(type));
|
||||
if (!hasErrorResults()) add(HighlightUtil.checkArrayType(type));
|
||||
if (!hasErrorResults()) {
|
||||
|
||||
@@ -105,13 +105,8 @@ public class BasicReferenceParser {
|
||||
if (expect(builder, BasicElementTypes.BASIC_PRIMITIVE_TYPE_BIT_SET)) {
|
||||
typeInfo.isPrimitive = true;
|
||||
}
|
||||
else if ((isSet(flags, WILDCARD) || badWildcard) && (tokenType == JavaTokenType.QUEST || isKeywordAny(builder))) {
|
||||
if (tokenType == JavaTokenType.QUEST) {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
else {
|
||||
dummy(builder);
|
||||
}
|
||||
else if ((isSet(flags, WILDCARD) || badWildcard) && (tokenType == JavaTokenType.QUEST)) {
|
||||
builder.advanceLexer();
|
||||
completeWildcardType(builder, isSet(flags, WILDCARD), type);
|
||||
typeInfo.marker = type;
|
||||
return typeInfo;
|
||||
@@ -359,10 +354,6 @@ public class BasicReferenceParser {
|
||||
|
||||
myParser.getDeclarationParser().parseAnnotations(builder);
|
||||
|
||||
if (isKeywordAny(builder)) {
|
||||
dummy(builder);
|
||||
}
|
||||
|
||||
boolean wild = expect(builder, JavaTokenType.QUEST);
|
||||
if (!wild && !expect(builder, JavaTokenType.IDENTIFIER)) {
|
||||
param.rollbackTo();
|
||||
@@ -404,14 +395,4 @@ public class BasicReferenceParser {
|
||||
}
|
||||
return endsWithError;
|
||||
}
|
||||
|
||||
private static boolean isKeywordAny(PsiBuilder builder) {
|
||||
return getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_X) && "any".equals(builder.getTokenText());
|
||||
}
|
||||
|
||||
private void dummy(PsiBuilder builder) {
|
||||
PsiBuilder.Marker mark = builder.mark();
|
||||
builder.advanceLexer();
|
||||
mark.done(myJavaElementTypeContainer.DUMMY_ELEMENT);
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,6 @@ public abstract class AbstractBasicReferenceParserTest extends AbstractBasicJava
|
||||
public void testTypeParams7() { doTypeParamsParserTest("<T extends X, Y>"); }
|
||||
public void testTypeParams8() { doTypeParamsParserTest("<?>"); }
|
||||
|
||||
public void testAnyTypeParams() { doTypeParamsParserTest("<any T>"); }
|
||||
public void testAnyTypeArgs() { doTypeParserTest("T<E_SRC, any, E_DST, ?>"); }
|
||||
|
||||
protected abstract void doRefParserTest(String text, boolean incomplete);
|
||||
|
||||
protected abstract void doTypeParserTest(String text);
|
||||
|
||||
@@ -108,8 +108,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
|
||||
ellipsis = true;
|
||||
}
|
||||
|
||||
if (PsiUtil.isJavaToken(child, JavaTokenType.QUEST) ||
|
||||
child instanceof ASTNode && ((ASTNode)child).getElementType() == JavaElementType.DUMMY_ELEMENT && "any".equals(child.getText())) {
|
||||
if (PsiUtil.isJavaToken(child, JavaTokenType.QUEST)) {
|
||||
assert type == null : this;
|
||||
PsiElement boundKind = PsiTreeUtil.skipWhitespacesAndCommentsForward(child);
|
||||
PsiElement boundType = PsiTreeUtil.skipWhitespacesAndCommentsForward(boundKind);
|
||||
@@ -125,6 +124,11 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
|
||||
type = type.annotate(createProvider(annotations));
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (child instanceof ASTNode) {
|
||||
((ASTNode)child).getElementType();
|
||||
}
|
||||
}
|
||||
|
||||
if (PsiUtil.isJavaToken(child, JavaTokenType.AND)) {
|
||||
List<PsiType> types = collectTypes();
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
class C<X, any Y> { }
|
||||
|
||||
class Test {
|
||||
void m(C<?, any> c) { }
|
||||
|
||||
void test() {
|
||||
C<String, int> c = new C<String, int>();
|
||||
m(c);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
PsiJavaFile:AnyTypeArgs.java
|
||||
PsiTypeElement:T<E_SRC, any, E_DST, ?>
|
||||
PsiJavaCodeReferenceElement:T<E_SRC, any, E_DST, ?>
|
||||
PsiIdentifier:T('T')
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:E_SRC
|
||||
PsiJavaCodeReferenceElement:E_SRC
|
||||
PsiIdentifier:E_SRC('E_SRC')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:any
|
||||
PsiElement(DUMMY_ELEMENT)
|
||||
PsiIdentifier:any('any')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:E_DST
|
||||
PsiJavaCodeReferenceElement:E_DST
|
||||
PsiIdentifier:E_DST('E_DST')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:?
|
||||
PsiJavaToken:QUEST('?')
|
||||
PsiJavaToken:GT('>')
|
||||
@@ -1,28 +0,0 @@
|
||||
test.java.file
|
||||
TYPE
|
||||
JAVA_CODE_REFERENCE
|
||||
IDENTIFIER
|
||||
REFERENCE_PARAMETER_LIST
|
||||
LT
|
||||
TYPE
|
||||
JAVA_CODE_REFERENCE
|
||||
IDENTIFIER
|
||||
REFERENCE_PARAMETER_LIST
|
||||
<empty list>
|
||||
COMMA
|
||||
WHITE_SPACE
|
||||
TYPE
|
||||
DUMMY_ELEMENT
|
||||
IDENTIFIER
|
||||
COMMA
|
||||
WHITE_SPACE
|
||||
TYPE
|
||||
JAVA_CODE_REFERENCE
|
||||
IDENTIFIER
|
||||
REFERENCE_PARAMETER_LIST
|
||||
<empty list>
|
||||
COMMA
|
||||
WHITE_SPACE
|
||||
TYPE
|
||||
QUEST
|
||||
GT
|
||||
@@ -1,11 +0,0 @@
|
||||
PsiJavaFile:AnyTypeParams.java
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:T
|
||||
PsiElement(DUMMY_ELEMENT)
|
||||
PsiIdentifier:any('any')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:T('T')
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
@@ -1,11 +0,0 @@
|
||||
test.java.file
|
||||
TYPE_PARAMETER_LIST
|
||||
LT
|
||||
TYPE_PARAMETER
|
||||
DUMMY_ELEMENT
|
||||
IDENTIFIER
|
||||
WHITE_SPACE
|
||||
IDENTIFIER
|
||||
EXTENDS_BOUND_LIST
|
||||
<empty list>
|
||||
GT
|
||||
@@ -49,8 +49,6 @@ public class LightAdvHighlightingJdk9Test extends LightDaemonAnalyzerTestCase {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doTest(false, false);}
|
||||
|
||||
public void testValueTypes() { setLanguageLevel(LanguageLevel.JDK_X); doTest(false, false); }
|
||||
|
||||
public void testModuleInfoSuppression() {
|
||||
doTest(BASE_PATH + "/module-info.java", true, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user