mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-379801 javadoc: Add an element type for markdown comments
GitOrigin-RevId: 00a38bd9de3aa2e0bcbd24de4593786dcb56d172
This commit is contained in:
committed by
intellij-monorepo-bot
parent
94d9da9cb7
commit
96fbb9ef55
@@ -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.impl.source.javadoc;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -39,6 +39,10 @@ public class PsiDocCommentImpl extends LazyParseablePsiElement implements PsiDoc
|
||||
super(JavaDocElementType.DOC_COMMENT, text);
|
||||
}
|
||||
|
||||
public PsiDocCommentImpl(CharSequence text, boolean markdownComment) {
|
||||
super(markdownComment ? DOC_MARKDOWN_COMMENT : DOC_COMMENT, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiJavaDocumentedElement getOwner() {
|
||||
return PsiImplUtil.findDocCommentOwner(this);
|
||||
@@ -64,7 +68,7 @@ public class PsiDocCommentImpl extends LazyParseablePsiElement implements PsiDoc
|
||||
|
||||
@Override
|
||||
public PsiDocTag findTagByName(String name) {
|
||||
if (getFirstChildNode().getElementType() == JavaDocElementType.DOC_COMMENT) {
|
||||
if (DOC_COMMENT_TOKENS.contains(getFirstChildNode().getElementType())) {
|
||||
if (!getFirstChildNode().getText().contains(name)) return null;
|
||||
}
|
||||
|
||||
@@ -336,7 +340,7 @@ public class PsiDocCommentImpl extends LazyParseablePsiElement implements PsiDoc
|
||||
if (i == DOC_TAG) {
|
||||
return ChildRole.DOC_TAG;
|
||||
}
|
||||
else if (i == JavaDocElementType.DOC_COMMENT || i == DOC_INLINE_TAG) {
|
||||
else if (DOC_COMMENT_TOKENS.contains(i) || i == DOC_INLINE_TAG) {
|
||||
return ChildRole.DOC_CONTENT;
|
||||
}
|
||||
else if (i == DOC_COMMENT_LEADING_ASTERISKS) {
|
||||
|
||||
@@ -67,8 +67,16 @@ public interface JavaDocElementType {
|
||||
return new PsiDocCommentImpl(text);
|
||||
}
|
||||
};
|
||||
ILazyParseableElementType DOC_MARKDOWN_COMMENT = new BasicJavaDocElementType.DocCommentElementType() {
|
||||
@Override
|
||||
public ASTNode createNode(final CharSequence text) {
|
||||
return new PsiDocCommentImpl(text, true);
|
||||
}
|
||||
};
|
||||
|
||||
TokenSet DOC_COMMENT_TOKENS = TokenSet.create(DOC_COMMENT, DOC_MARKDOWN_COMMENT);
|
||||
|
||||
@SuppressWarnings("unused") // used in plugins
|
||||
TokenSet ALL_JAVADOC_ELEMENTS = TokenSet.create(DOC_TAG, DOC_INLINE_TAG, DOC_METHOD_OR_FIELD_REF, DOC_PARAMETER_REF, DOC_TAG_VALUE_ELEMENT,
|
||||
DOC_REFERENCE_HOLDER, DOC_TYPE_HOLDER, DOC_COMMENT);
|
||||
DOC_REFERENCE_HOLDER, DOC_TYPE_HOLDER, DOC_COMMENT, DOC_MARKDOWN_COMMENT);
|
||||
}
|
||||
Reference in New Issue
Block a user