PsiElement (@NotNull Editor editor, @NotNull PsiFile file, @Nullable PsiElement contextElement, int targetOffset) { if (contextElement != null && PythonRuntimeService.getInstance().isInPydevConsole(contextElement)) { final IElementType elementType = contextElement.getNode().getElementType(); if (PythonDialectsTokenSetProvider.getInstance().getKeywordTokens().contains(elementType)) { return contextElement; } final PsiElement parent = contextElement.getParent(); if (parent instanceof PyArgumentList && (PyTokenTypes.LPAR == elementType || PyTokenTypes.RPAR == elementType)) { final PyCallExpression expression = PsiTreeUtil.getParentOfType(contextElement, PyCallExpression.class); if (expression != null) { return expression.getCallee(); } } } return null; }