IDEA-379801 javadoc: Update usages of JavaDocSyntaxElementType.DOC_COMMENT

GitOrigin-RevId: 4636107a9248cb5c38cf70a93b03f511936b514b
This commit is contained in:
Louis Vignier
2025-11-11 11:29:01 +00:00
committed by intellij-monorepo-bot
parent 96fbb9ef55
commit 70a1f45a0d
28 changed files with 57 additions and 79 deletions
@@ -222,7 +222,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
if (elementType == JavaElementType.LABELED_STATEMENT) {
return new LabeledJavaBlock(child, wrap, alignment, actualIndent, settings, javaSettings, formattingMode);
}
if (elementType == JavaDocElementType.DOC_COMMENT) {
if (JavaDocElementType.DOC_COMMENT_TOKENS.contains(elementType)) {
return new DocCommentBlock(child, wrap, alignment, actualIndent, settings, javaSettings, formattingMode);
}
if (isTextBlock(childPsi)) {
@@ -381,6 +381,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
if (parentType == JavaElementType.SWITCH_STATEMENT) return Indent.getNoneIndent();
if (parentType == JavaElementType.METHOD) return Indent.getNoneIndent();
if (parentType == JavaDocElementType.DOC_COMMENT) return Indent.getNoneIndent();
if (parentType == JavaDocElementType.DOC_MARKDOWN_COMMENT) return Indent.getNoneIndent();
if (parentType == JavaDocElementType.DOC_TAG) return Indent.getNoneIndent();
if (parentType == JavaDocElementType.DOC_INLINE_TAG) return Indent.getNoneIndent();
if (parentType == JavaElementType.IMPORT_LIST) return Indent.getNoneIndent();
@@ -1272,7 +1273,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
if (myUseChildAttributes) {
return new ChildAttributes(myChildIndent, myChildAlignment);
}
if (isAfter(newChildIndex, new IElementType[]{JavaDocElementType.DOC_COMMENT})) {
if (isAfter(newChildIndex, new IElementType[]{JavaDocElementType.DOC_COMMENT, JavaDocElementType.DOC_MARKDOWN_COMMENT})) {
return new ChildAttributes(Indent.getNoneIndent(), myChildAlignment);
}
return super.getChildAttributes(newChildIndex);
@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.formatter.java;
import com.intellij.formatting.*;
@@ -218,14 +218,14 @@ public class BlockContainingJavaBlock extends AbstractJavaBlock{
if (FormatterUtil.containsWhiteSpacesOnly(child)) return isPartOfCodeBlock(child.getTreeNext());
if (child.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) return isPartOfCodeBlock(child.getTreeNext());
return child.getElementType() == JavaDocElementType.DOC_COMMENT;
return JavaDocElementType.DOC_COMMENT_TOKENS.contains(child.getElementType());
}
@Override
public @NotNull ChildAttributes getChildAttributes(final int newChildIndex) {
if (isAfter(newChildIndex, new IElementType[]{JavaDocElementType.DOC_COMMENT})) {
if (isAfter(newChildIndex, new IElementType[]{JavaDocElementType.DOC_COMMENT, JavaDocElementType.DOC_MARKDOWN_COMMENT})) {
return new ChildAttributes(Indent.getNoneIndent(), null);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.formatter.java;
import com.intellij.formatting.*;
@@ -275,7 +275,7 @@ public class CodeBlockBlock extends AbstractJavaBlock {
@Override
public @NotNull ChildAttributes getChildAttributes(final int newChildIndex) {
if (isAfter(newChildIndex, new IElementType[]{JavaDocElementType.DOC_COMMENT, JavaElementType.MODIFIER_LIST})) {
if (isAfter(newChildIndex, new IElementType[]{JavaDocElementType.DOC_COMMENT, JavaDocElementType.DOC_MARKDOWN_COMMENT, JavaElementType.MODIFIER_LIST})) {
return new ChildAttributes(Indent.getNoneIndent(), null);
}
else {
@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.formatter.java;
import com.intellij.openapi.editor.Document;
@@ -101,7 +101,7 @@ public final class JavaLineWrapPositionStrategy extends PsiAwareDefaultLineWrapP
private static boolean isInsidePreTag(@NotNull PsiElement element, @NotNull CharSequence chars, int offset) {
PsiElement parent = PsiTreeUtil.findFirstParent(
element, e -> e.getNode().getElementType() == JavaDocElementType.DOC_COMMENT);
element, e -> JavaDocElementType.DOC_COMMENT_TOKENS.contains(e.getNode().getElementType()));
if (parent != null) {
int preStart = CharArrayUtil.lastIndexOf(chars, PRE_TAG_START, offset);
if (preStart >= 0) {
@@ -151,7 +151,7 @@ public final class JavaSpacePropertyProcessor extends JavaElementVisitor {
return PsiTreeUtil.getParentOfType(parent, PsiDocMethodOrFieldRef.class) != null;
}
return type == JavaDocElementType.DOC_COMMENT || type == JavaDocElementType.DOC_TAG || type == JavaDocElementType.DOC_INLINE_TAG;
return JavaDocElementType.DOC_COMMENT_TOKENS.contains(type) || type == JavaDocElementType.DOC_TAG || type == JavaDocElementType.DOC_INLINE_TAG;
}
private void init(ASTNode child) {
@@ -214,7 +214,7 @@ public final class JavaSpacePropertyProcessor extends JavaElementVisitor {
@Override
public void visitClass(@NotNull PsiClass aClass) {
if (myType1 == JavaDocElementType.DOC_COMMENT) {
if (JavaDocElementType.DOC_COMMENT_TOKENS.contains(myType1)) {
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
return;
}
@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.formatter.java;
import com.intellij.formatting.*;
@@ -100,7 +100,7 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
private void processHeadCommentsAndWhiteSpaces(@NotNull List<? super Block> result) {
while (myCurrentChild != null) {
if (StdTokenSets.COMMENT_BIT_SET.contains(myCurrentChild.getElementType()) || myCurrentChild.getElementType() == JavaDocElementType.DOC_COMMENT) {
if (StdTokenSets.COMMENT_BIT_SET.contains(myCurrentChild.getElementType()) || JavaDocElementType.DOC_COMMENT_TOKENS.contains(myCurrentChild.getElementType())) {
Block commentBlock = createJavaBlock(
myCurrentChild,
mySettings, myJavaSettings,