Common superinterface for JetBinaryOperation and JetUnaryOperation
This commit is contained in:
@@ -1830,7 +1830,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue visitPrefixExpression(JetPrefixExpression expression, StackValue receiver) {
|
public StackValue visitPrefixExpression(JetPrefixExpression expression, StackValue receiver) {
|
||||||
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationSign());
|
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
|
||||||
final Callable callable = resolveToCallable(op, false);
|
final Callable callable = resolveToCallable(op, false);
|
||||||
if (callable instanceof IntrinsicMethod) {
|
if (callable instanceof IntrinsicMethod) {
|
||||||
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
|
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
|
||||||
@@ -1847,7 +1847,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue visitPostfixExpression(JetPostfixExpression expression, StackValue receiver) {
|
public StackValue visitPostfixExpression(JetPostfixExpression expression, StackValue receiver) {
|
||||||
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationSign());
|
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
|
||||||
if (op instanceof FunctionDescriptor) {
|
if (op instanceof FunctionDescriptor) {
|
||||||
final Type asmType = expressionType(expression);
|
final Type asmType = expressionType(expression);
|
||||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import org.jetbrains.jet.lang.types.JetType;
|
|||||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
|
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -284,7 +283,7 @@ public class JetControlFlowProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitUnaryExpression(JetUnaryExpression expression) {
|
public void visitUnaryExpression(JetUnaryExpression expression) {
|
||||||
JetSimpleNameExpression operationSign = expression.getOperationSign();
|
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||||
JetExpression baseExpression = expression.getBaseExpression();
|
JetExpression baseExpression = expression.getBaseExpression();
|
||||||
if (baseExpression == null) return;
|
if (baseExpression == null) return;
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ public class JetFlowInformationProvider {
|
|||||||
operationReference = ((JetBinaryExpression) parent).getOperationReference();
|
operationReference = ((JetBinaryExpression) parent).getOperationReference();
|
||||||
}
|
}
|
||||||
else if (parent instanceof JetUnaryExpression) {
|
else if (parent instanceof JetUnaryExpression) {
|
||||||
operationReference = ((JetUnaryExpression) parent).getOperationSign();
|
operationReference = ((JetUnaryExpression) parent).getOperationReference();
|
||||||
}
|
}
|
||||||
if (operationReference != null) {
|
if (operationReference != null) {
|
||||||
DeclarationDescriptor descriptor = trace.get(BindingContext.REFERENCE_TARGET, operationReference);
|
DeclarationDescriptor descriptor = trace.get(BindingContext.REFERENCE_TARGET, operationReference);
|
||||||
@@ -471,7 +471,7 @@ public class JetFlowInformationProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (element instanceof JetPostfixExpression) {
|
else if (element instanceof JetPostfixExpression) {
|
||||||
IElementType operationToken = ((JetPostfixExpression) element).getOperationSign().getReferencedNameElementType();
|
IElementType operationToken = ((JetPostfixExpression) element).getOperationReference().getReferencedNameElementType();
|
||||||
if (operationToken == JetTokens.PLUSPLUS || operationToken == JetTokens.MINUSMINUS) {
|
if (operationToken == JetTokens.PLUSPLUS || operationToken == JetTokens.MINUSMINUS) {
|
||||||
trace.report(Errors.UNUSED_CHANGED_VALUE.on(element, element));
|
trace.report(Errors.UNUSED_CHANGED_VALUE.on(element, element));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetBinaryExpression extends JetExpression {
|
public class JetBinaryExpression extends JetExpression implements JetOperationExpression {
|
||||||
public JetBinaryExpression(@NotNull ASTNode node) {
|
public JetBinaryExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,7 @@ public class JetBinaryExpression extends JetExpression {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetSimpleNameExpression getOperationReference() {
|
public JetSimpleNameExpression getOperationReference() {
|
||||||
return (JetSimpleNameExpression) findChildByType(JetNodeTypes.OPERATION_REFERENCE);
|
return (JetSimpleNameExpression) findChildByType(JetNodeTypes.OPERATION_REFERENCE);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class JetCallExpression extends JetExpression implements JetCallElement {
|
|||||||
}
|
}
|
||||||
else if (psi instanceof JetPrefixExpression) {
|
else if (psi instanceof JetPrefixExpression) {
|
||||||
JetPrefixExpression prefixExpression = (JetPrefixExpression) psi;
|
JetPrefixExpression prefixExpression = (JetPrefixExpression) psi;
|
||||||
if (JetTokens.LABELS.contains(prefixExpression.getOperationSign().getReferencedNameElementType())) {
|
if (JetTokens.LABELS.contains(prefixExpression.getOperationReference().getReferencedNameElementType())) {
|
||||||
JetExpression labeledExpression = prefixExpression.getBaseExpression();
|
JetExpression labeledExpression = prefixExpression.getBaseExpression();
|
||||||
if (labeledExpression instanceof JetFunctionLiteralExpression) {
|
if (labeledExpression instanceof JetFunctionLiteralExpression) {
|
||||||
result.add(labeledExpression);
|
result.add(labeledExpression);
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package org.jetbrains.jet.lang.psi;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public interface JetOperationExpression {
|
||||||
|
@NotNull
|
||||||
|
JetSimpleNameExpression getOperationReference();
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ public class JetPrefixExpression extends JetUnaryExpression {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getBaseExpression() {
|
public JetExpression getBaseExpression() {
|
||||||
PsiElement expression = getOperationSign().getNextSibling();
|
PsiElement expression = getOperationReference().getNextSibling();
|
||||||
while (expression != null && !(expression instanceof JetExpression)) {
|
while (expression != null && !(expression instanceof JetExpression)) {
|
||||||
expression = expression.getNextSibling();
|
expression = expression.getNextSibling();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class JetPsiUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (expression instanceof JetPrefixExpression) {
|
else if (expression instanceof JetPrefixExpression) {
|
||||||
if (JetTokens.LABELS.contains(((JetPrefixExpression) expression).getOperationSign().getReferencedNameElementType())) {
|
if (JetTokens.LABELS.contains(((JetPrefixExpression) expression).getOperationReference().getReferencedNameElementType())) {
|
||||||
JetExpression baseExpression = ((JetPrefixExpression) expression).getBaseExpression();
|
JetExpression baseExpression = ((JetPrefixExpression) expression).getBaseExpression();
|
||||||
if (baseExpression != null) {
|
if (baseExpression != null) {
|
||||||
expression = baseExpression;
|
expression = baseExpression;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public abstract class JetUnaryExpression extends JetExpression {
|
public abstract class JetUnaryExpression extends JetExpression implements JetOperationExpression {
|
||||||
public JetUnaryExpression(ASTNode node) {
|
public JetUnaryExpression(ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -16,8 +16,9 @@ public abstract class JetUnaryExpression extends JetExpression {
|
|||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public abstract JetExpression getBaseExpression();
|
public abstract JetExpression getBaseExpression();
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetSimpleNameExpression getOperationSign() {
|
public JetSimpleNameExpression getOperationReference() {
|
||||||
return (JetSimpleNameExpression) findChildByType(JetNodeTypes.OPERATION_REFERENCE);
|
return (JetSimpleNameExpression) findChildByType(JetNodeTypes.OPERATION_REFERENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ public class CallMaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Call makeCall(@NotNull ReceiverDescriptor baseAsReceiver, JetUnaryExpression expression) {
|
public static Call makeCall(@NotNull ReceiverDescriptor baseAsReceiver, JetUnaryExpression expression) {
|
||||||
return makeCall(expression, baseAsReceiver, null, expression.getOperationSign(), Collections.<ValueArgument>emptyList());
|
return makeCall(expression, baseAsReceiver, null, expression.getOperationReference(), Collections.<ValueArgument>emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Call makeArraySetCall(@NotNull ReceiverDescriptor arrayAsReceiver, JetArrayAccessExpression arrayAccessExpression, JetExpression rightHandSide) {
|
public static Call makeArraySetCall(@NotNull ReceiverDescriptor arrayAsReceiver, JetArrayAccessExpression arrayAccessExpression, JetExpression rightHandSide) {
|
||||||
|
|||||||
+2
-2
@@ -628,7 +628,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
public JetType visitUnaryExpression(JetUnaryExpression expression, ExpressionTypingContext context) {
|
public JetType visitUnaryExpression(JetUnaryExpression expression, ExpressionTypingContext context) {
|
||||||
JetExpression baseExpression = expression.getBaseExpression();
|
JetExpression baseExpression = expression.getBaseExpression();
|
||||||
if (baseExpression == null) return null;
|
if (baseExpression == null) return null;
|
||||||
JetSimpleNameExpression operationSign = expression.getOperationSign();
|
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||||
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
||||||
String referencedName = operationSign.getReferencedName();
|
String referencedName = operationSign.getReferencedName();
|
||||||
referencedName = referencedName == null ? " <?>" : referencedName;
|
referencedName = referencedName == null ? " <?>" : referencedName;
|
||||||
@@ -649,7 +649,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
FunctionDescriptor functionDescriptor = context.resolveCallWithGivenNameToDescriptor(
|
FunctionDescriptor functionDescriptor = context.resolveCallWithGivenNameToDescriptor(
|
||||||
CallMaker.makeCall(receiver, expression),
|
CallMaker.makeCall(receiver, expression),
|
||||||
expression.getOperationSign(),
|
expression.getOperationReference(),
|
||||||
name);
|
name);
|
||||||
|
|
||||||
if (functionDescriptor == null) return null;
|
if (functionDescriptor == null) return null;
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class DataFlowUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitUnaryExpression(JetUnaryExpression expression) {
|
public void visitUnaryExpression(JetUnaryExpression expression) {
|
||||||
IElementType operationTokenType = expression.getOperationSign().getReferencedNameElementType();
|
IElementType operationTokenType = expression.getOperationReference().getReferencedNameElementType();
|
||||||
if (operationTokenType == JetTokens.EXCL) {
|
if (operationTokenType == JetTokens.EXCL) {
|
||||||
JetExpression baseExpression = expression.getBaseExpression();
|
JetExpression baseExpression = expression.getBaseExpression();
|
||||||
if (baseExpression != null) {
|
if (baseExpression != null) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class LabelsAnnotator implements Annotator {
|
|||||||
element.accept(new JetVisitorVoid() {
|
element.accept(new JetVisitorVoid() {
|
||||||
@Override
|
@Override
|
||||||
public void visitPrefixExpression(JetPrefixExpression expression) {
|
public void visitPrefixExpression(JetPrefixExpression expression) {
|
||||||
JetSimpleNameExpression operationSign = expression.getOperationSign();
|
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||||
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
||||||
holder.createInfoAnnotation(operationSign, null).setTextAttributes(JetHighlighter.JET_LABEL_IDENTIFIER);
|
holder.createInfoAnnotation(operationSign, null).setTextAttributes(JetHighlighter.JET_LABEL_IDENTIFIER);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user