Skip to content

Commit

Permalink
Fixed AIOOBE for javadoc <pre>{@code}</pre> with missing closing brace
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-matela committed Dec 29, 2024
1 parent 4716533 commit 347d85b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7813,4 +7813,23 @@ public void testIssue2127b() {
""",
CodeFormatter.K_MODULE_INFO | CodeFormatter.F_INCLUDE_COMMENTS);
}
/**
* https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3372
*/
public void testIssue3372() {
String source =
"""
/**
* <pre>
* {@code
* void test() {
* int i;
* }
* </pre>
*/
class Test {
}
""";
formatSource(source);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,8 @@ private void handleFormatCodeTag(TagElement tagElement, int startPos, int endPos
// int closingBracePos = src.lastIndexOf('}', tag.getStartPosition() + tag.getLength());
// TODO bug 570137 workaround
int closingBracePos = tag.getStartPosition() + 1;
for (int braces = 1; braces > 0 && closingBracePos < src.length(); closingBracePos++) {
int lastPos = this.ctm.get(this.ctm.size() - 2).originalEnd;
for (int braces = 1; braces > 0 && closingBracePos < lastPos; closingBracePos++) {
if (src.charAt(closingBracePos) == '{')
braces++;
if (src.charAt(closingBracePos) == '}')
Expand Down

0 comments on commit 347d85b

Please sign in to comment.