[java] JavaDocCommentFixer: reduce editor dependency

GitOrigin-RevId: b53db1529dbcbc7a15e6b8c09ab13344d5a56bfa
This commit is contained in:
Tagir Valeev
2025-05-09 14:45:21 +00:00
committed by intellij-monorepo-bot
parent 644a6b2e81
commit 76a9727974
2 changed files with 6 additions and 5 deletions
@@ -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();
@@ -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();