Parse annotations on nullable types
This commit is contained in:
@@ -1847,6 +1847,8 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
PsiBuilder.Marker typeRefMarker = mark();
|
PsiBuilder.Marker typeRefMarker = mark();
|
||||||
parseAnnotations(ONLY_ESCAPED_REGULAR_ANNOTATIONS);
|
parseAnnotations(ONLY_ESCAPED_REGULAR_ANNOTATIONS);
|
||||||
|
|
||||||
|
PsiBuilder.Marker typeElementMarker = mark();
|
||||||
|
|
||||||
IElementType lookahead = lookahead(1);
|
IElementType lookahead = lookahead(1);
|
||||||
IElementType lookahead2 = lookahead(2);
|
IElementType lookahead2 = lookahead(2);
|
||||||
boolean typeBeforeDot = true;
|
boolean typeBeforeDot = true;
|
||||||
@@ -1903,7 +1905,7 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
// Disabling token merge is required for cases like
|
// Disabling token merge is required for cases like
|
||||||
// Int?.(Foo) -> Bar
|
// Int?.(Foo) -> Bar
|
||||||
myBuilder.disableJoiningComplexTokens();
|
myBuilder.disableJoiningComplexTokens();
|
||||||
typeRefMarker = parseNullableTypeSuffix(typeRefMarker);
|
typeElementMarker = parseNullableTypeSuffix(typeElementMarker);
|
||||||
myBuilder.restoreJoiningComplexTokensState();
|
myBuilder.restoreJoiningComplexTokensState();
|
||||||
|
|
||||||
if (typeBeforeDot && at(DOT)) {
|
if (typeBeforeDot && at(DOT)) {
|
||||||
@@ -1929,19 +1931,20 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
functionType.done(FUNCTION_TYPE);
|
functionType.done(FUNCTION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typeElementMarker.drop();
|
||||||
return typeRefMarker;
|
return typeRefMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
PsiBuilder.Marker parseNullableTypeSuffix(@NotNull PsiBuilder.Marker typeRefMarker) {
|
PsiBuilder.Marker parseNullableTypeSuffix(@NotNull PsiBuilder.Marker typeElementMarker) {
|
||||||
// ?: is joined regardless of joining state
|
// ?: is joined regardless of joining state
|
||||||
while (at(QUEST) && myBuilder.rawLookup(1) != COLON) {
|
while (at(QUEST) && myBuilder.rawLookup(1) != COLON) {
|
||||||
PsiBuilder.Marker precede = typeRefMarker.precede();
|
PsiBuilder.Marker precede = typeElementMarker.precede();
|
||||||
advance(); // QUEST
|
advance(); // QUEST
|
||||||
typeRefMarker.done(NULLABLE_TYPE);
|
typeElementMarker.done(NULLABLE_TYPE);
|
||||||
typeRefMarker = precede;
|
typeElementMarker = precede;
|
||||||
}
|
}
|
||||||
return typeRefMarker;
|
return typeElementMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+16
-16
@@ -14,15 +14,15 @@ JetFile: annotationsOnNullableTypes.kt
|
|||||||
PsiElement(COLON)(':')
|
PsiElement(COLON)(':')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
|
ANNOTATION_ENTRY
|
||||||
|
PsiElement(AT)('@')
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
NULLABLE_TYPE
|
NULLABLE_TYPE
|
||||||
ANNOTATION_ENTRY
|
|
||||||
PsiElement(AT)('@')
|
|
||||||
CONSTRUCTOR_CALLEE
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('a')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('Int')
|
PsiElement(IDENTIFIER)('Int')
|
||||||
@@ -37,15 +37,15 @@ JetFile: annotationsOnNullableTypes.kt
|
|||||||
PsiElement(fun)('fun')
|
PsiElement(fun)('fun')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
|
ANNOTATION_ENTRY
|
||||||
|
PsiElement(AT)('@')
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
NULLABLE_TYPE
|
NULLABLE_TYPE
|
||||||
ANNOTATION_ENTRY
|
|
||||||
PsiElement(AT)('@')
|
|
||||||
CONSTRUCTOR_CALLEE
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('a')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('Int')
|
PsiElement(IDENTIFIER)('Int')
|
||||||
|
|||||||
Reference in New Issue
Block a user