Search in sources :

Example 1 with PyNamedParameterStub

use of com.jetbrains.python.psi.stubs.PyNamedParameterStub in project intellij-community by JetBrains.

the class PyNamedParameterImpl method getTypeCommentAnnotation.

@Nullable
@Override
public String getTypeCommentAnnotation() {
    final PyNamedParameterStub stub = getStub();
    if (stub != null) {
        return stub.getTypeComment();
    }
    final PsiComment comment = getTypeComment();
    if (comment != null) {
        return PyTypingTypeProvider.getTypeCommentValue(comment.getText());
    }
    return null;
}
Also used : PyNamedParameterStub(com.jetbrains.python.psi.stubs.PyNamedParameterStub) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with PyNamedParameterStub

use of com.jetbrains.python.psi.stubs.PyNamedParameterStub in project intellij-community by JetBrains.

the class PyNamedParameterImpl method getDefaultValue.

@Nullable
public PyExpression getDefaultValue() {
    final PyNamedParameterStub stub = getStub();
    if (stub != null && !stub.hasDefaultValue()) {
        return null;
    }
    ASTNode[] nodes = getNode().getChildren(PythonDialectsTokenSetProvider.INSTANCE.getExpressionTokens());
    if (nodes.length > 0) {
        return (PyExpression) nodes[0].getPsi();
    }
    return null;
}
Also used : ASTNode(com.intellij.lang.ASTNode) PyNamedParameterStub(com.jetbrains.python.psi.stubs.PyNamedParameterStub) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PyNamedParameterStub (com.jetbrains.python.psi.stubs.PyNamedParameterStub)2 Nullable (org.jetbrains.annotations.Nullable)2 ASTNode (com.intellij.lang.ASTNode)1