Parameter node getters
This commit is contained in:
@@ -4,6 +4,7 @@ import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -22,4 +23,29 @@ public class JetParameter extends JetNamedDeclaration {
|
||||
public JetTypeReference getTypeReference() {
|
||||
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetExpression getDefaultValue() {
|
||||
boolean passedEQ = false;
|
||||
ASTNode child = getNode().getFirstChildNode();
|
||||
while (child != null) {
|
||||
if (child.getElementType() == JetTokens.EQ) passedEQ = true;
|
||||
if (passedEQ && child.getPsi() instanceof JetExpression) {
|
||||
return (JetExpression) child.getPsi();
|
||||
}
|
||||
child = child.getTreeNext();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isOut() {
|
||||
JetModifierList modifierList = getModifierList();
|
||||
return modifierList != null && modifierList.hasModifier(JetTokens.OUT_KEYWORD);
|
||||
}
|
||||
|
||||
public boolean isRef() {
|
||||
JetModifierList modifierList = getModifierList();
|
||||
return modifierList != null && modifierList.hasModifier(JetTokens.REF_KEYWORD);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user