Make JetDotQualifiedExpression extend JetElementImplStub
This commit is contained in:
@@ -17,9 +17,12 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
|
||||
public class JetDotQualifiedExpression extends JetQualifiedExpressionImpl {
|
||||
public class JetDotQualifiedExpression<T extends StubElement> extends JetExpressionImplStub<T> implements JetQualifiedExpression {
|
||||
public JetDotQualifiedExpression(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -28,4 +31,29 @@ public class JetDotQualifiedExpression extends JetQualifiedExpressionImpl {
|
||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitDotQualifiedExpression(this, data);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetExpression getReceiverExpression() {
|
||||
return JetQualifiedExpressionImpl.instance$.getReceiverExpression(this);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetExpression getSelectorExpression() {
|
||||
return JetQualifiedExpressionImpl.instance$.getSelectorExpression(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode getOperationTokenNode() {
|
||||
return JetQualifiedExpressionImpl.instance$.getOperationTokenNode(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetToken getOperationSign() {
|
||||
return JetQualifiedExpressionImpl.instance$.getOperationSign(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
public interface JetQualifiedExpression extends JetExpression {
|
||||
@NotNull
|
||||
JetExpression getReceiverExpression();
|
||||
|
||||
@Nullable
|
||||
JetExpression getSelectorExpression();
|
||||
|
||||
@NotNull
|
||||
ASTNode getOperationTokenNode();
|
||||
|
||||
@NotNull
|
||||
JetToken getOperationSign();
|
||||
}
|
||||
+10
-15
@@ -21,29 +21,24 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.annotations.Nullable
|
||||
import org.jetbrains.jet.lexer.JetToken
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
|
||||
public trait JetQualifiedExpression : JetExpression {
|
||||
public fun getReceiverExpression(): JetExpression
|
||||
|
||||
public fun getSelectorExpression(): JetExpression?
|
||||
|
||||
public fun getOperationTokenNode(): ASTNode {
|
||||
val operationNode = getNode()!!.findChildByType(JetTokens.OPERATIONS)
|
||||
object JetQualifiedExpressionImpl {
|
||||
public fun JetQualifiedExpression.getOperationTokenNode(): ASTNode {
|
||||
val operationNode = this.getNode()!!.findChildByType(JetTokens.OPERATIONS)
|
||||
return operationNode!!
|
||||
}
|
||||
|
||||
public fun getOperationSign(): JetToken {
|
||||
return getOperationTokenNode().getElementType() as JetToken
|
||||
public fun JetQualifiedExpression.getOperationSign(): JetToken {
|
||||
return this.getOperationTokenNode().getElementType() as JetToken
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class JetQualifiedExpressionImpl(node: ASTNode) : JetExpressionImpl(node), JetQualifiedExpression {
|
||||
public override fun getReceiverExpression(): JetExpression {
|
||||
val left = findChildByClass(javaClass<JetExpression>())
|
||||
public fun JetQualifiedExpression.getReceiverExpression(): JetExpression {
|
||||
val left = PsiTreeUtil.findChildOfType(this, javaClass<JetExpression>())
|
||||
return left!!
|
||||
}
|
||||
|
||||
public override fun getSelectorExpression(): JetExpression? {
|
||||
public fun JetQualifiedExpression.getSelectorExpression(): JetExpression? {
|
||||
var node: ASTNode? = getOperationTokenNode()
|
||||
while (node != null) {
|
||||
val psi = node!!.getPsi()
|
||||
@@ -54,4 +49,4 @@ public abstract class JetQualifiedExpressionImpl(node: ASTNode) : JetExpressionI
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,10 @@ 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;
|
||||
|
||||
public class JetSafeQualifiedExpression extends JetQualifiedExpressionImpl {
|
||||
public class JetSafeQualifiedExpression extends JetExpressionImpl implements JetQualifiedExpression {
|
||||
public JetSafeQualifiedExpression(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -28,4 +30,28 @@ public class JetSafeQualifiedExpression extends JetQualifiedExpressionImpl {
|
||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitSafeQualifiedExpression(this, data);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetExpression getReceiverExpression() {
|
||||
return JetQualifiedExpressionImpl.instance$.getReceiverExpression(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetExpression getSelectorExpression() {
|
||||
return JetQualifiedExpressionImpl.instance$.getSelectorExpression(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ASTNode getOperationTokenNode() {
|
||||
return JetQualifiedExpressionImpl.instance$.getOperationTokenNode(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetToken getOperationSign() {
|
||||
return JetQualifiedExpressionImpl.instance$.getOperationSign(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user