diff --git a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocElementTypes.java b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocElementTypes.java index bf3ebd95014..6ff530e4cf4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocElementTypes.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocElementTypes.java @@ -17,9 +17,11 @@ package org.jetbrains.kotlin.kdoc.parser; import org.jetbrains.kotlin.kdoc.psi.impl.KDocLink; +import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection; import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag; public class KDocElementTypes { + public static final KDocElementType KDOC_SECTION = new KDocElementType("KDOC_SECTION", KDocSection.class); public static final KDocElementType KDOC_TAG = new KDocElementType("KDOC_TAG", KDocTag.class); public static final KDocElementType KDOC_LINK = new KDocElementType("KDOC_LINK", KDocLink.class); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocKnownTag.java b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocKnownTag.java index 9a2acf563e9..f7bb5a6b4d0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocKnownTag.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocKnownTag.java @@ -17,24 +17,32 @@ package org.jetbrains.kotlin.kdoc.parser; public enum KDocKnownTag { - AUTHOR(false), - THROWS(true), - EXCEPTION(true), - PARAM(true), - RETURN(false), - SEE(false), - SINCE(false); + AUTHOR(false, false), + THROWS(true, false), + EXCEPTION(true, false), + PARAM(true, false), + RETURN(false, false), + SEE(false, false), + SINCE(false, false), + CONSTRUCTOR(false, true), + PROPERTY(true, true); private final boolean takesReference; + private final boolean startsSection; - KDocKnownTag(boolean takesReference) { + KDocKnownTag(boolean takesReference, boolean startsSection) { this.takesReference = takesReference; + this.startsSection = startsSection; } public boolean isReferenceRequired() { return takesReference; } + public boolean isSectionStart() { + return startsSection; + } + public static KDocKnownTag findByTagName(String tagName) { if (tagName.startsWith("@")) { try { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocParser.java b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocParser.java index f8fcaa5a5b3..288346f243b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocParser.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/parser/KDocParser.java @@ -28,30 +28,48 @@ public class KDocParser implements PsiParser { @NotNull public ASTNode parse(IElementType root, PsiBuilder builder) { PsiBuilder.Marker rootMarker = builder.mark(); + if (builder.getTokenType() == KDocTokens.START) { + builder.advanceLexer(); + } + PsiBuilder.Marker currentSectionMarker = builder.mark(); // todo: parse KDoc tags, markdown, etc... while (!builder.eof()) { if (builder.getTokenType() == KDocTokens.TAG_NAME) { - parseTag(builder); + currentSectionMarker = parseTag(builder, currentSectionMarker); } else if (builder.getTokenType() == KDocTokens.MARKDOWN_LINK) { PsiBuilder.Marker linkStart = builder.mark(); builder.advanceLexer(); linkStart.done(KDocElementTypes.KDOC_LINK); } + else if (builder.getTokenType() == KDocTokens.END) { + if (currentSectionMarker != null) { + currentSectionMarker.done(KDocElementTypes.KDOC_SECTION); + currentSectionMarker = null; + } + builder.advanceLexer(); + } else { builder.advanceLexer(); } } + if (currentSectionMarker != null) { + currentSectionMarker.done(KDocElementTypes.KDOC_SECTION); + } rootMarker.done(root); return builder.getTreeBuilt(); } - private static void parseTag(PsiBuilder builder) { - PsiBuilder.Marker tagStart = builder.mark(); + private static PsiBuilder.Marker parseTag(PsiBuilder builder, PsiBuilder.Marker currentSectionMarker) { String tagName = builder.getTokenText(); KDocKnownTag knownTag = KDocKnownTag.findByTagName(tagName); + if (knownTag != null && knownTag.isSectionStart()) { + currentSectionMarker.done(KDocElementTypes.KDOC_SECTION); + currentSectionMarker = builder.mark(); + } + PsiBuilder.Marker tagStart = builder.mark(); builder.advanceLexer(); if (knownTag != null && knownTag.isReferenceRequired() && builder.getTokenType() == KDocTokens.TEXT_OR_LINK) { @@ -71,6 +89,7 @@ public class KDocParser implements PsiParser { } } tagStart.done(KDocElementTypes.KDOC_TAG); + return currentSectionMarker; } private static boolean isAtEndOfTag(PsiBuilder builder) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocSection.java b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocSection.java new file mode 100644 index 00000000000..23d1e53fcc8 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocSection.java @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.kdoc.psi.impl; + +import com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; + +/** + * The part of a doc comment which describes a single class, method or property + * produced by the element being documented. For example, the doc comment of a class + * can have sections for the class itself, its primary constructor and each of the + * properties defined in the primary constructor. + */ +public class KDocSection extends KDocElementImpl { + public KDocSection(@NotNull ASTNode node) { + super(node); + } +} diff --git a/compiler/testData/psi/CommentsBinding.txt b/compiler/testData/psi/CommentsBinding.txt index 33abacdbe8e..1cf194fbc68 100644 --- a/compiler/testData/psi/CommentsBinding.txt +++ b/compiler/testData/psi/CommentsBinding.txt @@ -64,8 +64,9 @@ JetFile: CommentsBinding.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment for A') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment for A') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n') @@ -128,7 +129,8 @@ JetFile: CommentsBinding.kt PROPERTY KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' v2 doc comment ') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' v2 doc comment ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n ') PsiElement(val)('val') @@ -356,7 +358,8 @@ JetFile: CommentsBinding.kt ENUM_ENTRY KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' This is B ') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' This is B ') PsiElement(KDOC_END)('*/') PsiWhiteSpace(' ') OBJECT_DECLARATION_NAME @@ -371,7 +374,8 @@ JetFile: CommentsBinding.kt ENUM_ENTRY KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' This is X ') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' This is X ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n ') OBJECT_DECLARATION_NAME diff --git a/compiler/testData/psi/DocCommentAfterFileAnnotations.txt b/compiler/testData/psi/DocCommentAfterFileAnnotations.txt index b5cc56c9605..55293c01796 100644 --- a/compiler/testData/psi/DocCommentAfterFileAnnotations.txt +++ b/compiler/testData/psi/DocCommentAfterFileAnnotations.txt @@ -18,8 +18,9 @@ JetFile: DocCommentAfterFileAnnotations.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n') diff --git a/compiler/testData/psi/DocCommentForFirstDeclaration.txt b/compiler/testData/psi/DocCommentForFirstDeclaration.txt index 58db3ebfed5..847f6418ea0 100644 --- a/compiler/testData/psi/DocCommentForFirstDeclaration.txt +++ b/compiler/testData/psi/DocCommentForFirstDeclaration.txt @@ -5,8 +5,9 @@ JetFile: DocCommentForFirstDeclaration.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n') diff --git a/compiler/testData/psi/DocCommentOnPackageDirectiveLine.txt b/compiler/testData/psi/DocCommentOnPackageDirectiveLine.txt index a21d9b42285..c82fa97d5f3 100644 --- a/compiler/testData/psi/DocCommentOnPackageDirectiveLine.txt +++ b/compiler/testData/psi/DocCommentOnPackageDirectiveLine.txt @@ -12,7 +12,8 @@ JetFile: DocCommentOnPackageDirectiveLine.kt FUN KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' some ') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' some ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n') PsiElement(fun)('fun') diff --git a/compiler/testData/psi/DocCommentsBinding.txt b/compiler/testData/psi/DocCommentsBinding.txt index ae98d9eb4a9..12f113f54b4 100644 --- a/compiler/testData/psi/DocCommentsBinding.txt +++ b/compiler/testData/psi/DocCommentsBinding.txt @@ -5,8 +5,9 @@ JetFile: DocCommentsBinding.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment for A') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment for A') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n') @@ -22,8 +23,9 @@ JetFile: DocCommentsBinding.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment for val-parameter') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment for val-parameter') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n ') @@ -47,8 +49,9 @@ JetFile: DocCommentsBinding.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment for function') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment for function') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n ') @@ -66,8 +69,9 @@ JetFile: DocCommentsBinding.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment for local function') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment for local function') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n ') @@ -87,8 +91,9 @@ JetFile: DocCommentsBinding.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment for local class') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment for local class') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n ') @@ -102,8 +107,9 @@ JetFile: DocCommentsBinding.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment for property') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment for property') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n ') @@ -120,7 +126,8 @@ JetFile: DocCommentsBinding.kt PROPERTY_ACCESSOR KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' Doc comment for getter ') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' Doc comment for getter ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n ') PsiElement(get)('get') @@ -135,7 +142,8 @@ JetFile: DocCommentsBinding.kt PROPERTY_ACCESSOR KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' Doc comment for setter ') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' Doc comment for setter ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n ') PsiElement(set)('set') @@ -155,8 +163,9 @@ JetFile: DocCommentsBinding.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Doc comment for B') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Doc comment for B') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n') diff --git a/compiler/testData/psi/EOLsInComments.txt b/compiler/testData/psi/EOLsInComments.txt index 8ae92f0ef03..4a71517c269 100644 --- a/compiler/testData/psi/EOLsInComments.txt +++ b/compiler/testData/psi/EOLsInComments.txt @@ -27,7 +27,8 @@ JetFile: EOLsInComments.kt PsiWhiteSpace('\n ') KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' ') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' ') PsiElement(KDOC_END)('*/') PREFIX_EXPRESSION OPERATION_REFERENCE @@ -78,6 +79,8 @@ JetFile: EOLsInComments.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') + KDOC_SECTION + PsiElement(KDOC_END)('*/') PsiWhiteSpace(' ') OPERATION_REFERENCE diff --git a/compiler/testData/psi/NestedComments.txt b/compiler/testData/psi/NestedComments.txt index 95052f017b2..7bc702a1edb 100644 --- a/compiler/testData/psi/NestedComments.txt +++ b/compiler/testData/psi/NestedComments.txt @@ -34,6 +34,8 @@ JetFile: NestedComments.kt PsiWhiteSpace('\n') KDoc PsiElement(KDOC_START)('/**') + KDOC_SECTION + PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n') REFERENCE_EXPRESSION @@ -41,7 +43,8 @@ JetFile: NestedComments.kt PsiWhiteSpace('\n') KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' /***/') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' /***/') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n') REFERENCE_EXPRESSION @@ -49,9 +52,10 @@ JetFile: NestedComments.kt PsiWhiteSpace('\n') KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' /**') - PsiWhiteSpace('\n\n') - PsiElement(KDOC_TEXT)('*/') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' /**') + PsiWhiteSpace('\n\n') + PsiElement(KDOC_TEXT)('*/') PsiElement(KDOC_END)('***/') PsiWhiteSpace('\n') REFERENCE_EXPRESSION diff --git a/compiler/testData/psi/examples/array/MutableArray.txt b/compiler/testData/psi/examples/array/MutableArray.txt index 928e7874a03..086fdc1bbbf 100644 --- a/compiler/testData/psi/examples/array/MutableArray.txt +++ b/compiler/testData/psi/examples/array/MutableArray.txt @@ -5,7 +5,8 @@ JetFile: MutableArray.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_TEXT)('These declarations are "shallow" in the sense that they are not really compiled, only the type-checker uses them') + KDOC_SECTION + PsiElement(KDOC_TEXT)('These declarations are "shallow" in the sense that they are not really compiled, only the type-checker uses them') PsiWhiteSpace('\n') PsiElement(KDOC_END)('*/') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/kdoc/AtTags.txt b/compiler/testData/psi/kdoc/AtTags.txt index 88fb41a42d6..ec8e2af4423 100644 --- a/compiler/testData/psi/kdoc/AtTags.txt +++ b/compiler/testData/psi/kdoc/AtTags.txt @@ -4,15 +4,16 @@ JetFile: AtTags.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' ') - KDOC_TAG - PsiElement(KDOC_TAG_NAME)('@tag') - PsiWhiteSpace('\n ') + KDOC_SECTION PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' text @notATag') - PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' @') + PsiElement(KDOC_TEXT)(' ') + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@tag') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' text @notATag') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' @') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile1.txt b/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile1.txt index cf6ca9c30f0..80f2a9b0e73 100644 --- a/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile1.txt +++ b/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile1.txt @@ -2,4 +2,6 @@ JetFile: DocCommentAtBeginningOfFile1.kt PACKAGE_DIRECTIVE KDoc - PsiElement(KDOC_START)('/**') \ No newline at end of file + PsiElement(KDOC_START)('/**') + KDOC_SECTION + \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile2.txt b/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile2.txt index c497cb3aa3b..3bf014c4e16 100644 --- a/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile2.txt +++ b/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile2.txt @@ -4,4 +4,5 @@ JetFile: DocCommentAtBeginningOfFile2.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n') - PsiElement(KDOC_TEXT)('/**') \ No newline at end of file + KDOC_SECTION + PsiElement(KDOC_TEXT)('/**') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile3.txt b/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile3.txt index a0b7c9e63db..048dd536e33 100644 --- a/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile3.txt +++ b/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile3.txt @@ -4,4 +4,5 @@ JetFile: DocCommentAtBeginningOfFile3.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n\n') - PsiElement(KDOC_TEXT)('fooo') \ No newline at end of file + KDOC_SECTION + PsiElement(KDOC_TEXT)('fooo') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile4.txt b/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile4.txt index d882da21f3a..78297346043 100644 --- a/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile4.txt +++ b/compiler/testData/psi/kdoc/DocCommentAtBeginningOfFile4.txt @@ -4,6 +4,7 @@ JetFile: DocCommentAtBeginningOfFile4.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n\n') - PsiElement(KDOC_TEXT)('/**foo*/') - PsiWhiteSpace('\n\n') - PsiElement(KDOC_TEXT)('asdfas') \ No newline at end of file + KDOC_SECTION + PsiElement(KDOC_TEXT)('/**foo*/') + PsiWhiteSpace('\n\n') + PsiElement(KDOC_TEXT)('asdfas') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/EndOnLeadingAsterisks.txt b/compiler/testData/psi/kdoc/EndOnLeadingAsterisks.txt index ac62c23340c..f46b84cfa81 100644 --- a/compiler/testData/psi/kdoc/EndOnLeadingAsterisks.txt +++ b/compiler/testData/psi/kdoc/EndOnLeadingAsterisks.txt @@ -4,4 +4,6 @@ JetFile: EndOnLeadingAsterisks.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') + KDOC_SECTION + PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/EndRightAfterText.txt b/compiler/testData/psi/kdoc/EndRightAfterText.txt index 15dca239106..a3b94b5dfb6 100644 --- a/compiler/testData/psi/kdoc/EndRightAfterText.txt +++ b/compiler/testData/psi/kdoc/EndRightAfterText.txt @@ -3,5 +3,6 @@ JetFile: EndRightAfterText.kt KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)('text') + KDOC_SECTION + PsiElement(KDOC_TEXT)('text') PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/Incomplete.txt b/compiler/testData/psi/kdoc/Incomplete.txt index b16a862297e..78dfb42b89b 100644 --- a/compiler/testData/psi/kdoc/Incomplete.txt +++ b/compiler/testData/psi/kdoc/Incomplete.txt @@ -4,4 +4,5 @@ JetFile: Incomplete.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_TEXT)('contents') \ No newline at end of file + KDOC_SECTION + PsiElement(KDOC_TEXT)('contents') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/Markdown.txt b/compiler/testData/psi/kdoc/Markdown.txt index b71356bf1eb..3dc99a1e0f3 100644 --- a/compiler/testData/psi/kdoc/Markdown.txt +++ b/compiler/testData/psi/kdoc/Markdown.txt @@ -4,26 +4,27 @@ JetFile: Markdown.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' ') - KDOC_LINK - PsiElement(KDOC_MARKDOWN_LINK)('[WikiLink]') - PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' ') - PsiElement(KDOC_MARKDOWN_ESCAPED_CHAR)('\[') - PsiElement(KDOC_TEXT)('NotALink]') - PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' [') - KDOC_LINK - PsiElement(KDOC_MARKDOWN_LINK)('[DoubleQuotedLink]') - PsiElement(KDOC_TEXT)(']') - PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' Just ') - PsiElement(KDOC_MARKDOWN_ESCAPED_CHAR)('\[') - PsiElement(KDOC_TEXT)(' and ') - PsiElement(KDOC_MARKDOWN_ESCAPED_CHAR)('\]') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + KDOC_LINK + PsiElement(KDOC_MARKDOWN_LINK)('[WikiLink]') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + PsiElement(KDOC_MARKDOWN_ESCAPED_CHAR)('\[') + PsiElement(KDOC_TEXT)('NotALink]') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' [') + KDOC_LINK + PsiElement(KDOC_MARKDOWN_LINK)('[DoubleQuotedLink]') + PsiElement(KDOC_TEXT)(']') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' Just ') + PsiElement(KDOC_MARKDOWN_ESCAPED_CHAR)('\[') + PsiElement(KDOC_TEXT)(' and ') + PsiElement(KDOC_MARKDOWN_ESCAPED_CHAR)('\]') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/ParamTag.txt b/compiler/testData/psi/kdoc/ParamTag.txt index 7460ebd83b3..9c59b997775 100644 --- a/compiler/testData/psi/kdoc/ParamTag.txt +++ b/compiler/testData/psi/kdoc/ParamTag.txt @@ -4,13 +4,14 @@ JetFile: ParamTag.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' ') - KDOC_TAG - PsiElement(KDOC_TAG_NAME)('@param') - PsiWhiteSpace(' ') - KDOC_LINK - PsiElement(KDOC_TEXT_OR_LINK)('a') - PsiElement(KDOC_TEXT)(' The description of a.') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@param') + PsiWhiteSpace(' ') + KDOC_LINK + PsiElement(KDOC_TEXT_OR_LINK)('a') + PsiElement(KDOC_TEXT)(' The description of a.') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/ReturnWithBrackets.txt b/compiler/testData/psi/kdoc/ReturnWithBrackets.txt index bf36f34fce1..554d1a069e9 100644 --- a/compiler/testData/psi/kdoc/ReturnWithBrackets.txt +++ b/compiler/testData/psi/kdoc/ReturnWithBrackets.txt @@ -4,20 +4,21 @@ JetFile: ReturnWithBrackets.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' ') - KDOC_TAG - PsiElement(KDOC_TAG_NAME)('@return') - PsiWhiteSpace(' ') - PsiElement(KDOC_TEXT_OR_LINK)('This') - PsiElement(KDOC_TEXT)(' is not a reference') - PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' ') - KDOC_TAG - PsiElement(KDOC_TAG_NAME)('@return') - KDOC_LINK - PsiElement(KDOC_MARKDOWN_LINK)('[x]') - PsiElement(KDOC_TEXT)(' This is a reference') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@return') + PsiWhiteSpace(' ') + PsiElement(KDOC_TEXT_OR_LINK)('This') + PsiElement(KDOC_TEXT)(' is not a reference') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@return') + KDOC_LINK + PsiElement(KDOC_MARKDOWN_LINK)('[x]') + PsiElement(KDOC_TEXT)(' This is a reference') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/Sections.kt b/compiler/testData/psi/kdoc/Sections.kt new file mode 100644 index 00000000000..3f2652136f2 --- /dev/null +++ b/compiler/testData/psi/kdoc/Sections.kt @@ -0,0 +1,6 @@ +/** + * This is the doc comment for a class. + * @param T a type parameter. + * @constructor This is the doc comment for the primary constructor. + * @param a a constructor parameter. + */ \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/Sections.txt b/compiler/testData/psi/kdoc/Sections.txt new file mode 100644 index 00000000000..30080e32e6c --- /dev/null +++ b/compiler/testData/psi/kdoc/Sections.txt @@ -0,0 +1,38 @@ +JetFile: Sections.kt + PACKAGE_DIRECTIVE + + KDoc + PsiElement(KDOC_START)('/**') + PsiWhiteSpace('\n ') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' This is the doc comment for a class.') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@param') + PsiWhiteSpace(' ') + KDOC_LINK + PsiElement(KDOC_TEXT_OR_LINK)('T') + PsiElement(KDOC_TEXT)(' a type parameter.') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + KDOC_SECTION + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@constructor') + PsiWhiteSpace(' ') + PsiElement(KDOC_TEXT_OR_LINK)('This') + PsiElement(KDOC_TEXT)(' is the doc comment for the primary constructor.') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@param') + PsiWhiteSpace(' ') + KDOC_LINK + PsiElement(KDOC_TEXT_OR_LINK)('a') + PsiElement(KDOC_TEXT)(' a constructor parameter.') + PsiWhiteSpace('\n ') + PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/Simple.txt b/compiler/testData/psi/kdoc/Simple.txt index 1661f7c3fb5..a7be8769ebe 100644 --- a/compiler/testData/psi/kdoc/Simple.txt +++ b/compiler/testData/psi/kdoc/Simple.txt @@ -3,21 +3,22 @@ JetFile: Simple.kt KDoc PsiElement(KDOC_START)('/**') - PsiElement(KDOC_TEXT)(' line 0') - PsiWhiteSpace('\n ') - PsiElement(KDOC_TEXT)('line 1 //') - PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('**') - PsiElement(KDOC_TEXT)(' line 2 /*') - PsiWhiteSpace('\n ') - PsiElement(KDOC_TEXT)('line 3 /**') - PsiWhiteSpace('\n') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' line * 4') - PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('***') - PsiElement(KDOC_TEXT)(' line */ 5') - PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('**') - PsiElement(KDOC_TEXT)(' line 6 ') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' line 0') + PsiWhiteSpace('\n ') + PsiElement(KDOC_TEXT)('line 1 //') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('**') + PsiElement(KDOC_TEXT)(' line 2 /*') + PsiWhiteSpace('\n ') + PsiElement(KDOC_TEXT)('line 3 /**') + PsiWhiteSpace('\n') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' line * 4') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('***') + PsiElement(KDOC_TEXT)(' line */ 5') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('**') + PsiElement(KDOC_TEXT)(' line 6 ') PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/TextRightAfterLeadAsterisks.txt b/compiler/testData/psi/kdoc/TextRightAfterLeadAsterisks.txt index 1f8ac66cb20..96ff061f008 100644 --- a/compiler/testData/psi/kdoc/TextRightAfterLeadAsterisks.txt +++ b/compiler/testData/psi/kdoc/TextRightAfterLeadAsterisks.txt @@ -4,7 +4,8 @@ JetFile: TextRightAfterLeadAsterisks.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n') - PsiElement(KDOC_LEADING_ASTERISK)('**') - PsiElement(KDOC_TEXT)('test') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('**') + PsiElement(KDOC_TEXT)('test') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/testData/psi/kdoc/TwoTags.txt b/compiler/testData/psi/kdoc/TwoTags.txt index ae899544752..22a99dfe0b2 100644 --- a/compiler/testData/psi/kdoc/TwoTags.txt +++ b/compiler/testData/psi/kdoc/TwoTags.txt @@ -4,19 +4,20 @@ JetFile: TwoTags.kt KDoc PsiElement(KDOC_START)('/**') PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' ') - KDOC_TAG - PsiElement(KDOC_TAG_NAME)('@author') - PsiWhiteSpace(' ') - PsiElement(KDOC_TEXT_OR_LINK)('Dmitry') - PsiElement(KDOC_TEXT)(' Jemerov') - PsiWhiteSpace('\n ') - PsiElement(KDOC_LEADING_ASTERISK)('*') - PsiElement(KDOC_TEXT)(' ') - KDOC_TAG - PsiElement(KDOC_TAG_NAME)('@since') - PsiWhiteSpace(' ') - PsiElement(KDOC_TEXT_OR_LINK)('M12') + KDOC_SECTION + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@author') + PsiWhiteSpace(' ') + PsiElement(KDOC_TEXT_OR_LINK)('Dmitry') + PsiElement(KDOC_TEXT)(' Jemerov') + PsiWhiteSpace('\n ') + PsiElement(KDOC_LEADING_ASTERISK)('*') + PsiElement(KDOC_TEXT)(' ') + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@since') + PsiWhiteSpace(' ') + PsiElement(KDOC_TEXT_OR_LINK)('M12') PsiWhiteSpace('\n ') PsiElement(KDOC_END)('*/') \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java index d3e3babc9c4..2e8dd95174e 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -1097,6 +1097,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("Sections.kt") + public void testSections() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/kdoc/Sections.kt"); + doParsingTest(fileName); + } + @TestMetadata("Simple.kt") public void testSimple() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/kdoc/Simple.kt");