visitor for tuple expression

This commit is contained in:
Max Medvedev
2013-04-30 11:49:14 +04:00
parent cbf9342ba8
commit 6d1eaa3ea1
3 changed files with 20 additions and 7 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -443,4 +443,8 @@ public abstract class GroovyElementVisitor {
public void visitTypeParameter(GrTypeParameter typeParameter) {
visitTypeDefinition(typeParameter);
}
public void visitTupleExpression(GrTupleExpression tupleExpression) {
visitExpression(tupleExpression);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,12 +17,14 @@
package org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
/**
* @author ilyas
*/
public interface GrTupleExpression extends GrExpression {
int indexOf(PsiElement element);
int indexOf(@NotNull PsiElement element);
@NotNull
GrExpression[] getExpressions();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,9 @@ import com.intellij.lang.ASTNode;
import com.intellij.psi.CommonClassNames;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiType;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ArrayUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrTupleExpression;
@@ -44,12 +45,18 @@ public class GrTupleExpressionImpl extends GrExpressionImpl implements GrTupleEx
}
@Override
public int indexOf(PsiElement element) {
public int indexOf(@NotNull PsiElement element) {
GrExpression[] children = getExpressions();
return ArrayUtil.find(children, element);
return ArrayUtilRt.find(children, element);
}
@NotNull
public GrExpression[] getExpressions() {
return findChildrenByClass(GrExpression.class);
}
@Override
public void accept(GroovyElementVisitor visitor) {
visitor.visitTupleExpression(this);
}
}