KT-35811: Type parameter angle brackets followed by equal sign are parsed incorrectly if whitespace is missing
This commit is contained in:
@@ -283,7 +283,6 @@ LONELY_BACKTICK=`
|
||||
"++" { return KtTokens.PLUSPLUS ; }
|
||||
"--" { return KtTokens.MINUSMINUS; }
|
||||
"<=" { return KtTokens.LTEQ ; }
|
||||
">=" { return KtTokens.GTEQ ; }
|
||||
"==" { return KtTokens.EQEQ ; }
|
||||
"!=" { return KtTokens.EXCLEQ ; }
|
||||
"&&" { return KtTokens.ANDAND ; }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2428,11 +2428,13 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
projection.done(TYPE_PROJECTION);
|
||||
if (!at(COMMA)) break;
|
||||
advance(); // COMMA
|
||||
if (at(GT)) {
|
||||
if (at(GT) || at(GTEQ)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
myBuilder.disableJoiningComplexTokens();
|
||||
|
||||
boolean atGT = at(GT);
|
||||
if (!atGT) {
|
||||
error("Expecting a '>'");
|
||||
@@ -2440,6 +2442,9 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
else {
|
||||
advance(); // GT
|
||||
}
|
||||
|
||||
myBuilder.restoreJoiningComplexTokensState();
|
||||
|
||||
myBuilder.restoreNewlinesState();
|
||||
return atGT;
|
||||
}
|
||||
|
||||
+10
-4
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import static org.jetbrains.kotlin.lexer.KtTokens.*;
|
||||
|
||||
public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter implements SemanticWhitespaceAwarePsiBuilder {
|
||||
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS, EXCLEXCL);
|
||||
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS, EXCLEXCL, GTEQ);
|
||||
private final Stack<Boolean> joinComplexTokens = new Stack<>();
|
||||
|
||||
private final Stack<Boolean> newlinesEnabled = new Stack<>();
|
||||
@@ -155,6 +155,10 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp
|
||||
IElementType nextRawToken = rawLookup(rawLookupSteps);
|
||||
if (nextRawToken == EXCL) return EXCLEXCL;
|
||||
}
|
||||
else if (rawTokenType == GT){
|
||||
IElementType nextRawToken = rawLookup(rawLookupSteps);
|
||||
if (nextRawToken == EQ) return GTEQ;
|
||||
}
|
||||
return rawTokenType;
|
||||
}
|
||||
|
||||
@@ -181,9 +185,11 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp
|
||||
if (!joinComplexTokens()) return super.getTokenText();
|
||||
IElementType tokenType = getTokenType();
|
||||
if (complexTokens.contains(tokenType)) {
|
||||
if (tokenType == ELVIS) return "?:";
|
||||
if (tokenType == SAFE_ACCESS) return "?.";
|
||||
}
|
||||
if (tokenType == ELVIS) return "?:";
|
||||
if (tokenType == SAFE_ACCESS) return "?.";
|
||||
if (tokenType == EXCLEXCL) return "!!";
|
||||
if (tokenType == GTEQ) return ">=";
|
||||
}
|
||||
return super.getTokenText();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user