private @Nullable PsiElement resolveElement(@NotNull PsiFile containingFile) {
    PsiElement element = getParent();
    while (element != null && !(element instanceof PsiFile)) {
      if (element instanceof PsiMethod) {
        for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable((PsiMethod)element)) {
          if (myQualifiedName.equals(parameter.getName())) return parameter;
        }
      }
      else if (element instanceof PsiClass && !(element instanceof PsiTypeParameter)) {
        PsiClass psiClass = (PsiClass)element;
        if (myQualifiedName.equals(psiClass.getQualifiedName())) return element;
        for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(psiClass)) {
          if (myQualifiedName.equals(parameter.getName())) return parameter;
        }
        for (PsiClass innerClass : psiClass.getInnerClasses()) {
          if (myQualifiedName.equals(innerClass.getQualifiedName())) return innerClass;
        }
      }
      element = element.getParent();
    }

    Project project = containingFile.getProject();
    GlobalSearchScope scope = ResolveScopeManager.getInstance(project).getResolveScope(this);
    return JavaPsiFacade.getInstance(project).findClass(myQualifiedName, scope);
  }
private @Nullable PsiElement resolveElement(@NotNull PsiFile containingFile)