typereferences
This commit is contained in:
@@ -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,9 @@ public class JetParameter extends JetNamedDeclaration {
|
||||
public void accept(JetVisitor visitor) {
|
||||
visitor.visitParameter(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetTypeReference getTypeReference() {
|
||||
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -15,4 +19,22 @@ public class JetProperty extends JetNamedDeclaration {
|
||||
public void accept(@NotNull JetVisitor visitor) {
|
||||
visitor.visitProperty(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetTypeReference getTypeReference() {
|
||||
ASTNode node = getNode().getFirstChildNode();
|
||||
boolean passedColon = false;
|
||||
while (node != null) {
|
||||
IElementType tt = node.getElementType();
|
||||
if (tt == JetTokens.COLON) {
|
||||
passedColon = true;
|
||||
}
|
||||
else if (tt == JetNodeTypes.TYPE_REFERENCE && passedColon) {
|
||||
return (JetTypeReference) node.getPsi();
|
||||
}
|
||||
node = node.getTreeNext();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,9 @@ public class JetTypedef extends JetTypeParameterListOwner {
|
||||
public void accept(@NotNull JetVisitor visitor) {
|
||||
visitor.visitTypedef(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetTypeReference getTypeReference() {
|
||||
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user