Revert "KT-35811: Type parameter angle brackets followed by equal sign are parsed incorrectly if whitespace is missing"

This reverts commit ba5c85d6

^KT-52684 Related
This commit is contained in:
Denis.Zharkov
2022-06-08 16:22:29 +03:00
committed by teamcity
parent 67f9025f9e
commit 9caa60d389
21 changed files with 390 additions and 713 deletions
@@ -283,6 +283,7 @@ 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,13 +2428,11 @@ public class KotlinParsing extends AbstractKotlinParsing {
projection.done(TYPE_PROJECTION);
if (!at(COMMA)) break;
advance(); // COMMA
if (at(GT) || at(GTEQ)) {
if (at(GT)) {
break;
}
}
myBuilder.disableJoiningComplexTokens();
boolean atGT = at(GT);
if (!atGT) {
error("Expecting a '>'");
@@ -2442,9 +2440,6 @@ public class KotlinParsing extends AbstractKotlinParsing {
else {
advance(); // GT
}
myBuilder.restoreJoiningComplexTokensState();
myBuilder.restoreNewlinesState();
return atGT;
}
@@ -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, GTEQ);
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS, EXCLEXCL);
private final Stack<Boolean> joinComplexTokens = new Stack<>();
private final Stack<Boolean> newlinesEnabled = new Stack<>();
@@ -155,10 +155,6 @@ 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;
}
@@ -185,11 +181,9 @@ 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 == EXCLEXCL) return "!!";
if (tokenType == GTEQ) return ">=";
}
if (tokenType == ELVIS) return "?:";
if (tokenType == SAFE_ACCESS) return "?.";
}
return super.getTokenText();
}