mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] ignores bad characters in simple tags (IDEA-178636)
This commit is contained in:
@@ -145,14 +145,14 @@ public class JavadocParser {
|
||||
builder.advanceLexer();
|
||||
tagValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
|
||||
}
|
||||
else if (!isInline && tagName != null && tagName.equals(PARAM_TAG)) {
|
||||
parseSimpleTagValue(builder, true);
|
||||
else if (!isInline && PARAM_TAG.equals(tagName)) {
|
||||
parseParameterRef(builder);
|
||||
}
|
||||
else if (JavaParserUtil.getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_5) && VALUE_TAG.equals(tagName) && isInline) {
|
||||
parseSeeTagValue(builder, true);
|
||||
}
|
||||
else {
|
||||
parseSimpleTagValue(builder, false);
|
||||
parseSimpleTagValue(builder);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -232,12 +232,21 @@ public class JavadocParser {
|
||||
refStart.done(JavaDocElementType.DOC_METHOD_OR_FIELD_REF);
|
||||
}
|
||||
|
||||
private static void parseSimpleTagValue(PsiBuilder builder, boolean parameter) {
|
||||
private static void parseParameterRef(PsiBuilder builder) {
|
||||
PsiBuilder.Marker tagValue = builder.mark();
|
||||
while (TAG_VALUES_SET.contains(getTokenType(builder))) {
|
||||
while (TAG_VALUES_SET.contains(getTokenType(builder))) builder.advanceLexer();
|
||||
tagValue.done(JavaDocElementType.DOC_PARAMETER_REF);
|
||||
}
|
||||
|
||||
private static void parseSimpleTagValue(PsiBuilder builder) {
|
||||
PsiBuilder.Marker tagData = builder.mark();
|
||||
while (true) {
|
||||
IElementType tokenType = getTokenType(builder);
|
||||
if (tokenType == JavaDocTokenType.DOC_COMMENT_BAD_CHARACTER) builder.remapCurrentToken(JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
|
||||
else if (!TAG_VALUES_SET.contains(tokenType)) break;
|
||||
builder.advanceLexer();
|
||||
}
|
||||
tagValue.done(parameter ? JavaDocElementType.DOC_PARAMETER_REF : JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
|
||||
tagData.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
/**
|
||||
* @return (read-only) Foo
|
||||
*/
|
||||
Foo foo();
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
PsiJavaFile:Tag6.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:Test
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:class('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:Test('Test')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiMethod:foo
|
||||
PsiDocComment
|
||||
PsiDocToken:DOC_COMMENT_START('/**')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiDocToken:DOC_COMMENT_LEADING_ASTERISKS('*')
|
||||
PsiDocToken:DOC_COMMENT_DATA(' ')
|
||||
PsiDocTag:@return
|
||||
PsiDocToken:DOC_TAG_NAME('@return')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('read')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('-')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('only')
|
||||
PsiDocToken:DOC_TAG_VALUE_RPAREN(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiDocToken:DOC_COMMENT_DATA('Foo')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiDocToken:DOC_COMMENT_END('*/')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiTypeElement:Foo
|
||||
PsiJavaCodeReferenceElement:Foo
|
||||
PsiIdentifier:Foo('Foo')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:foo('foo')
|
||||
PsiParameterList:()
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -29,6 +29,8 @@ public class JavadocParsingTest extends JavaParsingTestCase {
|
||||
public void testTag3() { doTest(true); }
|
||||
public void testTag4() { doTest(true); }
|
||||
public void testTag5() { doTest(true); }
|
||||
public void testTag6() { doTest(true); }
|
||||
|
||||
public void testInlineTag0() { doTest(true); }
|
||||
public void testInlineTag1() { doTest(true); }
|
||||
public void testInlineTag2() { doTest(true); }
|
||||
@@ -87,8 +89,8 @@ public class JavadocParsingTest extends JavaParsingTestCase {
|
||||
public void testLiteralTag() { doTest(true); }
|
||||
|
||||
public void testIDEADEV_41403() { doTest(true); }
|
||||
|
||||
|
||||
public void testValueQualified() { doTest(true); }
|
||||
public void testValueUnqualifiedWithHash() { doTest(true); }
|
||||
public void testValueUnqualifiedWithoutHash() { doTest(true); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user