Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java70
1 files changed, 8 insertions, 62 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java
index 26cbce481..e7c3bc7ec 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java
@@ -12,8 +12,8 @@ package org.eclipse.equinox.internal.p2.ql.expression;
import java.util.Iterator;
import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.internal.p2.ql.Everything;
-import org.eclipse.equinox.p2.metadata.expression.*;
+import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
+import org.eclipse.equinox.p2.metadata.expression.IExpression;
import org.eclipse.equinox.p2.ql.IContextExpression;
import org.eclipse.equinox.p2.ql.ITranslationSupport;
@@ -22,71 +22,17 @@ import org.eclipse.equinox.p2.ql.ITranslationSupport;
* variable 'everything' and initialized it with the iterator that represents all
* available items.
*/
-public final class ContextExpression<T> extends Unary implements IContextExpression<T>, IQLConstants {
- private static final Object[] noParams = new Object[0];
- private final Class<T> elementClass;
- private final Object[] parameters;
-
- public ContextExpression(Class<T> elementClass, Expression expression, Object[] parameters) {
- super(expression);
- this.elementClass = elementClass;
- this.parameters = parameters == null ? noParams : parameters;
- }
-
- public boolean accept(IExpressionVisitor visitor) {
- return visitor.visit(operand);
- }
-
- public void toString(StringBuffer bld, Variable rootVariable) {
- operand.toString(bld, rootVariable);
- }
-
- public IEvaluationContext createContext(Iterator<T> iterator) {
- Variable everything = QLFactory.EVERYTHING;
- IEvaluationContext context = EvaluationContext.create(parameters, everything);
- context.setValue(everything, new Everything<T>(elementClass, iterator, QLUtil.needsRepeadedAccessToEverything(operand)));
- return context;
+public final class ContextExpression<T> extends org.eclipse.equinox.internal.p2.metadata.expression.ContextExpression<T> implements IContextExpression<T> {
+ public ContextExpression(Expression expression, Object[] parameters) {
+ super(expression, parameters);
}
- public IEvaluationContext createContext(Iterator<T> iterator, ITranslationSupport ts) {
- Variable everything = QLFactory.EVERYTHING;
+ public IEvaluationContext createContext(Class<T> elementClass, Iterator<T> iterator, ITranslationSupport ts) {
+ Variable everything = ExpressionFactory.EVERYTHING;
IExpression translations = QLFactory.TRANSLATIONS;
IEvaluationContext context = EvaluationContext.create(parameters, new IExpression[] {everything, translations});
- context.setValue(everything, new Everything<T>(elementClass, iterator, QLUtil.needsRepeadedAccessToEverything(operand)));
+ context.setValue(everything, new Everything<T>(elementClass, iterator, operand));
context.setValue(translations, ts);
return context;
}
-
- public Class<T> getElementClass() {
- return elementClass;
- }
-
- public int getExpressionType() {
- return 0;
- }
-
- public String getOperator() {
- throw new UnsupportedOperationException();
- }
-
- public int getPriority() {
- return operand.getPriority();
- }
-
- public Object[] getParameters() {
- return parameters;
- }
-
- public int hashCode() {
- return operand.hashCode();
- }
-
- @SuppressWarnings("unchecked")
- public Iterator<T> iterator(IEvaluationContext context) {
- return (Iterator<T>) evaluateAsIterator(context);
- }
-
- public void toString(StringBuffer bld) {
- toString(bld, QLFactory.EVERYTHING);
- }
}

Back to the top