aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry BLIND2014-04-07 19:25:26 (EDT)
committerThierry BLIND2014-04-07 19:25:26 (EDT)
commit3b422d1576c51461196eded7982ce50659293066 (patch)
tree5df544f96740a86d4e5baa6d32065909b2b09930
parentd58d803eb4f630dfb726b0f6ba396f56cb2ce33a (diff)
downloadorg.eclipse.pdt-3b422d1576c51461196eded7982ce50659293066.zip
org.eclipse.pdt-3b422d1576c51461196eded7982ce50659293066.tar.gz
org.eclipse.pdt-3b422d1576c51461196eded7982ce50659293066.tar.bz2
Correction for Bug 431979 - Code formatter remove pipe caracters andrefs/changes/96/24596/1
delete words when using multitype in @return comments (with patch). Signed-off-by: Thierry BLIND <thierryblind@msn.com>
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTag.java17
-rw-r--r--plugins/org.eclipse.php.formatter.core/src/org/eclipse/php/formatter/core/CodeFormatterVisitor.java10
2 files changed, 25 insertions, 2 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTag.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTag.java
index ce28ccf..ba7a488 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTag.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/nodes/PHPDocTag.java
@@ -82,7 +82,22 @@ public class PHPDocTag extends ASTNode implements PHPDocTagKinds {
}
public String[] getDescTexts() {
- int wordSize = referencesWithOrigOrder.length;
+ // For all unsupported tags
+ int wordSize = 0;
+ if (referencesWithOrigOrder.length == 0) {
+ // No references were found
+ wordSize = 0;
+ } else if (tagKind == RETURN || tagKind == VAR || tagKind == THROWS
+ || tagKind == SEE) {
+ // The word following the tag name was splitted into several
+ // references
+ wordSize = 1;
+ } else if (tagKind == PARAM || tagKind == PROPERTY
+ || tagKind == PROPERTY_READ || tagKind == PROPERTY_WRITE) {
+ // The two words following the tag name were splitted into two
+ // references
+ wordSize = 2;
+ }
List<String> result = new ArrayList<String>();
for (int i = 0; i < texts.size(); i++) {
String text = texts.get(i).getValue();
diff --git a/plugins/org.eclipse.php.formatter.core/src/org/eclipse/php/formatter/core/CodeFormatterVisitor.java b/plugins/org.eclipse.php.formatter.core/src/org/eclipse/php/formatter/core/CodeFormatterVisitor.java
index 9b86972..c4c4612 100644
--- a/plugins/org.eclipse.php.formatter.core/src/org/eclipse/php/formatter/core/CodeFormatterVisitor.java
+++ b/plugins/org.eclipse.php.formatter.core/src/org/eclipse/php/formatter/core/CodeFormatterVisitor.java
@@ -18,6 +18,7 @@ import java_cup.runtime.Symbol;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.dltk.ast.references.SimpleReference;
+import org.eclipse.dltk.ast.references.TypeReference;
import org.eclipse.jface.text.*;
import org.eclipse.php.internal.core.PHPVersion;
import org.eclipse.php.internal.core.ast.nodes.*;
@@ -76,6 +77,7 @@ public class CodeFormatterVisitor extends AbstractVisitor implements
private static final char SPACE = ' ';
private static final char COMMA = ',';
private static final char QUESTION_MARK = '?';
+ private static final char PHPDOC_CLASS_SEPARATOR = '|';
private String lineSeparator;
private CodeFormatterPreferences preferences;
@@ -1843,7 +1845,13 @@ public class CodeFormatterVisitor extends AbstractVisitor implements
SimpleReference[] reference = phpDocTag.getReferencesWithOrigOrder();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < reference.length; i++) {
- sb.append(" ").append(reference[i].getName()); //$NON-NLS-1$
+ if (i > 0 && reference[i - 1] instanceof TypeReference
+ && reference[i] instanceof TypeReference) {
+ sb.append(PHPDOC_CLASS_SEPARATOR)
+ .append(reference[i].getName()); //$NON-NLS-1$
+ } else {
+ sb.append(" ").append(reference[i].getName()); //$NON-NLS-1$
+ }
}
return sb.toString();
}