Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDongqing Hu2013-05-16 07:07:49 +0000
committerJayaprakash Arthanareeswaran2013-05-16 10:58:44 +0000
commit6d2c36cd6a158e27a9e02bee22865e65d7a52a58 (patch)
tree6ae432ee3cde3bf17090b4922074a1dca52294c6
parenta0e5f98b1c0224b51eff41180a89042104376c95 (diff)
downloadeclipse.jdt.core-6d2c36cd6a158e27a9e02bee22865e65d7a52a58.tar.gz
eclipse.jdt.core-6d2c36cd6a158e27a9e02bee22865e65d7a52a58.tar.xz
eclipse.jdt.core-6d2c36cd6a158e27a9e02bee22865e65d7a52a58.zip
Bug 403735: NaiveASTFlattener does not flatten Javadoc correctly (missed
an important whitespace)
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
index 27fdab7c9f..ecd82da382 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
@@ -18,6 +18,7 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.jdt.core.dom.*;
+import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
/**
* Internal AST visitor for serializing an AST in a quick and dirty fashion.
@@ -1543,9 +1544,15 @@ public class NaiveASTFlattener extends ASTVisitor {
boolean previousRequiresNewLine = false;
for (Iterator it = node.fragments().iterator(); it.hasNext(); ) {
ASTNode e = (ASTNode) it.next();
- // assume text elements include necessary leading and trailing whitespace
- // but Name, MemberRef, MethodRef, and nested TagElement do not include white space
- boolean currentIncludesWhiteSpace = (e instanceof TextElement);
+ // Name, MemberRef, MethodRef, and nested TagElement do not include white space.
+ // TextElements don't always include whitespace, see <https://bugs.eclipse.org/206518>.
+ boolean currentIncludesWhiteSpace = false;
+ if (e instanceof TextElement) {
+ String text = ((TextElement) e).getText();
+ if (text.length() > 0 && ScannerHelper.isWhitespace(text.charAt(0))) {
+ currentIncludesWhiteSpace = true; // workaround for https://bugs.eclipse.org/403735
+ }
+ }
if (previousRequiresNewLine && currentIncludesWhiteSpace) {
this.buffer.append("\n * ");//$NON-NLS-1$
}

Back to the top