Removed AT, ATAT tokens
Checks 'in LABELS token set' replaced with LABEL_IDENTIFIER equality
This commit is contained in:
@@ -2920,7 +2920,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
if (expression.getParent() instanceof JetPrefixExpression) {
|
||||
JetPrefixExpression parent = (JetPrefixExpression) expression.getParent();
|
||||
JetSimpleNameExpression operationSign = parent.getOperationReference();
|
||||
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
||||
if (operationSign.getReferencedNameElementType() == JetTokens.LABEL_IDENTIFIER) {
|
||||
return operationSign;
|
||||
}
|
||||
}
|
||||
@@ -2930,7 +2930,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
@Override
|
||||
public StackValue visitPrefixExpression(@NotNull JetPrefixExpression expression, StackValue receiver) {
|
||||
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
||||
if (operationSign.getReferencedNameElementType() == JetTokens.LABEL_IDENTIFIER) {
|
||||
return genQualified(receiver, expression.getBaseExpression());
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public class DebugInfoUtil {
|
||||
if (EXCLUDED.contains(referencedNameElementType)) {
|
||||
return;
|
||||
}
|
||||
if (JetTokens.LABELS.contains(referencedNameElementType)) return;
|
||||
if (referencedNameElementType == JetTokens.LABEL_IDENTIFIER) return;
|
||||
}
|
||||
else if (nameExpression.getReferencedNameElementType() == JetTokens.THIS_KEYWORD) {
|
||||
return;
|
||||
|
||||
@@ -374,7 +374,7 @@ public class JetControlFlowProcessor {
|
||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
if (baseExpression == null) return;
|
||||
if (JetTokens.LABELS.contains(operationType)) {
|
||||
if (operationType == JetTokens.LABEL_IDENTIFIER) {
|
||||
String referencedName = operationSign.getReferencedName();
|
||||
visitLabeledExpression(referencedName.substring(1), baseExpression, context);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
// Prefix
|
||||
MINUS, PLUS, MINUSMINUS, PLUSPLUS,
|
||||
EXCL, EXCLEXCL, // Joining complex tokens makes it necessary to put EXCLEXCL here
|
||||
LBRACKET, LABEL_IDENTIFIER, AT, ATAT,
|
||||
LBRACKET, LABEL_IDENTIFIER,
|
||||
// Atomic
|
||||
|
||||
COLONCOLON, // callable reference
|
||||
@@ -138,7 +138,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
POSTFIX(PLUSPLUS, MINUSMINUS, EXCLEXCL,
|
||||
DOT, SAFE_ACCESS), // typeArguments? valueArguments : typeArguments : arrayAccess
|
||||
|
||||
PREFIX(MINUS, PLUS, MINUSMINUS, PLUSPLUS, EXCL, LABEL_IDENTIFIER, AT, ATAT) { // attributes
|
||||
PREFIX(MINUS, PLUS, MINUSMINUS, PLUSPLUS, EXCL, LABEL_IDENTIFIER) { // attributes
|
||||
|
||||
@Override
|
||||
public void parseHigherPrecedence(JetExpressionParsing parser) {
|
||||
@@ -498,10 +498,9 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
*/
|
||||
protected boolean parseCallWithClosure() {
|
||||
boolean success = false;
|
||||
|
||||
while (at(LBRACE) || atSet(LABELS) && lookahead(1) == LBRACE) {
|
||||
while ((at(LBRACE) || at(LABEL_IDENTIFIER) && lookahead(1) == LBRACE)) {
|
||||
if (!at(LBRACE)) {
|
||||
assert _atSet(LABELS);
|
||||
assert _at(LABEL_IDENTIFIER);
|
||||
parsePrefixExpression();
|
||||
}
|
||||
else {
|
||||
@@ -1397,7 +1396,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
if (at(LBRACE)) {
|
||||
parseFunctionLiteral(true);
|
||||
}
|
||||
else if (atSet(LABELS) && lookahead(1) == LBRACE ) {
|
||||
else if (at(LABEL_IDENTIFIER) && lookahead(1) == LBRACE ) {
|
||||
PsiBuilder.Marker mark = mark();
|
||||
|
||||
parseOperationReference();
|
||||
@@ -1581,11 +1580,11 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
* labels
|
||||
*/
|
||||
private void parseLabel() {
|
||||
if (!eol() && atSet(LABELS)) {
|
||||
if (!eol() && at(LABEL_IDENTIFIER)) {
|
||||
PsiBuilder.Marker labelWrap = mark();
|
||||
|
||||
PsiBuilder.Marker mark = mark();
|
||||
advance(); // LABELS
|
||||
advance(); // LABEL_IDENTIFIER
|
||||
mark.done(LABEL_REFERENCE);
|
||||
|
||||
labelWrap.done(LABEL_QUALIFIER);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class JetCallExpression extends JetReferenceExpression implements JetCall
|
||||
}
|
||||
else if (psi instanceof JetPrefixExpression) {
|
||||
JetPrefixExpression prefixExpression = (JetPrefixExpression) psi;
|
||||
if (JetTokens.LABELS.contains(prefixExpression.getOperationReference().getReferencedNameElementType())) {
|
||||
if (prefixExpression.getOperationReference().getReferencedNameElementType() == JetTokens.LABEL_IDENTIFIER) {
|
||||
JetExpression labeledExpression = prefixExpression.getBaseExpression();
|
||||
if (labeledExpression instanceof JetFunctionLiteralExpression) {
|
||||
result.add(prefixExpression);
|
||||
|
||||
@@ -133,7 +133,7 @@ public class JetPsiUtil {
|
||||
}
|
||||
|
||||
public static boolean isLabeledExpression(JetPrefixExpression expression) {
|
||||
return JetTokens.LABELS.contains(expression.getOperationReference().getReferencedNameElementType());
|
||||
return expression.getOperationReference().getReferencedNameElementType() == JetTokens.LABEL_IDENTIFIER;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
import static org.jetbrains.jet.lexer.JetTokens.*;
|
||||
|
||||
public class JetSimpleNameExpression extends JetReferenceExpression {
|
||||
public static final TokenSet REFERENCE_TOKENS = TokenSet.orSet(LABELS, TokenSet.create(IDENTIFIER, FIELD_IDENTIFIER, THIS_KEYWORD, SUPER_KEYWORD));
|
||||
public static final TokenSet REFERENCE_TOKENS = TokenSet.create(LABEL_IDENTIFIER, IDENTIFIER, FIELD_IDENTIFIER, THIS_KEYWORD, SUPER_KEYWORD);
|
||||
|
||||
public JetSimpleNameExpression(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
|
||||
+2
-2
@@ -617,7 +617,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||
// If it's a labeled expression
|
||||
if (JetTokens.LABELS.contains(operationType)) {
|
||||
if (operationType == JetTokens.LABEL_IDENTIFIER) {
|
||||
return visitLabeledExpression(expression, context, isStatement);
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
assert baseExpression != null;
|
||||
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||
assert JetTokens.LABELS.contains(operationSign.getReferencedNameElementType());
|
||||
assert operationSign.getReferencedNameElementType() == JetTokens.LABEL_IDENTIFIER;
|
||||
|
||||
return facade.getTypeInfo(baseExpression, context, isStatement);
|
||||
}
|
||||
|
||||
+1
-1
@@ -485,6 +485,6 @@ public class ExpressionTypingUtils {
|
||||
|
||||
public static boolean isUnaryExpressionDependentOnExpectedType(@NotNull JetUnaryExpression expression) {
|
||||
IElementType operationType = expression.getOperationReference().getReferencedNameElementType();
|
||||
return JetTokens.LABELS.contains(operationType) || operationType == JetTokens.EXCLEXCL;
|
||||
return operationType == JetTokens.LABEL_IDENTIFIER || operationType == JetTokens.EXCLEXCL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,10 +127,6 @@ public interface JetTokens {
|
||||
JetKeywordToken NOT_IN = JetKeywordToken.keyword("NOT_IN", "!in");
|
||||
JetKeywordToken NOT_IS = JetKeywordToken.keyword("NOT_IS", "!is");
|
||||
JetSingleValueToken HASH = new JetSingleValueToken("HASH", "#");
|
||||
JetSingleValueToken AT = new JetSingleValueToken("AT", "@");
|
||||
JetSingleValueToken ATAT = new JetSingleValueToken("ATAT", "@@");
|
||||
|
||||
TokenSet LABELS = TokenSet.create(AT, ATAT, LABEL_IDENTIFIER);
|
||||
|
||||
JetSingleValueToken COMMA = new JetSingleValueToken("COMMA", ",");
|
||||
|
||||
@@ -203,7 +199,7 @@ public interface JetTokens {
|
||||
COLON,
|
||||
RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ,
|
||||
NOT_IN, NOT_IS,
|
||||
IDENTIFIER, LABEL_IDENTIFIER, ATAT, AT);
|
||||
IDENTIFIER, LABEL_IDENTIFIER);
|
||||
|
||||
TokenSet AUGMENTED_ASSIGNMENTS = TokenSet.create(PLUSEQ, MINUSEQ, MULTEQ, PERCEQ, DIVEQ);
|
||||
TokenSet ALL_ASSIGNMENTS = TokenSet.create(EQ, PLUSEQ, MINUSEQ, MULTEQ, PERCEQ, DIVEQ);
|
||||
|
||||
@@ -53,7 +53,6 @@ public class JetHighlighter extends SyntaxHighlighterBase {
|
||||
|
||||
keys1.put(JetTokens.AS_SAFE, JetHighlightingColors.KEYWORD);
|
||||
keys1.put(JetTokens.LABEL_IDENTIFIER, JetHighlightingColors.LABEL);
|
||||
keys1.put(JetTokens.ATAT, JetHighlightingColors.LABEL);
|
||||
keys1.put(JetTokens.INTEGER_LITERAL, JetHighlightingColors.NUMBER);
|
||||
keys1.put(JetTokens.FLOAT_LITERAL, JetHighlightingColors.NUMBER);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class LabelsHighlightingVisitor extends HighlightingVisitor {
|
||||
@Override
|
||||
public void visitPrefixExpression(@NotNull JetPrefixExpression expression) {
|
||||
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
||||
if (operationSign.getReferencedNameElementType() == JetTokens.LABEL_IDENTIFIER) {
|
||||
JetPsiChecker.highlightName(holder, operationSign, JetHighlightingColors.LABEL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
|
||||
JetSimpleNameExpression operationReference = expression.getOperationReference();
|
||||
IElementType operationToken = operationReference.getReferencedNameElementType();
|
||||
JsNode result;
|
||||
if (JetTokens.LABELS.contains(operationToken)) {
|
||||
if (operationToken == JetTokens.LABEL_IDENTIFIER) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
assert baseExpression != null;
|
||||
result = new JsLabel(context.scope().declareName(getReferencedName(operationReference)),
|
||||
|
||||
-1
@@ -120,7 +120,6 @@ class SyntaxHighlighter() {
|
||||
styleMap.put(JetTokens.CLOSING_QUOTE, "string")
|
||||
styleMap.put(JetTokens.CHARACTER_LITERAL, "string")
|
||||
styleMap.put(JetTokens.LABEL_IDENTIFIER, "label")
|
||||
styleMap.put(JetTokens.ATAT, "label")
|
||||
styleMap.put(JetTokens.FIELD_IDENTIFIER, "field")
|
||||
styleMap.put(TokenType.BAD_CHARACTER, "bad")
|
||||
putAll(JetTokens.STRINGS, "string")
|
||||
|
||||
Reference in New Issue
Block a user