use of com.jetbrains.python.psi.PyCallExpression in project intellij-community by JetBrains.
the class PySmartStepIntoHandler method computeSmartStepVariants.
@Override
@NotNull
public List<PySmartStepIntoVariant> computeSmartStepVariants(@NotNull XSourcePosition position) {
final Document document = FileDocumentManager.getInstance().getDocument(position.getFile());
final List<PySmartStepIntoVariant> variants = Lists.newArrayList();
final Set<PyCallExpression> visitedCalls = Sets.newHashSet();
final int line = position.getLine();
XDebuggerUtil.getInstance().iterateLine(mySession.getProject(), document, line, psiElement -> {
addVariants(document, line, psiElement, variants, visitedCalls);
return true;
});
return variants;
}
use of com.jetbrains.python.psi.PyCallExpression in project intellij-community by JetBrains.
the class PyRemoveCallQuickFix method applyFix.
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiElement call = descriptor.getPsiElement();
assert call instanceof PyCallExpression;
if (call instanceof PyDecorator) {
call.delete();
} else {
final PyArgumentList argumentList = ((PyCallExpression) call).getArgumentList();
assert argumentList != null;
argumentList.delete();
}
}
use of com.jetbrains.python.psi.PyCallExpression in project intellij-community by JetBrains.
the class PyPackageUtilTest method doTestSetupPyReading.
private void doTestSetupPyReading(boolean hasFile, boolean hasCall, boolean requires) {
final Module module = myFixture.getModule();
if (hasFile) {
assertTrue(PyPackageUtil.hasSetupPy(module));
final PyFile setupPy = PyPackageUtil.findSetupPy(module);
assertNotNull(setupPy);
if (hasCall) {
final PyCallExpression callByModule = PyPackageUtil.findSetupCall(module);
final PyCallExpression callByFile = PyPackageUtil.findSetupCall(setupPy);
assertNotNull(callByModule);
assertNotNull(callByFile);
assertSame(callByFile, callByModule);
if (requires) {
checkRequirements(PyPackageUtil.findSetupPyRequires(module));
} else {
final List<PyRequirement> requirements = PyPackageUtil.findSetupPyRequires(module);
assertNotNull(requirements);
assertEmpty(requirements);
}
} else {
assertNull(PyPackageUtil.findSetupCall(module));
assertNull(PyPackageUtil.findSetupCall(setupPy));
assertNull(PyPackageUtil.findSetupPyRequires(module));
}
} else {
assertFalse(PyPackageUtil.hasSetupPy(module));
assertNull(PyPackageUtil.findSetupPy(module));
assertNull(PyPackageUtil.findSetupCall(module));
assertNull(PyPackageUtil.findSetupPyRequires(module));
}
}
use of com.jetbrains.python.psi.PyCallExpression in project intellij-community by JetBrains.
the class PyPackageUtilTest method checkSetupArgumentText.
private static void checkSetupArgumentText(@NotNull Module module, @NotNull String keyword, @Nullable String text) {
final PyCallExpression setupCall = PyPackageUtil.findSetupCall(module);
assertNotNull(setupCall);
final PyExpression argument = setupCall.getKeywordArgument(keyword);
if (text == null) {
assertNull(argument);
} else {
assertNotNull(argument);
assertEquals(text, argument.getText());
}
}
use of com.jetbrains.python.psi.PyCallExpression in project intellij-community by JetBrains.
the class PyKeywordArgumentManipulator method handleContentChange.
@Override
public PyKeywordArgument handleContentChange(@NotNull PyKeywordArgument element, @NotNull TextRange range, String newContent) throws IncorrectOperationException {
final ASTNode keywordNode = element.getKeywordNode();
if (keywordNode != null && keywordNode.getTextRange().shiftRight(-element.getTextRange().getStartOffset()).equals(range)) {
final LanguageLevel langLevel = LanguageLevel.forElement(element);
final PyElementGenerator generator = PyElementGenerator.getInstance(element.getProject());
final PyCallExpression callExpression = (PyCallExpression) generator.createExpressionFromText(langLevel, "foo(" + newContent + "=None)");
final PyKeywordArgument kwArg = callExpression.getArgumentList().getKeywordArgument(newContent);
element.getKeywordNode().getPsi().replace(kwArg.getKeywordNode().getPsi());
return element;
}
throw new IncorrectOperationException("unsupported manipulation on keyword argument");
}
Aggregations