public static @NotNull PsiElement decodeContextInfo(@NotNull PsiElement scope,
                                                      @Nullable PsiClass thisClass,
                                                      @Nullable PsiExpression thisAccessExpr) throws IncorrectOperationException {
    if (scope instanceof StubBasedPsiElement) {
      scope.putUserData(HARD_REF_TO_AST, null);
    }
    if (scope.getCopyableUserData(ENCODED_KEY) != null) {
      scope.putCopyableUserData(ENCODED_KEY, null);

      if (scope instanceof PsiThisExpression) {
        PsiThisExpression thisExpr = (PsiThisExpression)scope;
        scope = decodeThisExpression(thisExpr, thisClass, thisAccessExpr);
      }
      else if (scope instanceof PsiReferenceExpression) {
        scope = decodeReferenceExpression((PsiReferenceExpression)scope, thisAccessExpr, thisClass);
      }
      else {
        PsiClass refClass = scope.getCopyableUserData(REF_CLASS_KEY);
        scope.putCopyableUserData(REF_CLASS_KEY, null);

        if (refClass != null && refClass.isValid()) {
          PsiReference ref = scope.getReference();
          if (ref != null) {
            final String qualifiedName = refClass.getQualifiedName();
            if (qualifiedName != null) {
              if (JavaPsiFacade.getInstance(refClass.getProject()).findClass(qualifiedName, scope.getResolveScope()) != null) {
                scope = ref.bindToElement(refClass);
              }
            }
          }
        }
      }
    }

    if (scope instanceof PsiClass) {
      if (thisAccessExpr != null) {
        thisAccessExpr = (PsiExpression)qualifyThis(thisAccessExpr, thisClass);
      }
    }

    PsiElement child = scope.getFirstChild();
    while (child != null) {
      child = decodeContextInfo(child, thisClass, thisAccessExpr).getNextSibling();
    }

    return scope;
  }
public static @NotNull PsiElement decodeContextInfo(@NotNull PsiElement scope,
                                                      @Nullable PsiClass thisClass,
                                                      @Nullable PsiExpression thisAccessExpr)