Search in sources :

Example 6 with PyCallExpression

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

the class PyResolveCalleeTest method resolveCallee.

@NotNull
private PyCallExpression.PyMarkedCallee resolveCallee() {
    final PsiReference ref = myFixture.getReferenceAtCaretPosition("/resolve/callee/" + getTestName(false) + ".py");
    final PyCallExpression call = PsiTreeUtil.getParentOfType(ref.getElement(), PyCallExpression.class);
    final TypeEvalContext context = TypeEvalContext.codeAnalysis(myFixture.getProject(), myFixture.getFile());
    final PyResolveContext resolveContext = PyResolveContext.noImplicits().withTypeEvalContext(context);
    final List<PyCallExpression.PyMarkedCallee> callees = call.multiResolveCallee(resolveContext);
    assertEquals(1, callees.size());
    return callees.get(0);
}
Also used : PyResolveContext(com.jetbrains.python.psi.resolve.PyResolveContext) PsiReference(com.intellij.psi.PsiReference) PyCallExpression(com.jetbrains.python.psi.PyCallExpression) TypeEvalContext(com.jetbrains.python.psi.types.TypeEvalContext) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with PyCallExpression

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

the class PySmartStepIntoHandler method addVariants.

private static void addVariants(Document document, int line, @Nullable PsiElement element, List<PySmartStepIntoVariant> variants, Set<PyCallExpression> visited) {
    if (element == null)
        return;
    final PyCallExpression expression = PsiTreeUtil.getParentOfType(element, PyCallExpression.class);
    if (expression != null && expression.getTextRange().getEndOffset() <= document.getLineEndOffset(line) && visited.add(expression)) {
        addVariants(document, line, expression.getParent(), variants, visited);
        PyExpression ref = expression.getCallee();
        variants.add(new PySmartStepIntoVariant(ref));
    }
}
Also used : PyExpression(com.jetbrains.python.psi.PyExpression) PyCallExpression(com.jetbrains.python.psi.PyCallExpression)

Aggregations

PyCallExpression (com.jetbrains.python.psi.PyCallExpression)7 PyExpression (com.jetbrains.python.psi.PyExpression)2 NotNull (org.jetbrains.annotations.NotNull)2 ASTNode (com.intellij.lang.ASTNode)1 Document (com.intellij.openapi.editor.Document)1 Module (com.intellij.openapi.module.Module)1 PsiElement (com.intellij.psi.PsiElement)1 PsiReference (com.intellij.psi.PsiReference)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 LanguageLevel (com.jetbrains.python.psi.LanguageLevel)1 PyArgumentList (com.jetbrains.python.psi.PyArgumentList)1 PyDecorator (com.jetbrains.python.psi.PyDecorator)1 PyElementGenerator (com.jetbrains.python.psi.PyElementGenerator)1 PyFile (com.jetbrains.python.psi.PyFile)1 PyKeywordArgument (com.jetbrains.python.psi.PyKeywordArgument)1 PyResolveContext (com.jetbrains.python.psi.resolve.PyResolveContext)1 TypeEvalContext (com.jetbrains.python.psi.types.TypeEvalContext)1