aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2018-06-03 06:43:57 -0400
committerAndrey Loskutov2018-06-03 06:43:57 -0400
commit9f903548e632c6555de6e0b4207b0da6fe3986eb (patch)
treef03797508b7b91b9c4232e95399d4317237c24bb
parent161ad37fec5f89d08e9cf93a1675aed3ed39d01d (diff)
downloadeclipse.platform.runtime-9f903548e632c6555de6e0b4207b0da6fe3986eb.zip
eclipse.platform.runtime-9f903548e632c6555de6e0b4207b0da6fe3986eb.tar.gz
eclipse.platform.runtime-9f903548e632c6555de6e0b4207b0da6fe3986eb.tar.xz
Bug 535489 - [expressions] add toString() to
org.eclipse.core.expressions.Expression subclasses Change-Id: I2ccc367c05d45547bcfc6f6ff7e7737c7dbf14b6 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/AdaptExpression.java17
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CompositeExpression.java14
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CountExpression.java40
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/EqualsExpression.java9
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java15
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/NotExpression.java5
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Property.java23
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ReferenceExpression.java9
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java19
-rw-r--r--bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/WithExpression.java16
10 files changed, 164 insertions, 3 deletions
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/AdaptExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/AdaptExpression.java
index 5ab6b4b..c87dba3 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/AdaptExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/AdaptExpression.java
@@ -11,9 +11,12 @@
*******************************************************************************/
package org.eclipse.core.internal.expressions;
+import java.util.Arrays;
+
import org.w3c.dom.Element;
import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionInfo;
import org.eclipse.core.expressions.IEvaluationContext;
@@ -125,4 +128,18 @@ public class AdaptExpression extends CompositeExpression {
info.markDefaultVariableAccessed();
super.collectExpressionInfo(info);
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(getClass().getSimpleName());
+ builder.append(" [type=").append(fTypeName); //$NON-NLS-1$
+ Expression[] children = getChildren();
+ if (children.length > 0) {
+ builder.append(", children="); //$NON-NLS-1$
+ builder.append(Arrays.toString(children));
+ }
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
+
}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CompositeExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CompositeExpression.java
index b3dc493..9ba9b91 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CompositeExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CompositeExpression.java
@@ -11,6 +11,7 @@
package org.eclipse.core.internal.expressions;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.core.expressions.EvaluationResult;
@@ -82,4 +83,17 @@ public abstract class CompositeExpression extends Expression {
protected int computeHashCode() {
return HASH_INITIAL * HASH_FACTOR + hashCode(fExpressions);
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(getClass().getSimpleName());
+ Expression[] children = getChildren();
+ if (children.length > 0) {
+ builder.append(" [children="); //$NON-NLS-1$
+ builder.append(Arrays.toString(children));
+ builder.append("]"); //$NON-NLS-1$
+ }
+ return builder.toString();
+ }
+
}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CountExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CountExpression.java
index 9a2b438..29aada5 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CountExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/CountExpression.java
@@ -145,4 +145,44 @@ public class CountExpression extends Expression {
return HASH_INITIAL * HASH_FACTOR + fMode
* HASH_FACTOR + fSize;
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(getClass().getSimpleName());
+ builder.append(" [ size="); //$NON-NLS-1$
+ builder.append(fSize);
+ builder.append(", mode: "); //$NON-NLS-1$
+ builder.append(fMode);
+ switch (fMode) {
+ case GREATER_THAN:
+ builder.append(" GREATER_THAN"); //$NON-NLS-1$
+ break;
+ case LESS_THAN:
+ builder.append(" LESS_THAN"); //$NON-NLS-1$ // -N)
+ break;
+ case ANY_NUMBER:
+ builder.append(" ANY_NUMBER"); //$NON-NLS-1$ // *
+ break;
+ case EXACT:
+ builder.append(" EXACT"); //$NON-NLS-1$ // N
+ break;
+ case ONE_OR_MORE:
+ builder.append(" ONE_OR_MORE"); //$NON-NLS-1$ // +
+ break;
+ case NONE_OR_ONE:
+ builder.append(" NONE_OR_ONE"); //$NON-NLS-1$ // ?
+ break;
+ case NONE:
+ builder.append(" NONE"); //$NON-NLS-1$ // !
+ break;
+ case UNKNOWN:
+ builder.append(" UNKNOWN"); //$NON-NLS-1$ ;
+ break;
+ default:
+ break;
+ }
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
+
}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/EqualsExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/EqualsExpression.java
index 4c71eb4..8c6a747 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/EqualsExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/EqualsExpression.java
@@ -70,4 +70,13 @@ public class EqualsExpression extends Expression {
protected int computeHashCode() {
return HASH_INITIAL * HASH_FACTOR + fExpectedValue.hashCode();
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(getClass().getSimpleName());
+ builder.append(" [expected="); //$NON-NLS-1$
+ builder.append(fExpectedValue);
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java
index 91a9b76..7ac1927 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.core.internal.expressions;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -17,6 +18,7 @@ import java.util.List;
import org.w3c.dom.Element;
import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionInfo;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.expressions.IIterable;
@@ -237,4 +239,17 @@ public class IterateExpression extends CompositeExpression {
return HASH_INITIAL * HASH_FACTOR + hashCode(fExpressions)
* HASH_FACTOR + fOperator;
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(getClass().getSimpleName());
+ builder.append(" [type=").append(fOperator == AND ? "AND" : "OR"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Expression[] children = getChildren();
+ if (children.length > 0) {
+ builder.append(", children="); //$NON-NLS-1$
+ builder.append(Arrays.toString(children));
+ }
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/NotExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/NotExpression.java
index 16b9aa0..e7f25b8 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/NotExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/NotExpression.java
@@ -54,4 +54,9 @@ public class NotExpression extends Expression {
protected int computeHashCode() {
return HASH_INITIAL * HASH_FACTOR + fExpression.hashCode();
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Property.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Property.java
index 4c7f60d..2e77977 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Property.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Property.java
@@ -16,9 +16,9 @@ import org.eclipse.core.runtime.Assert;
public class Property {
- private Class<?> fType;
- private String fNamespace;
- private String fName;
+ private final Class<?> fType;
+ private final String fNamespace;
+ private final String fName;
private IPropertyTester fTester;
@@ -70,4 +70,21 @@ public class Property {
public int hashCode() {
return (fType.hashCode() << 16) | fNamespace.hashCode() << 8 | fName.hashCode();
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Property ["); //$NON-NLS-1$
+ builder.append(fNamespace);
+ builder.append("."); //$NON-NLS-1$
+ builder.append(fName);
+ builder.append(", type="); //$NON-NLS-1$
+ builder.append(fType);
+ if (fTester != null) {
+ builder.append(", tester="); //$NON-NLS-1$
+ builder.append(fTester);
+ }
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ReferenceExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ReferenceExpression.java
index b06c6e6..6ce7205 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ReferenceExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ReferenceExpression.java
@@ -97,4 +97,13 @@ public class ReferenceExpression extends Expression {
protected int computeHashCode() {
return HASH_INITIAL * HASH_FACTOR + fDefinitionId.hashCode();
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(getClass().getSimpleName());
+ builder.append(" [definitionId="); //$NON-NLS-1$
+ builder.append(fDefinitionId);
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java
index c1ad6a8..1f3c4c9 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java
@@ -10,10 +10,13 @@
*******************************************************************************/
package org.eclipse.core.internal.expressions;
+import java.util.Arrays;
+
import org.w3c.dom.Element;
import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionInfo;
import org.eclipse.core.expressions.IEvaluationContext;
@@ -90,4 +93,20 @@ public class ResolveExpression extends CompositeExpression {
* HASH_FACTOR + hashCode(fArgs)
* HASH_FACTOR + fVariable.hashCode();
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(getClass().getSimpleName());
+ builder.append(" [variable=").append(fVariable); //$NON-NLS-1$
+ if (fArgs != null) {
+ builder.append(", args=").append(Arrays.toString(fArgs)); //$NON-NLS-1$
+ }
+ Expression[] children = getChildren();
+ if (children.length > 0) {
+ builder.append(", children="); //$NON-NLS-1$
+ builder.append(Arrays.toString(children));
+ }
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/WithExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/WithExpression.java
index a64df38..be34104 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/WithExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/WithExpression.java
@@ -10,10 +10,13 @@
*******************************************************************************/
package org.eclipse.core.internal.expressions;
+import java.util.Arrays;
+
import org.w3c.dom.Element;
import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionInfo;
import org.eclipse.core.expressions.IEvaluationContext;
@@ -84,4 +87,17 @@ public class WithExpression extends CompositeExpression {
}
info.mergeExceptDefaultVariable(other);
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(getClass().getSimpleName());
+ builder.append(" [variable=").append(fVariable); //$NON-NLS-1$
+ Expression[] children = getChildren();
+ if (children.length > 0) {
+ builder.append(", children="); //$NON-NLS-1$
+ builder.append(Arrays.toString(children));
+ }
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
} \ No newline at end of file