Search in sources :

Example 1 with PropertyStubStorage

use of com.jetbrains.python.psi.stubs.PropertyStubStorage in project intellij-community by JetBrains.

the class PyClassImpl method processStubProperties.

@Nullable
private Property processStubProperties(@Nullable String name, @Nullable Processor<Property> propertyProcessor) {
    final PyClassStub stub = getStub();
    if (stub != null) {
        for (StubElement subStub : stub.getChildrenStubs()) {
            if (subStub.getStubType() == PyElementTypes.TARGET_EXPRESSION) {
                final PyTargetExpressionStub targetStub = (PyTargetExpressionStub) subStub;
                PropertyStubStorage prop = targetStub.getCustomStub(PropertyStubStorage.class);
                if (prop != null && (name == null || name.equals(targetStub.getName()))) {
                    Maybe<PyCallable> getter = fromPacked(prop.getGetter());
                    Maybe<PyCallable> setter = fromPacked(prop.getSetter());
                    Maybe<PyCallable> deleter = fromPacked(prop.getDeleter());
                    String doc = prop.getDoc();
                    if (getter != NONE || setter != NONE || deleter != NONE) {
                        final PropertyImpl property = new PropertyImpl(targetStub.getName(), getter, setter, deleter, doc, targetStub.getPsi());
                        if (propertyProcessor == null || propertyProcessor.process(property))
                            return property;
                    }
                }
            }
        }
    }
    return null;
}
Also used : PropertyStubStorage(com.jetbrains.python.psi.stubs.PropertyStubStorage) PyClassStub(com.jetbrains.python.psi.stubs.PyClassStub) PyTargetExpressionStub(com.jetbrains.python.psi.stubs.PyTargetExpressionStub) StubElement(com.intellij.psi.stubs.StubElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

StubElement (com.intellij.psi.stubs.StubElement)1 PropertyStubStorage (com.jetbrains.python.psi.stubs.PropertyStubStorage)1 PyClassStub (com.jetbrains.python.psi.stubs.PyClassStub)1 PyTargetExpressionStub (com.jetbrains.python.psi.stubs.PyTargetExpressionStub)1 Nullable (org.jetbrains.annotations.Nullable)1