Skip to content

Commit 9ac2927

Browse files
in-corporate code review comments
1 parent 9a7b508 commit 9ac2927

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,34 +1404,36 @@ protected boolean parseURLReference() throws InvalidInputException {
14041404
firstTokenStartPos = this.index;
14051405
while (pos < this.source.length) {
14061406
c = readChar();
1407-
if (c == '(' || c == '[' || c == ' ')
1407+
if (c == '[') // invalid syntax for url
1408+
return false;
1409+
if (c == '(' || c == ' ')
14081410
continue;
14091411

1410-
if (c == '\t' || c == '\n' || c == '\r' || c == '*' || c == ')' || c == '[' || c == ']' ) {
1412+
if (c == '\n' || c == '\r' || c == ')' ) {
14111413
break;
14121414
}
14131415
urlBuilder.append(c);
14141416
}
14151417
pos = this.index - 1;
1416-
if (validateMarkdownSyntax(this.source[firstTokenStartPos], this.source[pos]))
1417-
fullURL = urlBuilder.toString().toCharArray();
1418+
fullURL = urlBuilder.toString().toCharArray();
14181419
} else {
14191420
pos = this.scanner.startPosition - 1;
14201421
firstTokenStartPos = pos;
14211422
while (pos < this.source.length) {
14221423
c = this.source[pos];
1423-
if (c == '(' || c == '[' || c == ' ') {
1424+
if (c == '[') // invalid syntax for url
1425+
return false;
1426+
if (c == '(' || c == ' ') {
14241427
pos++;
14251428
continue;
14261429
}
1427-
if (c == '\t' || c == '\n' || c == '\r' || c == '*' || c == ')' || c == '[' || c == ']' ) {
1430+
if (c == '\n' || c == '\r' || c == ')') {
14281431
break;
14291432
}
14301433
urlBuilder.append(c);
14311434
pos++;
14321435
}
1433-
if (validateMarkdownSyntax(this.source[firstTokenStartPos], this.source[pos]))
1434-
fullURL = urlBuilder.toString().toCharArray();
1436+
fullURL = urlBuilder.toString().toCharArray();
14351437
}
14361438

14371439
this.identifierPtr = 0;
@@ -1443,11 +1445,6 @@ protected boolean parseURLReference() throws InvalidInputException {
14431445
return true;
14441446
}
14451447

1446-
/// validate markdown syntax check
1447-
private boolean validateMarkdownSyntax(char start, char end) {
1448-
return (start == '[' && end == ']') || (start == '(' && end == ')');
1449-
}
1450-
14511448
/*
14521449
* Parse a reference in @see tag
14531450
*/

org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterMarkdownTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,11 @@ public class Markdown() {}
20272027
CompilationUnit compilUnit = (CompilationUnit) runConversion(this.workingCopies[0], true);
20282028
TypeDeclaration typedeclaration = (TypeDeclaration) compilUnit.types().get(0);
20292029
Javadoc javadoc = typedeclaration.getJavadoc();
2030-
assertEquals("Tags count does not match", 0, javadoc.tags().size());
2030+
assertEquals("Tags count does not match", 1, javadoc.tags().size());
2031+
TagElement tags = (TagElement) javadoc.tags().get(0);
2032+
assertTrue(tags.fragments().get(0) instanceof TextElement);
2033+
assertTrue(tags.fragments().get(1) instanceof TextElement);
2034+
assertTrue(tags.fragments().get(2) instanceof TextElement);
20312035
}
20322036
}
20332037

0 commit comments

Comments
 (0)