mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
correct type for static access to properties (PY-5915)
This commit is contained in:
@@ -216,12 +216,16 @@ public class PyReferenceExpressionImpl extends PyElementImpl implements PyRefere
|
||||
PyExpression qualifier = getQualifier();
|
||||
final String name = getName();
|
||||
if (name != null && qualifier != null) {
|
||||
PyType qualifier_type = context.getType(qualifier);
|
||||
if (qualifier_type instanceof PyClassType) {
|
||||
PyClass pyClass = ((PyClassType)qualifier_type).getPyClass();
|
||||
PyType qualifierType = context.getType(qualifier);
|
||||
if (qualifierType instanceof PyClassType) {
|
||||
final PyClassType classType = (PyClassType)qualifierType;
|
||||
PyClass pyClass = classType.getPyClass();
|
||||
if (pyClass != null) {
|
||||
Property property = pyClass.findProperty(name);
|
||||
if (property != null) {
|
||||
if (classType.isDefinition()) {
|
||||
return Ref.<PyType>create(PyBuiltinCache.getInstance(pyClass).getObjectType(PyNames.PROPERTY));
|
||||
}
|
||||
final Maybe<PyFunction> accessor = property.getByDirection(AccessDirection.of(this));
|
||||
if (!accessor.isDefined()) {
|
||||
return Ref.create(null);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# coding=utf-8
|
||||
|
||||
"""
|
||||
Sample of code that use fget
|
||||
"""
|
||||
|
||||
class Parent(object):
|
||||
"""
|
||||
parent class to show a simply property
|
||||
"""
|
||||
|
||||
@property
|
||||
def attribute(self):
|
||||
"""
|
||||
some attribute in parent
|
||||
"""
|
||||
return True
|
||||
|
||||
class Child(Parent):
|
||||
"""
|
||||
child class
|
||||
"""
|
||||
|
||||
@property
|
||||
def attribute(self):
|
||||
"""
|
||||
do something before execute code of parent attribute
|
||||
"""
|
||||
print "i'm the child"
|
||||
return Parent.attribute.fget(self)
|
||||
|
||||
if __name__ == '__main__':
|
||||
child = Child()
|
||||
print child.attribute
|
||||
+4
@@ -93,6 +93,10 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
public void testPropertyType() { // PY-5915
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doMultiFileTest() {
|
||||
myFixture.copyFileToProject("inspections/PyUnresolvedReferencesInspection/__init__.py", "PyUnresolvedReferencesInspection/__init__.py");
|
||||
myFixture.copyFileToProject("inspections/PyUnresolvedReferencesInspection/" + getTestName(true) + ".py",
|
||||
|
||||
Reference in New Issue
Block a user