mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't insert parentheses when completing a function call if the function has any custom decorators (PY-4859)
This commit is contained in:
@@ -47,6 +47,7 @@ public class CompletionVariantsProcessor extends VariantsProcessor {
|
||||
if (!myPlainNamesOnly) {
|
||||
if (!mySuppressParentheses &&
|
||||
object instanceof PyFunction && ((PyFunction)object).getProperty() == null &&
|
||||
hasNoCustomDecorators((PyFunction)object) &&
|
||||
!isSingleArgDecoratorCall(myContext, (PyFunction)object)) {
|
||||
item = item.withInsertHandler(PyFunctionInsertHandler.INSTANCE);
|
||||
final PyParameterList parameterList = ((PyFunction)object).getParameterList();
|
||||
@@ -102,6 +103,21 @@ public class CompletionVariantsProcessor extends VariantsProcessor {
|
||||
return item;
|
||||
}
|
||||
|
||||
private static boolean hasNoCustomDecorators(PyFunction function) {
|
||||
PyDecoratorList decoratorList = function.getDecoratorList();
|
||||
if (decoratorList == null) {
|
||||
return true;
|
||||
}
|
||||
for (PyDecorator decorator : decoratorList.getDecorators()) {
|
||||
PyQualifiedName name = decorator.getQualifiedName();
|
||||
if (name == null || (!PyNames.CLASSMETHOD.equals(name.toString()) && !PyNames.STATICMETHOD.equals(name.toString()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isSingleArgDecoratorCall(PsiElement elementInCall, PyFunction callee) {
|
||||
// special case hack to avoid the need of patching generator3.py
|
||||
PyClass containingClass = callee.getContainingClass();
|
||||
|
||||
Reference in New Issue
Block a user