From 223882d2926bcd64bd9c5b03df2042ddaed083a0 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 2 Feb 2015 15:19:50 +0100 Subject: [PATCH] correctly parse tag in the beginning of doc comment --- .../org/jetbrains/kotlin/kdoc/lexer/KDoc.flex | 2 +- .../kotlin/kdoc/lexer/_KDocLexer.java | 38 ++++++------------- compiler/testData/psi/kdoc/ParamTagAtStart.kt | 1 + .../testData/psi/kdoc/ParamTagAtStart.txt | 14 +++++++ .../parsing/JetParsingTestGenerated.java | 6 +++ 5 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 compiler/testData/psi/kdoc/ParamTagAtStart.kt create mode 100644 compiler/testData/psi/kdoc/ParamTagAtStart.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex index bafec022e15..a7e0e5fedda 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex +++ b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex @@ -59,7 +59,7 @@ CODE_LINK=\[{CODE_LINK_START}{CODE_LINK_CHAR}*\] %% - "/**" { yybegin(CONTENTS); + "/**" { yybegin(CONTENTS_BEGINNING); return KDocTokens.START; } "*"+ "/" { if (isLastToken()) return KDocTokens.END; else return KDocTokens.TEXT; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/_KDocLexer.java b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/_KDocLexer.java index e1e48faa690..4c9eaba2c23 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/_KDocLexer.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/_KDocLexer.java @@ -1,20 +1,4 @@ -/* - * 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. - */ - -/* The following code was generated by JFlex 1.4.3 on 1/19/15 8:28 PM */ +/* The following code was generated by JFlex 1.4.3 on 2/2/15 2:35 PM */ package org.jetbrains.kotlin.kdoc.lexer; @@ -28,7 +12,7 @@ import java.lang.Character; /** * This class is a scanner generated by * JFlex 1.4.3 - * on 1/19/15 8:28 PM from the specification file + * on 2/2/15 2:35 PM from the specification file * /Users/yole/jetbrains/kotlin/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex */ class _KDocLexer implements FlexLexer { @@ -582,37 +566,37 @@ class _KDocLexer implements FlexLexer { } } case 13: break; + case 11: + { yybegin(CONTENTS_BEGINNING); + return KDocTokens.START; + } + case 14: break; case 7: { yybegin(CONTENTS); return KDocTokens.TEXT_OR_LINK; } - case 14: break; + case 15: break; case 8: { if (isLastToken()) return KDocTokens.END; else return KDocTokens.TEXT; } - case 15: break; + case 16: break; case 5: { yybegin(CONTENTS); return KDocTokens.TEXT; } - case 16: break; + case 17: break; case 6: { if (yytextContainLineBreaks()) { yybegin(LINE_BEGINNING); } return TokenType.WHITE_SPACE; } - case 17: break; + case 18: break; case 12: { yybegin(CONTENTS); return KDocTokens.MARKDOWN_LINK; } - case 18: break; - case 11: - { yybegin(CONTENTS); - return KDocTokens.START; - } case 19: break; case 10: { yybegin(TAG_BEGINNING); diff --git a/compiler/testData/psi/kdoc/ParamTagAtStart.kt b/compiler/testData/psi/kdoc/ParamTagAtStart.kt new file mode 100644 index 00000000000..f0fcdb8945c --- /dev/null +++ b/compiler/testData/psi/kdoc/ParamTagAtStart.kt @@ -0,0 +1 @@ +/** @param a this is a */ diff --git a/compiler/testData/psi/kdoc/ParamTagAtStart.txt b/compiler/testData/psi/kdoc/ParamTagAtStart.txt new file mode 100644 index 00000000000..54d53bf16a7 --- /dev/null +++ b/compiler/testData/psi/kdoc/ParamTagAtStart.txt @@ -0,0 +1,14 @@ +JetFile: ParamTagAtStart.kt + PACKAGE_DIRECTIVE + + KDoc + PsiElement(KDOC_START)('/**') + KDOC_SECTION + PsiElement(KDOC_TEXT)(' ') + KDOC_TAG + PsiElement(KDOC_TAG_NAME)('@param') + PsiWhiteSpace(' ') + KDOC_LINK + PsiElement(KDOC_TEXT_OR_LINK)('a') + PsiElement(KDOC_TEXT)(' this is a ') + 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 2e8dd95174e..81223dfb149 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -1091,6 +1091,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("ParamTagAtStart.kt") + public void testParamTagAtStart() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/kdoc/ParamTagAtStart.kt"); + doParsingTest(fileName); + } + @TestMetadata("ReturnWithBrackets.kt") public void testReturnWithBrackets() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/kdoc/ReturnWithBrackets.kt");