Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDongqing Hu2013-04-05 18:29:28 +0000
committerMarkus Keller2013-04-05 18:29:28 +0000
commit6e4128f5cd06f71535503e1d8c2cddb98551d7a4 (patch)
tree212344608c94281419a91d59158859d379615a86
parent11bdf7ee83fa535bb4e922a4f202eec91a5eb529 (diff)
downloadeclipse.jdt.core-6e4128f5cd06f71535503e1d8c2cddb98551d7a4.tar.gz
eclipse.jdt.core-6e4128f5cd06f71535503e1d8c2cddb98551d7a4.tar.xz
eclipse.jdt.core-6e4128f5cd06f71535503e1d8c2cddb98551d7a4.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.java15
1 files changed, 11 insertions, 4 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 a6bf1516a1..143abbd89c 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -107,6 +107,7 @@ import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.core.dom.WildcardType;
+import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
/**
* Internal AST visitor for serializing an AST in a quick and dirty fashion.
@@ -1478,9 +1479,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