mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-16643: Context added to "visitClassAttributes"
This commit is contained in:
@@ -160,7 +160,7 @@ public interface PyClass extends PsiNameIdentifierOwner, PyStatement, NameDefine
|
||||
*/
|
||||
boolean visitMethods(Processor<PyFunction> processor, boolean inherited);
|
||||
|
||||
boolean visitClassAttributes(Processor<PyTargetExpression> processor, boolean inherited);
|
||||
boolean visitClassAttributes(Processor<PyTargetExpression> processor, boolean inherited, TypeEvalContext context);
|
||||
|
||||
/**
|
||||
* Effectively collects assignments inside the class body.
|
||||
|
||||
@@ -955,12 +955,13 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean visitClassAttributes(Processor<PyTargetExpression> processor, boolean inherited) {
|
||||
public boolean visitClassAttributes(Processor<PyTargetExpression> processor, boolean inherited, @Nullable final TypeEvalContext context) {
|
||||
List<PyTargetExpression> methods = getClassAttributes();
|
||||
if (!ContainerUtil.process(methods, processor)) return false;
|
||||
if (inherited) {
|
||||
for (PyClass ancestor : getAncestorClasses(null)) {
|
||||
if (!ancestor.visitClassAttributes(processor, false)) {
|
||||
for (PyClass ancestor : getAncestorClasses(context)) {
|
||||
// TODO: Why there is FALSE here? We support only one level of inheritance?
|
||||
if (!ancestor.visitClassAttributes(processor, false, context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -993,7 +994,7 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
|
||||
@Override
|
||||
public PyTargetExpression findClassAttribute(@NotNull String name, boolean inherited) {
|
||||
final NameFinder<PyTargetExpression> processor = new NameFinder<PyTargetExpression>(name);
|
||||
visitClassAttributes(processor, inherited);
|
||||
visitClassAttributes(processor, inherited, null);
|
||||
return processor.getResult();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user