Bug 545898 - [formatter] IOOBE with empty javadoc @param
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
index 8949617..c913cd2 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -7658,4 +7658,17 @@
"}"
);
}
+/**
+ * https://bugs.eclipse.org/545898 - [formatter] IOOBE with empty javadoc @param
+ */
+public void testBug545898() {
+ useOldCommentWidthCounting();
+ String source =
+ "/**\n" +
+ " * @param\n" +
+ " */\n" +
+ "void foo() {\n" +
+ "}";
+ formatSource(source);
+}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java
index 0a7c06d..7803a20 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2018 Mateusz Matela and others.
+ * Copyright (c) 2014, 2019 Mateusz Matela and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -630,7 +630,7 @@
List<Token> tagTokens = new ArrayList<>();
tagTokens.add(this.ctm.get(startIndex));
- if (!PARAM_TAGS.contains(tagName)) {
+ if (!PARAM_TAGS.contains(tagName) || startIndex == endIndex) {
tagTokens.add(null);
}
for (int i = startIndex + 1; i <= endIndex; i++) {