From 76a9727974ca07117f9f295ed6d70ae4cfaf0659 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Wed, 7 May 2025 12:51:08 +0200 Subject: [PATCH] [java] JavaDocCommentFixer: reduce editor dependency GitOrigin-RevId: b53db1529dbcbc7a15e6b8c09ab13344d5a56bfa --- .../codeInsight/documentation/JavaDocCommentFixer.java | 9 +++++---- .../com/intellij/javadoc/JavadocNavigationDelegate.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/documentation/JavaDocCommentFixer.java b/java/java-impl/src/com/intellij/codeInsight/documentation/JavaDocCommentFixer.java index f77f74270c86..2edefc29a1e5 100644 --- a/java/java-impl/src/com/intellij/codeInsight/documentation/JavaDocCommentFixer.java +++ b/java/java-impl/src/com/intellij/codeInsight/documentation/JavaDocCommentFixer.java @@ -81,12 +81,13 @@ public final class JavaDocCommentFixer implements DocCommentFixer { if (!referenceProblems.isEmpty()) { fixReferenceProblems(ContainerUtil.flatten(referenceProblems.values()), project); } + Document document = file.getFileDocument(); if (!commonProblems.isEmpty()) { - fixCommonProblems(ContainerUtil.flatten(commonProblems.values()), comment, editor.getDocument(), project); + fixCommonProblems(ContainerUtil.flatten(commonProblems.values()), comment, document, project); } - PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument()); - ensureContentOrdered(docComment, editor.getDocument()); + PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document); + ensureContentOrdered(docComment, document); locateCaret(docComment, editor, file); } @@ -294,7 +295,7 @@ public final class JavaDocCommentFixer implements DocCommentFixer { } private static void locateCaret(@NotNull PsiDocComment comment, @NotNull Editor editor, @NotNull PsiFile file) { - Document document = editor.getDocument(); + Document document = file.getFileDocument(); int lineToNavigate = -1; for (PsiDocTag tag : comment.getTags()) { PsiElement nameElement = tag.getNameElement(); diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocNavigationDelegate.java b/java/java-impl/src/com/intellij/javadoc/JavadocNavigationDelegate.java index 287f5ee2c2b9..80a084f7099c 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocNavigationDelegate.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocNavigationDelegate.java @@ -79,7 +79,7 @@ public final class JavadocNavigationDelegate extends EditorNavigationDelegateAda } public static Result navigateToLineEnd(@NotNull Editor editor, @NotNull PsiFile psiFile) { - final Document document = editor.getDocument(); + final Document document = psiFile.getFileDocument(); final CaretModel caretModel = editor.getCaretModel(); final int offset = caretModel.getOffset();