diff --git a/idea/src/org/jetbrains/jet/JetNodeTypes.java b/idea/src/org/jetbrains/jet/JetNodeTypes.java index b6b3d5c2dee..9f2c657daaa 100644 --- a/idea/src/org/jetbrains/jet/JetNodeTypes.java +++ b/idea/src/org/jetbrains/jet/JetNodeTypes.java @@ -59,7 +59,6 @@ public interface JetNodeTypes { JetNodeType PROPERTY_ACCESSOR = new JetNodeType("PROPERTY_ACCESSOR"); JetNodeType INITIALIZER_LIST = new JetNodeType("INITIALIZER_LIST"); JetNodeType THIS_CALL = new JetNodeType("THIS_CALL"); - JetNodeType BLOCK = new JetNodeType("BLOCK"); JetNodeType TYPE_CONSTRAINT_LIST = new JetNodeType("TYPE_CONSTRAINT_LIST"); JetNodeType TYPE_CONSTRAINT = new JetNodeType("TYPE_CONSTRAINT"); @@ -81,19 +80,20 @@ public interface JetNodeTypes { JetNodeType CONTINUE = new JetNodeType("CONTINUE", JetContinueExpression.class); JetNodeType BREAK = new JetNodeType("BREAK", JetBreakExpression.class); JetNodeType IF = new JetNodeType("IF", JetIfExpression.class); - JetNodeType CONDITION = new JetNodeType("CONDITION"); - JetNodeType THEN = new JetNodeType("THEN"); - JetNodeType ELSE = new JetNodeType("ELSE"); + JetNodeType CONDITION = new JetNodeType("CONDITION"); //TODO: discuss, this can be omitted + JetNodeType THEN = new JetNodeType("THEN"); //TODO: discuss, this can be omitted + JetNodeType ELSE = new JetNodeType("ELSE"); //TODO: discuss, this can be omitted JetNodeType TRY = new JetNodeType("TRY", JetTryExpression.class); - JetNodeType CATCH = new JetNodeType("CATCH"); - JetNodeType FINALLY = new JetNodeType("FINALLY"); + JetNodeType CATCH = new JetNodeType("CATCH", JetCatchSection.class); + JetNodeType FINALLY = new JetNodeType("FINALLY", JetFinallySection.class); JetNodeType FOR = new JetNodeType("FOR", JetForExpression.class); JetNodeType WHILE = new JetNodeType("WHILE", JetWhileExpression.class); JetNodeType DO_WHILE = new JetNodeType("DO_WHILE", JetDoWhileExpression.class); - JetNodeType LOOP_PARAMETER = new JetNodeType("LOOP_PARAMETER"); - JetNodeType LOOP_RANGE = new JetNodeType("LOOP_RANGE"); - JetNodeType BODY = new JetNodeType("BODY"); + JetNodeType LOOP_PARAMETER = new JetNodeType("LOOP_PARAMETER", JetParameter.class); // TODO: Do we need separate type? + JetNodeType LOOP_RANGE = new JetNodeType("LOOP_RANGE"); //TODO: discuss, this can be omitted + JetNodeType BODY = new JetNodeType("BODY"); //TODO: discuss, this can be omitted JetNodeType RECEIVER_TYPE = new JetNodeType("RECEIVER_TYPE"); + JetNodeType BLOCK = new JetNodeType("BLOCK", JetBlockExpression.class); JetNodeType FUNCTION_LITERAL = new JetNodeType("FUNCTION_LITERAL", JetFunctionLiteralExpression.class); JetNodeType ANNOTATED_EXPRESSION = new JetNodeType("ANNOTATED_EXPRESSION", JetAnnotatedExpression.class); JetNodeType REFERENCE_EXPRESSION = new JetNodeType("REFERENCE_EXPRESSION", JetReferenceExpression.class); diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.java index db61386ef5d..a9d5389ddad 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.java @@ -2,6 +2,11 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.JetNodeTypes; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** * @author max @@ -19,4 +24,17 @@ public class JetAnnotatedExpression extends JetExpression { public JetExpression getBaseExpression() { return findChildByClass(JetExpression.class); } + + public List getAttributeAnnotations() { + return findChildrenByType(JetNodeTypes.ATTRIBUTE_ANNOTATION); + } + + public List getAttributes() { + List answer = null; + for (JetAttributeAnnotation annotation : getAttributeAnnotations()) { + if (answer == null) answer = new ArrayList(); + answer.addAll(annotation.getAttributes()); + } + return answer != null ? answer : Collections.emptyList(); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetBinaryExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetBinaryExpression.java index b9cc8cc7266..523c440ed95 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetBinaryExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetBinaryExpression.java @@ -2,16 +2,11 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiErrorElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lexer.JetToken; import org.jetbrains.jet.lexer.JetTokens; -import static org.jetbrains.jet.lexer.JetTokens.*; - /** * @author max */ @@ -46,26 +41,15 @@ public class JetBinaryExpression extends JetExpression { return null; } + @NotNull public ASTNode getOperationTokenNode() { - PsiElement child = getLeft().getNextSibling(); - - while (child != null) { - IElementType tt = child.getNode().getElementType(); - - if (JetTokens.WHITE_SPACE_OR_COMMENT_BIT_SET.contains(tt) || child instanceof PsiErrorElement) { - child = child.getNextSibling(); - } - else { - return child.getNode(); - } - } - - return null; + ASTNode operationNode = getNode().findChildByType(JetTokens.OPERATIONS); + assert operationNode != null; + return operationNode; } @Nullable public JetToken getOperationSign() { - ASTNode node = getOperationTokenNode(); - return node != null ? (JetToken) node.getElementType() : null; + return (JetToken) getOperationTokenNode().getElementType(); } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetBlockExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetBlockExpression.java new file mode 100644 index 00000000000..3168d1b3be8 --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/psi/JetBlockExpression.java @@ -0,0 +1,18 @@ +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; + +/** + * @author max + */ +public class JetBlockExpression extends JetExpression { + public JetBlockExpression(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(JetVisitor visitor) { + visitor.visitBlockExpression(this); + } +} diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetBreakExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetBreakExpression.java index 0bbefd9a91b..8c6d4ce2abd 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetBreakExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetBreakExpression.java @@ -1,7 +1,10 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lexer.JetTokens; /** * @author max @@ -15,4 +18,10 @@ public class JetBreakExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitBreakExpression(this); } + + @Nullable + public String getLabelName() { + PsiElement id = findChildByType(JetTokens.IDENTIFIER); + return id != null ? id.getText() : null; + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetCatchSection.java b/idea/src/org/jetbrains/jet/lang/psi/JetCatchSection.java new file mode 100644 index 00000000000..c8256b0f7ab --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/psi/JetCatchSection.java @@ -0,0 +1,40 @@ +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetNodeTypes; + +import java.util.List; + +/** + * @author max + */ +public class JetCatchSection extends JetElement { + public JetCatchSection(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(JetVisitor visitor) { + visitor.visitCatchSection(this); + } + + @Nullable + public JetParameterList getParameterList() { + return (JetParameterList) findChildByType(JetNodeTypes.VALUE_PARAMETER_LIST); + } + + @Nullable + public JetParameter getCatchParameter() { + JetParameterList list = getParameterList(); + if (list == null) return null; + List parameters = list.getParameters(); + return parameters.size() == 1 ? parameters.get(0) : null; + } + + + public JetExpression getCatchBody() { + return findChildByClass(JetExpression.class); + } +} diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetContinueExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetContinueExpression.java index b9282c946bf..f5f09201956 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetContinueExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetContinueExpression.java @@ -1,7 +1,10 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lexer.JetTokens; /** * @author max @@ -15,4 +18,10 @@ public class JetContinueExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitContinueExpression(this); } + + @Nullable + public String getLabelName() { + PsiElement id = findChildByType(JetTokens.IDENTIFIER); + return id != null ? id.getText() : null; + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetDoWhileExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetDoWhileExpression.java index 91d142f9134..45d24509c22 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetDoWhileExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetDoWhileExpression.java @@ -2,6 +2,8 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetNodeTypes; /** * @author max @@ -15,4 +17,13 @@ public class JetDoWhileExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitDoWhileExpression(this); } + + @Nullable + public JetExpression getCondition() { + return findExpressionUnder(JetNodeTypes.CONDITION); + } + + public JetExpression getBody() { + return findExpressionUnder(JetNodeTypes.THEN); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetExpression.java index c45b3165239..250c0b46ecb 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetExpression.java @@ -1,7 +1,10 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.JetNodeType; /** * @author max @@ -15,4 +18,12 @@ public class JetExpression extends JetElement { public void accept(JetVisitor visitor) { visitor.visitExpression(this); } + + + JetExpression findExpressionUnder(JetNodeType type) { + PsiElement containerNode = findChildByType(type); + if (containerNode == null) return null; + + return PsiTreeUtil.findChildOfType(containerNode, JetExpression.class); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetFinallySection.java b/idea/src/org/jetbrains/jet/lang/psi/JetFinallySection.java new file mode 100644 index 00000000000..18c0efc805e --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/psi/JetFinallySection.java @@ -0,0 +1,22 @@ +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; + +/** + * @author max + */ +public class JetFinallySection extends JetElement { + public JetFinallySection(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(JetVisitor visitor) { + visitor.visitFinallySection(this); + } + + public JetExpression getFinalExpression() { + return findChildByClass(JetExpression.class); + } +} diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetForExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetForExpression.java index e3458e03545..35bf5b7c77d 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetForExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetForExpression.java @@ -2,6 +2,7 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.JetNodeTypes; /** * @author max @@ -15,4 +16,16 @@ public class JetForExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitForExpression(this); } + + public JetParameter getLoopParameter() { + return (JetParameter) findChildByType(JetNodeTypes.LOOP_PARAMETER); + } + + public JetExpression getLoopRange() { + return findExpressionUnder(JetNodeTypes.LOOP_RANGE); + } + + public JetExpression getBody() { + return findExpressionUnder(JetNodeTypes.THEN); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetIfExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetIfExpression.java index 4ad72770491..64763cae9af 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetIfExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetIfExpression.java @@ -2,6 +2,8 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetNodeTypes; /** * @author max @@ -15,4 +17,17 @@ public class JetIfExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitIfExpression(this); } + + @Nullable + public JetExpression getCondition() { + return findExpressionUnder(JetNodeTypes.CONDITION); + } + + public JetExpression getThen() { + return findExpressionUnder(JetNodeTypes.THEN); + } + + public JetExpression getElse() { + return findExpressionUnder(JetNodeTypes.ELSE); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetNewExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetNewExpression.java index 8bbeee203bd..281ca8340f2 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetNewExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetNewExpression.java @@ -2,6 +2,11 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetNodeTypes; + +import java.util.Collections; +import java.util.List; /** * @author max @@ -15,4 +20,19 @@ public class JetNewExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitNewExpression(this); } + + public JetTypeReference getTypeReference() { + return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE); + } + + @Nullable + public JetArgumentList getArgumentList() { + return (JetArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST); + } + + @NotNull + public List getArguments() { + JetArgumentList list = getArgumentList(); + return list != null ? list.getArguments() : Collections.emptyList(); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetPostfixExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetPostfixExpression.java index 48db11ff363..2fe42726000 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetPostfixExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetPostfixExpression.java @@ -2,6 +2,9 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.jet.lexer.JetTokens; /** * @author max @@ -19,4 +22,16 @@ public class JetPostfixExpression extends JetExpression { public JetExpression getBaseExpression() { return findChildByClass(JetExpression.class); } + + @NotNull + public ASTNode getOperationTokenNode() { + ASTNode operationNode = getNode().findChildByType(JetTokens.OPERATIONS); + assert operationNode != null; + return operationNode; + } + + @Nullable + public JetToken getOperationSign() { + return (JetToken) getOperationTokenNode().getElementType(); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetPrefixExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetPrefixExpression.java index ee93386f620..64613380f5f 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetPrefixExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetPrefixExpression.java @@ -1,10 +1,10 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; -import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; - -import java.util.List; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lexer.JetToken; +import org.jetbrains.jet.lexer.JetTokens; /** * @author max @@ -22,4 +22,16 @@ public class JetPrefixExpression extends JetExpression { public JetExpression getBaseExpression() { return findChildByClass(JetExpression.class); } + + @NotNull + public ASTNode getOperationTokenNode() { + ASTNode operationNode = getNode().findChildByType(JetTokens.OPERATIONS); + assert operationNode != null; + return operationNode; + } + + @Nullable + public JetToken getOperationSign() { + return (JetToken) getOperationTokenNode().getElementType(); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetQualifiedExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetQualifiedExpression.java index f0655cab543..c5e0a2bda2d 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetQualifiedExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetQualifiedExpression.java @@ -1,7 +1,12 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiErrorElement; +import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lexer.JetTokens; /** * @author max @@ -10,4 +15,42 @@ public abstract class JetQualifiedExpression extends JetExpression { public JetQualifiedExpression(@NotNull ASTNode node) { super(node); } + + @NotNull + public JetExpression getReceiverExpression() { + JetExpression left = findChildByClass(JetExpression.class); + assert left != null; + return left; + } + + @Nullable + public JetExpression getSelectorExpression() { + ASTNode node = getOperationTokenNode(); + while (node != null) { + PsiElement psi = node.getPsi(); + if (psi instanceof JetExpression) { + return (JetExpression) psi; + } + node = node.getTreeNext(); + } + + return null; + } + + public ASTNode getOperationTokenNode() { + PsiElement child = getReceiverExpression().getNextSibling(); + + while (child != null) { + IElementType tt = child.getNode().getElementType(); + + if (JetTokens.WHITE_SPACE_OR_COMMENT_BIT_SET.contains(tt) || child instanceof PsiErrorElement) { + child = child.getNextSibling(); + } + else { + return child.getNode(); + } + } + + return null; + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetReturnExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetReturnExpression.java index 07f7930cdc7..478990d1e9a 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetReturnExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetReturnExpression.java @@ -2,6 +2,7 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author max @@ -15,4 +16,9 @@ public class JetReturnExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitReturnExpression(this); } + + @Nullable + public JetExpression getReturnedExpression() { + return findChildByClass(JetExpression.class); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetThrowExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetThrowExpression.java index 137fbb7f900..55bf69cc750 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetThrowExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetThrowExpression.java @@ -2,6 +2,7 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author max @@ -15,4 +16,9 @@ public class JetThrowExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitThrowExpression(this); } + + @Nullable + public JetExpression getThrownExpression() { + return findChildByClass(JetExpression.class); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetTryExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetTryExpression.java index 407c1015bc4..833c1d69500 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetTryExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetTryExpression.java @@ -15,4 +15,10 @@ public class JetTryExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitTryExpression(this); } + + public JetExpression getBody() { + return findChildByClass(JetExpression.class); + } + + } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetVisitor.java b/idea/src/org/jetbrains/jet/lang/psi/JetVisitor.java index cacd1e6d941..6211a0dd72d 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetVisitor.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetVisitor.java @@ -241,4 +241,16 @@ public class JetVisitor extends PsiElementVisitor { public void visitRootNamespaceExpression(JetRootNamespaceExpression expression) { visitExpression(expression); } + + public void visitBlockExpression(JetBlockExpression expression) { + visitExpression(expression); + } + + public void visitCatchSection(JetCatchSection catchSection) { + visitJetElement(catchSection); + } + + public void visitFinallySection(JetFinallySection finallySection) { + visitJetElement(finallySection); + } } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetWhileExpression.java b/idea/src/org/jetbrains/jet/lang/psi/JetWhileExpression.java index 561fc18acd8..a4fcf901d3b 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetWhileExpression.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetWhileExpression.java @@ -2,6 +2,8 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetNodeTypes; /** * @author max @@ -15,4 +17,13 @@ public class JetWhileExpression extends JetExpression { public void accept(JetVisitor visitor) { visitor.visitWhileExpression(this); } + + @Nullable + public JetExpression getCondition() { + return findExpressionUnder(JetNodeTypes.CONDITION); + } + + public JetExpression getBody() { + return findExpressionUnder(JetNodeTypes.THEN); + } } diff --git a/idea/src/org/jetbrains/jet/lexer/JetTokens.java b/idea/src/org/jetbrains/jet/lexer/JetTokens.java index 72e45b41482..6fc934ca61d 100644 --- a/idea/src/org/jetbrains/jet/lexer/JetTokens.java +++ b/idea/src/org/jetbrains/jet/lexer/JetTokens.java @@ -155,4 +155,9 @@ public interface JetTokens { TokenSet WHITESPACES = TokenSet.create(TokenType.WHITE_SPACE); TokenSet COMMENTS = TokenSet.create(EOL_COMMENT, BLOCK_COMMENT, DOC_COMMENT); TokenSet STRINGS = TokenSet.create(CHARACTER_LITERAL, STRING_LITERAL, RAW_STRING_LITERAL); + + TokenSet OPERATIONS = TokenSet.create(AS_KEYWORD, IS_KEYWORD, IN_KEYWORD, DOT, PLUSPLUS, MINUSMINUS, MUL, PLUS, + MINUS, EXCL, DIV, PERC, LT, GT, LTEQ, GTEQ, EQEQEQ, ARROW, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR, + SAFE_ACCESS, ELVIS, MAP, FILTER, QUEST, COLON, SEMICOLON, RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ, + NOT_IN, NOT_IS, HASH, IDENTIFIER, MATCH_KEYWORD); }