package com.jetbrains.python.psi.types;

import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyResolveUtil;
import com.jetbrains.python.psi.PyReferenceExpression;
import com.intellij.psi.PsiElement;
import com.intellij.psi.ResolveState;
import org.jetbrains.annotations.Nullable;

/**
 * @author yole
 */
public class PyClassType implements PyType {
  private PyClass myClass;

  public PyClassType(final PyClass aClass) {
    myClass = aClass;
  }

  public PyClass getPyClass() {
    return myClass;
  }

  @Nullable
  public PsiElement resolveMember(final String name) {
    return PyResolveUtil.treeWalkUp(new PyResolveUtil.ResolveProcessor(name), myClass, null, null);
  }

  public Object[] getCompletionVariants(final PyReferenceExpression referenceExpression) {
    final PyResolveUtil.VariantsProcessor processor = new PyResolveUtil.VariantsProcessor();
    myClass.processDeclarations(processor, ResolveState.initial(), null, referenceExpression);
    return processor.getResult();
  }
}

@@ -34,16 +34,90 @@
 types;%0A%0A
+import com.intellij.psi.PsiElement;%0Aimport com.intellij.psi.ResolveState;%0A
 import c
@@ -183,27 +183,26 @@
 n.psi.Py
-ResolveUtil
+Expression
 ;%0Aimport
@@ -265,69 +265,42 @@
 com.
-intellij.psi.PsiElement;%0Aimport com.intellij
+jetbrains.python
 .psi.
+Py
 Resolve
-State
+Util
 ;%0Aim
@@ -638,22 +638,48 @@
 ) %7B%0A    
-return
+final PsiElement resolveResult =
  PyResol
@@ -760,16 +760,527 @@
  null);%0A
+    if (resolveResult != null) %7B%0A      return resolveResult;%0A    %7D%0A    final PyExpression%5B%5D superClassExpressions = myClass.getSuperClassExpressions();%0A    if (superClassExpressions != null) %7B%0A      for(PyExpression expr: superClassExpressions) %7B%0A        PyType superType = expr.getType();%0A        if (superType != null) %7B%0A          PsiElement superMember = superType.resolveMember(name);%0A          if (superMember != null) %7B%0A            return superMember;%0A          %7D%0A        %7D%0A      %7D%0A    %7D%0A    return null;%0A
   %7D%0A%0A  p

resolve to superclass member