Support !!foo as a double-negation
This commit is contained in:
@@ -64,7 +64,9 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
|
||||
/*package*/ static final TokenSet EXPRESSION_FIRST = TokenSet.create(
|
||||
// Prefix
|
||||
MINUS, PLUS, MINUSMINUS, PLUSPLUS, EXCL, LBRACKET, LABEL_IDENTIFIER, AT, ATAT,
|
||||
MINUS, PLUS, MINUSMINUS, PLUSPLUS,
|
||||
EXCL, EXCLEXCL, // Joining complex tokens makes it necessary to put EXCLEXCL here
|
||||
LBRACKET, LABEL_IDENTIFIER, AT, ATAT,
|
||||
// Atomic
|
||||
|
||||
LPAR, // parenthesized
|
||||
@@ -325,24 +327,34 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
*/
|
||||
private void parsePrefixExpression() {
|
||||
// System.out.println("pre at " + myBuilder.getTokenText());
|
||||
|
||||
if (at(LBRACKET)) {
|
||||
if (!parseLocalDeclaration()) {
|
||||
PsiBuilder.Marker expression = mark();
|
||||
myJetParsing.parseAnnotations(false);
|
||||
parsePrefixExpression();
|
||||
expression.done(ANNOTATED_EXPRESSION);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
} else if (atSet(Precedence.PREFIX.getOperations())) {
|
||||
PsiBuilder.Marker expression = mark();
|
||||
}
|
||||
else {
|
||||
myBuilder.disableJoiningComplexTokens();
|
||||
if (atSet(Precedence.PREFIX.getOperations())) {
|
||||
PsiBuilder.Marker expression = mark();
|
||||
|
||||
parseOperationReference();
|
||||
parseOperationReference();
|
||||
|
||||
parsePrefixExpression();
|
||||
expression.done(PREFIX_EXPRESSION);
|
||||
} else {
|
||||
parsePostfixExpression();
|
||||
myBuilder.restoreJoiningComplexTokensState();
|
||||
|
||||
parsePrefixExpression();
|
||||
expression.done(PREFIX_EXPRESSION);
|
||||
}
|
||||
else {
|
||||
myBuilder.restoreJoiningComplexTokensState();
|
||||
parsePostfixExpression();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -32,7 +32,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*;
|
||||
* @author abreslav
|
||||
*/
|
||||
public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter implements SemanticWhitespaceAwarePsiBuilder {
|
||||
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS);
|
||||
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS, EXCLEXCL);
|
||||
private final Stack<Boolean> joinComplexTokens = new Stack<Boolean>();
|
||||
|
||||
private final Stack<Boolean> newlinesEnabled = new Stack<Boolean>();
|
||||
@@ -126,6 +126,10 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp
|
||||
if (nextRawToken == DOT) return SAFE_ACCESS;
|
||||
if (nextRawToken == COLON) return ELVIS;
|
||||
}
|
||||
else if (rawTokenType == EXCL) {
|
||||
IElementType nextRawToken = rawLookup(rawLookupSteps);
|
||||
if (nextRawToken == EXCL) return EXCLEXCL;
|
||||
}
|
||||
return rawTokenType;
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ LONG_TEMPLATE_ENTRY_END=\}
|
||||
">=" { return JetTokens.GTEQ ; }
|
||||
"==" { return JetTokens.EQEQ ; }
|
||||
"!=" { return JetTokens.EXCLEQ ; }
|
||||
"!!" { return JetTokens.EXCLEXCL ; }
|
||||
//"!!" { return JetTokens.EXCLEXCL ; }
|
||||
"&&" { return JetTokens.ANDAND ; }
|
||||
"||" { return JetTokens.OROR ; }
|
||||
//"?." { return JetTokens.SAFE_ACCESS;}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user