Replaced PrefixExpression with LabeledExpression

where labeled expression is used

Added 'visitLabeledExpression'
This commit is contained in:
Svetlana Isakova
2014-05-15 14:45:41 +04:00
parent 04729f5985
commit f109cfc303
22 changed files with 108 additions and 131 deletions
@@ -267,7 +267,7 @@ public class JetPositionManager implements PositionManager {
PsiElement valueArgument = functionLiteralExpression;
while (parent instanceof JetParenthesizedExpression ||
parent instanceof JetBinaryExpressionWithTypeRHS ||
parent instanceof JetPrefixExpression && JetPsiUtil.isLabeledExpression((JetPrefixExpression) parent)) {
parent instanceof JetLabeledExpression) {
valueArgument = parent;
parent = parent.getParent();
}
@@ -19,23 +19,13 @@ package org.jetbrains.jet.plugin.highlighter;
import com.intellij.lang.annotation.AnnotationHolder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetExpressionWithLabel;
import org.jetbrains.jet.lang.psi.JetPrefixExpression;
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
import org.jetbrains.jet.lexer.JetTokens;
class LabelsHighlightingVisitor extends HighlightingVisitor {
LabelsHighlightingVisitor(AnnotationHolder holder) {
super(holder);
}
@Override
public void visitPrefixExpression(@NotNull JetPrefixExpression expression) {
JetSimpleNameExpression operationSign = expression.getOperationReference();
if (operationSign.getReferencedNameElementType() == JetTokens.LABEL_IDENTIFIER) {
JetPsiChecker.highlightName(holder, operationSign, JetHighlightingColors.LABEL);
}
}
@Override
public void visitExpressionWithLabel(@NotNull JetExpressionWithLabel expression) {
JetSimpleNameExpression targetLabel = expression.getTargetLabel();
@@ -86,8 +86,8 @@ class JetInvokeFunctionReference extends JetSimpleReference<JetCallExpression> i
List<JetExpression> functionLiteralArguments = getExpression().getFunctionLiteralArguments();
for (JetExpression functionLiteralArgument : functionLiteralArguments) {
while (functionLiteralArgument instanceof JetPrefixExpression) {
functionLiteralArgument = ((JetPrefixExpression) functionLiteralArgument).getBaseExpression();
while (functionLiteralArgument instanceof JetLabeledExpression) {
functionLiteralArgument = ((JetLabeledExpression) functionLiteralArgument).getBaseExpression();
}
if (functionLiteralArgument instanceof JetFunctionLiteralExpression) {
@@ -46,6 +46,7 @@ public object JetPsiPrecedences {
public fun getPrecedence(expression: JetExpression): Int {
return when (expression) {
is JetAnnotatedExpression,
is JetLabeledExpression,
is JetPrefixExpression -> PRECEDENCE_OF_PREFIX_EXPRESSION
is JetPostfixExpression -> PRECEDENCE_OF_POSTFIX_EXPRESSION
is JetOperationExpression -> {