private static boolean fixMethodCallWithoutTrailingSemicolon(@Nullable ASTNode returnStatement, @NotNull Editor editor,
                                                               @NotNull AbstractBasicJavaSmartEnterProcessor processor) {
    if (returnStatement == null) {
      return false;
    }

    final ASTNode lastChild = returnStatement.getLastChildNode();
    if (!(BasicJavaAstTreeUtil.is(lastChild, TokenType.ERROR_ELEMENT))) {
      return false;
    }
    ASTNode prev = lastChild.getTreePrev();
    if (BasicJavaAstTreeUtil.isWhiteSpace(prev)) {
      prev = prev.getTreePrev();
    }

    if (!(prev instanceof PsiJavaToken prevToken)) {
      int offset = returnStatement.getTextRange().getEndOffset();
      final PsiElement psiMethod =
        BasicJavaAstTreeUtil.getParentOfType(BasicJavaAstTreeUtil.toPsi(returnStatement), BASIC_METHOD, true,
                                             ParentAwareTokenSet.create(BASIC_LAMBDA_EXPRESSION));
      ASTNode method = BasicJavaAstTreeUtil.toNode(psiMethod);
      ASTNode type = BasicJavaAstTreeUtil.findChildByType(method, BASIC_TYPE);
      if (method != null && type != null && type.getText().equals("void")) {
        offset = returnStatement.getTextRange().getStartOffset() + "return".length();
      }
      editor.getDocument().insertString(offset, ";");
      //processor.setSkipEnter(true);
      return true;
    }

    if (prevToken.getTokenType() == JavaTokenType.SEMICOLON) {
      return false;
    }

    final int offset = returnStatement.getTextRange().getEndOffset();
    editor.getDocument().insertString(offset, ";");
    if (prevToken.getTokenType() == JavaTokenType.RETURN_KEYWORD) {
      final ASTNode method = BasicJavaAstTreeUtil.getParentOfType(returnStatement, BASIC_METHOD);
      ASTNode type = BasicJavaAstTreeUtil.findChildByType(method, BASIC_TYPE);
      if (method != null && type != null && !type.getText().equals("void")) {
        editor.getCaretModel().moveToOffset(offset);
        processor.setSkipEnter(true);
      }
    }
    return true;
  }
private static boolean fixMethodCallWithoutTrailingSemicolon(@Nullable ASTNode returnStatement, @NotNull Editor editor,
                                                               @NotNull AbstractBasicJavaSmartEnterProcessor processor)