private void adjustTargetClassReferences(final PsiElement body) throws IncorrectOperationException {
    PsiManager manager = PsiManager.getInstance(myProject);
    PsiClass targetClass = getMethod().getContainingClass();
    //Actually we should go into lambdas as this/super expressions inside them still refer to the outer class instance.
    //Visiting returns inside lambdas is safe as they never have GENERATED_RETURN inside
    //noinspection UnsafeReturnStatementVisitor
    body.accept(new JavaRecursiveElementVisitor() {
      @Override
      public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
        if (statement.getCopyableUserData(GENERATED_RETURN) == null) { // do not modify our generated returns
          super.visitReturnStatement(statement);
        }
      }

      @Override
      public void visitThisExpression(@NotNull PsiThisExpression expression) {
        if (expression.getQualifier() == null) {
          expression.replace(RefactoringChangeUtil.createThisExpression(manager, targetClass));
        }
      }

      @Override
      public void visitSuperExpression(@NotNull PsiSuperExpression expression) {
        if (expression.getQualifier() == null) {
          expression.replace(RefactoringChangeUtil.createSuperExpression(manager, targetClass));
        }
      }

      @Override
      public void visitClass(@NotNull PsiClass aClass) {
        // do not visit sub classes
      }
    });
  }
private void adjustTargetClassReferences(final PsiElement body)