PY-16643: Context added to "visitClassAttributes"

This commit is contained in:
Ilya.Kazakevich
2015-08-11 21:35:22 +03:00
parent 2fb14bf02e
commit cdd3e05d9f
2 changed files with 6 additions and 5 deletions
@@ -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();
}