Skip to content

Commit 66f69ff

Browse files
added more unit tests
1 parent 8a01966 commit 66f69ff

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,4 +2014,42 @@ public class Markdown() {}
20142014
assertTrue(tagFragments.get(1) instanceof SimpleName);
20152015
}
20162016
}
2017+
2018+
// [)[) - invalid condition
2019+
public void testMarkdownURLs4531_06() throws JavaModelException {
2020+
String source = """
2021+
/// @see [Ex Si)[http://ex.com)
2022+
public class Markdown() {}
2023+
""";
2024+
this.workingCopies = new ICompilationUnit[1];
2025+
this.workingCopies[0] = getWorkingCopy("/Converter_25/src/markdown/gh3761/Markdown.java", source, null);
2026+
if (this.docCommentSupport.equals(JavaCore.ENABLED)) {
2027+
CompilationUnit compilUnit = (CompilationUnit) runConversion(this.workingCopies[0], true);
2028+
TypeDeclaration typedeclaration = (TypeDeclaration) compilUnit.types().get(0);
2029+
Javadoc javadoc = typedeclaration.getJavadoc();
2030+
TagElement tags = (TagElement) javadoc.tags().get(0);
2031+
assertEquals("fragments count does not match", 3, tags.fragments().size());
2032+
assertTrue(tags.fragments().get(0) instanceof TextElement);
2033+
assertTrue(tags.fragments().get(1) instanceof TextElement);
2034+
assertTrue(tags.fragments().get(2) instanceof TagElement);
2035+
}
2036+
}
2037+
2038+
// (](] - invalid condition
2039+
public void testMarkdownURLs4531_07() throws JavaModelException {
2040+
String source = """
2041+
/// @see (Ex Si](http://ex.com]
2042+
public class Markdown() {}
2043+
""";
2044+
this.workingCopies = new ICompilationUnit[1];
2045+
this.workingCopies[0] = getWorkingCopy("/Converter_25/src/markdown/gh3761/Markdown.java", source, null);
2046+
if (this.docCommentSupport.equals(JavaCore.ENABLED)) {
2047+
CompilationUnit compilUnit = (CompilationUnit) runConversion(this.workingCopies[0], true);
2048+
TypeDeclaration typedeclaration = (TypeDeclaration) compilUnit.types().get(0);
2049+
Javadoc javadoc = typedeclaration.getJavadoc();
2050+
TagElement tags = (TagElement) javadoc.tags().get(0);
2051+
assertEquals("fragments count does not match", 1, tags.fragments().size());
2052+
assertTrue(tags.fragments().get(0) instanceof TextElement);
2053+
}
2054+
}
20172055
}

org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,10 @@ protected boolean parseMarkdownLinks(int previousPosition) throws InvalidInputEx
735735
break;
736736
case ')':
737737
case ']':
738+
if (this.source[start - 1] == '[' && currentChar == ')' &&
739+
peekChar() == '[' && this.source[this.scanner.eofPosition-2] == ')') {
740+
return false; //[)[) - invalid
741+
}
738742
if ((peekChar() == '[' ) || peekChar() == '(') {
739743
tStart = start;
740744
tEnd = this.index - 1;

0 commit comments

Comments
 (0)