diff --git a/java/java-impl/src/com/intellij/lexer/JavaLexer.java b/java/java-impl/src/com/intellij/lexer/JavaLexer.java index 21a8a1a00552..4a6ee9fcb0f7 100644 --- a/java/java-impl/src/com/intellij/lexer/JavaLexer.java +++ b/java/java-impl/src/com/intellij/lexer/JavaLexer.java @@ -250,13 +250,14 @@ public class JavaLexer extends LexerBase { myTokenEndOffset = getLineTerminator(myBufferIndex + 2); } else if (nextChar == '*') { - if (myBufferIndex + 2 >= myBufferEndOffset || myBuffer.charAt(myBufferIndex + 2) != '*') { + if (myBufferIndex + 2 >= myBufferEndOffset || myBuffer.charAt(myBufferIndex + 2) != '*' || + (myBufferIndex + 3 < myBufferEndOffset && myBuffer.charAt(myBufferIndex + 3) == '/')) { myTokenType = JavaTokenType.C_STYLE_COMMENT; myTokenEndOffset = getClosingComment(myBufferIndex + 2); } else { myTokenType = JavaDocElementType.DOC_COMMENT; - myTokenEndOffset = getDocClosingComment(myBufferIndex + 3); + myTokenEndOffset = getClosingComment(myBufferIndex + 3); } } else if (c > 127 && Character.isJavaIdentifierStart(c)) { @@ -271,7 +272,7 @@ public class JavaLexer extends LexerBase { case '"': case '\'': myTokenType = c == '"' ? JavaTokenType.STRING_LITERAL : JavaTokenType.CHARACTER_LITERAL; - myTokenEndOffset = getClosingParenthesys(myBufferIndex + 1, c); + myTokenEndOffset = getClosingParenthesis(myBufferIndex + 1, c); } if (myTokenEndOffset > myBufferEndOffset) { @@ -305,8 +306,7 @@ public class JavaLexer extends LexerBase { } } - - private int getClosingParenthesys(int offset, char c) { + private int getClosingParenthesis(int offset, char c) { int pos = offset; final int lBufferEnd = myBufferEndOffset; if (pos >= lBufferEnd) return lBufferEnd; @@ -342,26 +342,6 @@ public class JavaLexer extends LexerBase { return pos + 1; } - private int getDocClosingComment(int offset) { - final int lBufferEnd = myBufferEndOffset; - final CharSequence lBuffer = myBuffer; - - if (offset < lBufferEnd && lBuffer.charAt(offset) == '/') { - return offset + 1; - } - - int pos = offset; - while (pos < lBufferEnd - 1) { - final char c = lBuffer.charAt(pos); - - if (c == '*' && lBuffer.charAt(pos + 1) == '/') { - break; - } - pos++; - } - return pos + 2; - } - private int getClosingComment(int offset) { int pos = offset; diff --git a/java/java-tests/testData/psi/parser-full/commonParsing/ImportListBug.txt b/java/java-tests/testData/psi/parser-full/commonParsing/ImportListBug.txt index 27e45ed74f16..e18e9a3c98e3 100644 --- a/java/java-tests/testData/psi/parser-full/commonParsing/ImportListBug.txt +++ b/java/java-tests/testData/psi/parser-full/commonParsing/ImportListBug.txt @@ -1,6 +1,5 @@ PsiJavaFile:ImportListBug.java - PsiDocComment - PsiDocToken:DOC_COMMENT_END('/**/') + PsiComment(C_STYLE_COMMENT)('/**/') PsiImportList PsiClass:AClass diff --git a/java/java-tests/testData/psi/parser-full/javadocParsing/Javadoc1.java b/java/java-tests/testData/psi/parser-full/javadocParsing/Javadoc1.java new file mode 100644 index 000000000000..7068cde4d17e --- /dev/null +++ b/java/java-tests/testData/psi/parser-full/javadocParsing/Javadoc1.java @@ -0,0 +1 @@ +/**/ \ No newline at end of file diff --git a/java/java-tests/testData/psi/parser-full/javadocParsing/Javadoc1.txt b/java/java-tests/testData/psi/parser-full/javadocParsing/Javadoc1.txt new file mode 100644 index 000000000000..3c6b0391cff5 --- /dev/null +++ b/java/java-tests/testData/psi/parser-full/javadocParsing/Javadoc1.txt @@ -0,0 +1,4 @@ +PsiJavaFile:Javadoc1.java + PsiComment(C_STYLE_COMMENT)('/**/') + PsiImportList + \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/JavadocParsingTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/JavadocParsingTest.java index 3fdf409f95ca..8ce2a4835d66 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/JavadocParsingTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/JavadocParsingTest.java @@ -20,63 +20,65 @@ public class JavadocParsingTest extends JavaParsingTestCase { super("parser-full/javadocParsing"); } - public void testJavadoc0() throws Exception { doTest(true); } - public void testTag0() throws Exception { doTest(true); } - public void testTag1() throws Exception { doTest(true); } - public void testTag2() throws Exception { doTest(true); } - public void testTag3() throws Exception { doTest(true); } - public void testTag4() throws Exception { doTest(true); } - public void testTag5() throws Exception { doTest(true); } - public void testInlineTag0() throws Exception { doTest(true); } - public void testInlineTag1() throws Exception { doTest(true); } - public void testInlineTag2() throws Exception { doTest(true); } - public void testInlineTag3() throws Exception { doTest(true); } + public void testJavadoc0() { doTest(true); } + public void testJavadoc1() { doTest(true); } - public void testSeeTag0() throws Exception { doTest(true); } - public void testSeeTag1() throws Exception { doTest(true); } - public void testSeeTag2() throws Exception { doTest(true); } - public void testSeeTag3() throws Exception { doTest(true); } - public void testSeeTag4() throws Exception { doTest(true); } - public void testSeeTag5() throws Exception { doTest(true); } - public void testSeeTag6() throws Exception { doTest(true); } - public void testSeeTag7() throws Exception { doTest(true); } - public void testSeeTag8() throws Exception { doTest(true); } - public void testSeeTag9() throws Exception { doTest(true); } - public void testSeeTag10() throws Exception { doTest(true); } - public void testSeeTag11() throws Exception { doTest(true); } - public void testSeeTag12() throws Exception { doTest(true); } - public void testSeeTag13() throws Exception { doTest(true); } - public void testSeeTag14() throws Exception { doTest(true); } - public void testSeeTag15() throws Exception { doTest(true); } - public void testSeeTag16() throws Exception { doTest(true); } + public void testTag0() { doTest(true); } + public void testTag1() { doTest(true); } + public void testTag2() { doTest(true); } + public void testTag3() { doTest(true); } + public void testTag4() { doTest(true); } + public void testTag5() { doTest(true); } + public void testInlineTag0() { doTest(true); } + public void testInlineTag1() { doTest(true); } + public void testInlineTag2() { doTest(true); } + public void testInlineTag3() { doTest(true); } - public void testLinkTag0() throws Exception { doTest(true); } - public void testLinkTag1() throws Exception { doTest(true); } - public void testLinkTag2() throws Exception { doTest(true); } - public void testLinkTag3() throws Exception { doTest(true); } - public void testLinkTag4() throws Exception { doTest(true); } - public void testLinkTag5() throws Exception { doTest(true); } - public void testLinkTag6() throws Exception { doTest(true); } + public void testSeeTag0() { doTest(true); } + public void testSeeTag1() { doTest(true); } + public void testSeeTag2() { doTest(true); } + public void testSeeTag3() { doTest(true); } + public void testSeeTag4() { doTest(true); } + public void testSeeTag5() { doTest(true); } + public void testSeeTag6() { doTest(true); } + public void testSeeTag7() { doTest(true); } + public void testSeeTag8() { doTest(true); } + public void testSeeTag9() { doTest(true); } + public void testSeeTag10() { doTest(true); } + public void testSeeTag11() { doTest(true); } + public void testSeeTag12() { doTest(true); } + public void testSeeTag13() { doTest(true); } + public void testSeeTag14() { doTest(true); } + public void testSeeTag15() { doTest(true); } + public void testSeeTag16() { doTest(true); } - public void testParamTag1() throws Exception { doTest(true); } + public void testLinkTag0() { doTest(true); } + public void testLinkTag1() { doTest(true); } + public void testLinkTag2() { doTest(true); } + public void testLinkTag3() { doTest(true); } + public void testLinkTag4() { doTest(true); } + public void testLinkTag5() { doTest(true); } + public void testLinkTag6() { doTest(true); } - public void testLinkPlainTag0() throws Exception { doTest(true); } - public void testLinkPlainTag1() throws Exception { doTest(true); } - public void testLinkPlainTag2() throws Exception { doTest(true); } + public void testParamTag1() { doTest(true); } - public void testException0() throws Exception { doTest(true); } + public void testLinkPlainTag0() { doTest(true); } + public void testLinkPlainTag1() { doTest(true); } + public void testLinkPlainTag2() { doTest(true); } - public void testSymbols01() throws Exception { doTest(true); } - public void testSymbols02() throws Exception { doTest(true); } - public void testSymbols03() throws Exception { doTest(true); } - public void testSymbols04() throws Exception { doTest(true); } - public void testSymbols05() throws Exception { doTest(true); } + public void testException0() { doTest(true); } - public void testAdjacent01() throws Exception { doTest(true); } - public void testSeparated01() throws Exception { doTest(true); } + public void testSymbols01() { doTest(true); } + public void testSymbols02() { doTest(true); } + public void testSymbols03() { doTest(true); } + public void testSymbols04() { doTest(true); } + public void testSymbols05() { doTest(true); } - public void testTypeParam() throws Exception { doTest(true); } - public void testParameterlessTag() throws Exception { doTest(true); } + public void testAdjacent01() { doTest(true); } + public void testSeparated01() { doTest(true); } + + public void testTypeParam() { doTest(true); } + public void testParameterlessTag() { doTest(true); } - public void testIDEADEV_41403() throws Exception {doTest(true);} + public void testIDEADEV_41403() {doTest(true);} }