Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Matela2019-04-29 18:08:06 +0000
committerMateusz Matela2019-04-29 18:09:13 +0000
commit0af93e735d1c71697728854a488fb34b4c2d280b (patch)
tree78cb54fa6b30366cc9518bcb80ba206d7ced9217
parent134ff1f738789c12523e5e04627bcf666c2a08a4 (diff)
downloadeclipse.jdt.core-0af93e735d1c71697728854a488fb34b4c2d280b.tar.gz
eclipse.jdt.core-0af93e735d1c71697728854a488fb34b4c2d280b.tar.xz
eclipse.jdt.core-0af93e735d1c71697728854a488fb34b4c2d280b.zip
Bug 545898 - [formatter] IOOBE with empty javadoc @paramI20190429-1800
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java15
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java4
2 files changed, 16 insertions, 3 deletions
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 8949617b1c..c913cd2812 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 @@ public void testBug512095() {
"}"
);
}
+/**
+ * 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 0a7c06daef..7803a20517 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 @@ public class CommentsPreparator extends ASTVisitor {
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++) {

Back to the top