use of com.jetbrains.python.psi.PyDecorator in project intellij-community by JetBrains.
the class PyArgumentListFixer method doApply.
@Override
public void doApply(@NotNull Editor editor, @NotNull PySmartEnterProcessor processor, @NotNull PyArgumentList arguments) throws IncorrectOperationException {
final PsiElement rBrace = PyPsiUtils.getChildByFilter(arguments, PyTokenTypes.CLOSE_BRACES, 0);
if (arguments.getParent() instanceof PyClass || arguments.getParent() instanceof PyDecorator) {
final PsiElement lBrace = PyPsiUtils.getChildByFilter(arguments, PyTokenTypes.OPEN_BRACES, 0);
if (lBrace != null && rBrace == null) {
final Document document = editor.getDocument();
document.insertString(arguments.getTextRange().getEndOffset(), ")");
}
} else {
if (rBrace == null) {
final Document document = editor.getDocument();
document.insertString(arguments.getTextRange().getEndOffset(), ")");
}
}
}
use of com.jetbrains.python.psi.PyDecorator 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.PyDecorator in project intellij-community by JetBrains.
the class PyDecoratorTest method testDecoCall.
public void testDecoCall() throws Exception {
PsiElement targetElement = find().getParent();
assertTrue(targetElement instanceof PyDecorator);
PyDecorator deco = (PyDecorator) targetElement;
PyFunction decofun = deco.getTarget();
assertNotNull(decofun);
assertEquals("foo", decofun.getName());
assertFalse(deco.isBuiltin());
assertFalse(deco.hasArgumentList());
}
use of com.jetbrains.python.psi.PyDecorator in project intellij-community by JetBrains.
the class PyDecoratorTest method testDecoParamCall.
public void testDecoParamCall() throws Exception {
PsiElement targetElement = find().getParent();
assertTrue(targetElement instanceof PyDecorator);
PyDecorator deco = (PyDecorator) targetElement;
PyFunction decofun = deco.getTarget();
assertNotNull(decofun);
assertEquals("foo", decofun.getName());
assertFalse(deco.isBuiltin());
assertTrue(deco.hasArgumentList());
PyArgumentList arglist = deco.getArgumentList();
assertNotNull(arglist);
PyExpression[] args = arglist.getArguments();
assertEquals("argument count", 1, args.length);
assertEquals("argument value", "1", args[0].getText());
}
Aggregations