mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
provide type also for functions annotated as setter or deleter (PY-5951 take 2)
This commit is contained in:
@@ -42,6 +42,8 @@ public class PyNames {
|
||||
public static final String STATICMETHOD = "staticmethod";
|
||||
|
||||
public static final String PROPERTY = "property";
|
||||
public static final String SETTER = "setter";
|
||||
public static final String DELETER = "deleter";
|
||||
|
||||
public static final String ALL = "__all__";
|
||||
public static final String SLOTS = "__slots__";
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PyPropertyDefinitionInspection extends PyInspection {
|
||||
return PyBundle.message("INSP.NAME.property.definition");
|
||||
}
|
||||
|
||||
private static final ImmutableList<String> SUFFIXES = ImmutableList.of("setter", "deleter");
|
||||
private static final ImmutableList<String> SUFFIXES = ImmutableList.of(PyNames.SETTER, PyNames.DELETER);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -559,10 +559,10 @@ public class PyClassImpl extends PyPresentableElementImpl<PyClassStub> implement
|
||||
if (qname.matches(PyNames.PROPERTY)) {
|
||||
getter = new Maybe<PyFunction>(method);
|
||||
}
|
||||
else if (useAdvancedSyntax && qname.matches(decoratorName, "setter")) {
|
||||
else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.SETTER)) {
|
||||
setter = new Maybe<PyFunction>(method);
|
||||
}
|
||||
else if (useAdvancedSyntax && qname.matches(decoratorName, "deleter")) {
|
||||
else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.DELETER)) {
|
||||
deleter = new Maybe<PyFunction>(method);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,10 +313,16 @@ public class PyReferenceExpressionImpl extends PyElementImpl implements PyRefere
|
||||
if (target instanceof PyFunction) {
|
||||
final PyDecoratorList decoratorList = ((PyFunction)target).getDecoratorList();
|
||||
if (decoratorList != null) {
|
||||
final PyDecorator decorator = decoratorList.findDecorator(PyNames.PROPERTY);
|
||||
if (decorator != null) {
|
||||
final PyDecorator propertyDecorator = decoratorList.findDecorator(PyNames.PROPERTY);
|
||||
if (propertyDecorator != null) {
|
||||
return PyBuiltinCache.getInstance(target).getObjectType(PyNames.PROPERTY);
|
||||
}
|
||||
for (PyDecorator decorator: decoratorList.getDecorators()) {
|
||||
final PyQualifiedName qName = decorator.getQualifiedName();
|
||||
if (qName != null && (qName.endsWith(PyNames.SETTER) || qName.endsWith(PyNames.DELETER))) {
|
||||
return PyBuiltinCache.getInstance(target).getObjectType(PyNames.PROPERTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class C(object):
|
||||
def __init__(self):
|
||||
self._x = None
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
return self._x
|
||||
|
||||
@x.setter
|
||||
def x(self, value):
|
||||
self._x = value
|
||||
|
||||
@x.deleter
|
||||
@@ -0,0 +1,13 @@
|
||||
class C(object):
|
||||
def __init__(self):
|
||||
self._x = None
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
return self._x
|
||||
|
||||
@x.setter
|
||||
def x(self, value):
|
||||
self._x = value
|
||||
|
||||
@x.d<caret>
|
||||
@@ -16,6 +16,10 @@ public class Py3CompletionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPropertyAfterAccessor() { // PY-5951
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
final String testName = "completion/" + getTestName(true);
|
||||
myFixture.configureByFile(testName + ".py");
|
||||
|
||||
Reference in New Issue
Block a user