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