Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-03-23 10:39:02 +0000
committerThomas Hallgren2010-03-23 10:39:02 +0000
commitda12e4db54d637bd5f4c24bc1e3904424fc18ba0 (patch)
treeb5a7cfc40be2e8bc2407d7386b2441f09d1b46f4 /bundles/org.eclipse.equinox.p2.ql
parent48c3679d0a7d2d590e00538c7af801676384a26f (diff)
downloadrt.equinox.p2-da12e4db54d637bd5f4c24bc1e3904424fc18ba0.tar.gz
rt.equinox.p2-da12e4db54d637bd5f4c24bc1e3904424fc18ba0.tar.xz
rt.equinox.p2-da12e4db54d637bd5f4c24bc1e3904424fc18ba0.zip
306217 : [api] Merge p2.ql bundle into metadata
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ql')
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/.settings/.api_filters12
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/META-INF/MANIFEST.MF21
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/OSGI-INF/qlFactory.xml8
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/OSGI-INF/qlParser.xml8
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/QLActivator.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Array.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Assignment.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/BooleanFunction.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ClassFunction.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Collect.java68
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Condition.java64
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/CurryedLambdaExpression.java88
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/FilterFunction.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/First.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Flatten.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Function.java79
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/IQLConstants.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Intersect.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Latest.java94
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Limit.java93
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Pipe.java163
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLFactory.java145
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLUtil.java88
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/RangeFunction.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Select.java51
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/SetFunction.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Traverse.java60
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/UnaryCollectionFilter.java44
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Union.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Unique.java83
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/VersionFunction.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/WrappedIQuery.java76
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/parser/QLParser.java360
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLExpression.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLFactory.java116
35 files changed, 4 insertions, 2326 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ql/.settings/.api_filters b/bundles/org.eclipse.equinox.p2.ql/.settings/.api_filters
deleted file mode 100644
index 0fa1636b7..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/.settings/.api_filters
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.equinox.p2.ql" version="2">
- <resource path="src/org/eclipse/equinox/internal/p2/ql/expression/WrappedIQuery.java" type="org.eclipse.equinox.internal.p2.ql.expression.WrappedIQuery">
- <filter id="640712815">
- <message_arguments>
- <message_argument value="IMatchQuery&lt;T&gt;"/>
- <message_argument value="WrappedIQuery"/>
- <message_argument value="isMatch(T)"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
diff --git a/bundles/org.eclipse.equinox.p2.ql/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ql/META-INF/MANIFEST.MF
index a14ba9512..072c1650e 100644
--- a/bundles/org.eclipse.equinox.p2.ql/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.ql/META-INF/MANIFEST.MF
@@ -4,29 +4,12 @@ Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.ql;singleton:=true
Bundle-Version: 2.0.0.qualifier
Bundle-ClassPath: .
-Bundle-Activator: org.eclipse.equinox.internal.p2.ql.QLActivator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Export-Package: org.eclipse.equinox.internal.p2.ql.expression;x-internal:=true,
- org.eclipse.equinox.p2.ql;version="2.0.0"
+Export-Package: org.eclipse.equinox.p2.ql;version="2.0.0"
Require-Bundle: org.eclipse.equinox.common;bundle-version="3.5.1"
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
J2SE-1.4,
CDC-1.1/Foundation-1.1
Bundle-ActivationPolicy: lazy
-Service-Component: OSGI-INF/qlFactory.xml, OSGI-INF/qlParser.xml
-Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
- org.eclipse.equinox.internal.p2.metadata,
- org.eclipse.equinox.internal.p2.metadata.expression,
- org.eclipse.equinox.internal.p2.metadata.expression.parser,
- org.eclipse.equinox.internal.p2.metadata.index,
- org.eclipse.equinox.internal.p2.metadata.query,
- org.eclipse.equinox.p2.core;version="[2.0.0,3.0.0)",
- org.eclipse.equinox.p2.engine;version="[2.0.0,3.0.0)",
- org.eclipse.equinox.p2.metadata;version="[2.0.0,3.0.0)",
- org.eclipse.equinox.p2.metadata.expression;version="[2.0.0,3.0.0)",
- org.eclipse.equinox.p2.metadata.index;version="[2.0.0,3.0.0)",
- org.eclipse.equinox.p2.query;version="[2.0.0,3.0.0)",
- org.eclipse.equinox.p2.repository.artifact;version="[2.0.0,3.0.0)",
- org.eclipse.osgi.service.localization,
- org.osgi.framework
+Import-Package: org.eclipse.equinox.p2.metadata.expression;version="[2.0.0,3.0.0)"
diff --git a/bundles/org.eclipse.equinox.p2.ql/OSGI-INF/qlFactory.xml b/bundles/org.eclipse.equinox.p2.ql/OSGI-INF/qlFactory.xml
deleted file mode 100644
index 407aa9704..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/OSGI-INF/qlFactory.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.ql.factory">
- <implementation class="org.eclipse.equinox.internal.p2.ql.expression.QLFactory"/>
- <service>
- <provide interface="org.eclipse.equinox.p2.metadata.expression.IExpressionFactory"/>
- </service>
- <property name="service.priority" type="Integer" value="2"/>
-</scr:component>
diff --git a/bundles/org.eclipse.equinox.p2.ql/OSGI-INF/qlParser.xml b/bundles/org.eclipse.equinox.p2.ql/OSGI-INF/qlParser.xml
deleted file mode 100644
index 5cbb1f6e4..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/OSGI-INF/qlParser.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.ql.parser">
- <implementation class="org.eclipse.equinox.internal.p2.ql.parser.QLParser"/>
- <service>
- <provide interface="org.eclipse.equinox.p2.metadata.expression.IExpressionParser"/>
- </service>
- <property name="service.priority" type="Integer" value="2"/>
-</scr:component> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/QLActivator.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/QLActivator.java
deleted file mode 100644
index d1fc901fd..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/QLActivator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class QLActivator implements BundleActivator {
- public static BundleContext context;
-
- public static BundleContext getContext() {
- return context;
- }
-
- public void start(BundleContext aContext) throws Exception {
- QLActivator.context = aContext;
- }
-
- public void stop(BundleContext aContext) throws Exception {
- QLActivator.context = null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Array.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Array.java
deleted file mode 100644
index 62dfb329c..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Array.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * An array of expressions
- */
-final class Array extends NAry implements IQLConstants, IQLExpression {
- final class ArrayIterator implements Iterator<Object> {
- private final IEvaluationContext context;
-
- private int pos = -1;
-
- public ArrayIterator(IEvaluationContext context) {
- this.context = context;
- }
-
- public boolean hasNext() {
- return pos + 1 < operands.length;
- }
-
- public Object next() {
- if (++pos >= operands.length) {
- --pos;
- throw new NoSuchElementException();
- }
- return operands[pos].evaluate(context);
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- Array(Expression[] operands) {
- super(assertLength(operands, 0, OPERATOR_ARRAY));
- }
-
- public Object evaluate(IEvaluationContext context) {
- return evaluateAsIterator(context);
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- return new ArrayIterator(context);
- }
-
- public int getExpressionType() {
- return TYPE_ARRAY;
- }
-
- public void toString(StringBuffer bld, Variable rootVariable) {
- bld.append('[');
- elementsToString(bld, rootVariable, operands);
- bld.append(']');
- }
-
- public String getOperator() {
- return OPERATOR_ARRAY;
- }
-
- public int getPriority() {
- return PRIORITY_FUNCTION;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Assignment.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Assignment.java
deleted file mode 100644
index 22b747b7e..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Assignment.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * An expression representing a variable stack in the current thread.
- */
-class Assignment extends Binary implements IQLConstants, IQLExpression {
- Assignment(Variable variable, Expression expression) {
- super(variable, expression);
- }
-
- public final Object evaluate(IEvaluationContext context) {
- Object value = rhs.evaluate(context);
- context.setValue(lhs, value);
- return value;
- }
-
- public int getExpressionType() {
- return TYPE_ASSIGNMENT;
- }
-
- public int getPriority() {
- return IExpressionConstants.PRIORITY_ASSIGNMENT;
- }
-
- public String getOperator() {
- return OPERATOR_ASSIGN;
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- Iterator<?> value = rhs.evaluateAsIterator(context);
- context.setValue(lhs, value);
- return value;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/BooleanFunction.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/BooleanFunction.java
deleted file mode 100644
index 860fe6e12..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/BooleanFunction.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.expression.Expression;
-
-/**
- * A function that obtains a class based on a String
- */
-public final class BooleanFunction extends Function {
-
- public BooleanFunction(Expression[] operands) {
- super(assertLength(operands, 1, 1, KEYWORD_BOOLEAN));
- }
-
- boolean assertSingleArgumentClass(Object v) {
- return v instanceof String || v instanceof Boolean;
- }
-
- Object createInstance(Object arg) {
- if (arg instanceof String)
- return Boolean.valueOf("true".equalsIgnoreCase((String) arg)); //$NON-NLS-1$
- if (arg instanceof Boolean)
- return arg;
- return Boolean.FALSE;
- }
-
- public String getOperator() {
- return KEYWORD_BOOLEAN;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ClassFunction.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ClassFunction.java
deleted file mode 100644
index 53d0b3044..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ClassFunction.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.expression.Expression;
-
-/**
- * A function that obtains a class based on a String
- */
-public final class ClassFunction extends Function {
-
- public ClassFunction(Expression[] operands) {
- super(assertLength(operands, 1, 1, KEYWORD_CLASS));
- }
-
- boolean assertSingleArgumentClass(Object v) {
- return v instanceof String;
- }
-
- Object createInstance(Object arg) {
- try {
- return Class.forName((String) arg);
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
-
- public String getOperator() {
- return KEYWORD_CLASS;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Collect.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Collect.java
deleted file mode 100644
index 5f3a67ebc..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Collect.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import org.eclipse.equinox.internal.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.IQLExpression;
-
-/**
- */
-final class Collect extends CollectionFilter implements IQLExpression {
- final class CollectIterator implements Iterator<Object> {
- private final IEvaluationContext context;
-
- private final IExpression variable;
-
- private final Iterator<?> innerIterator;
-
- public CollectIterator(IEvaluationContext context, Iterator<?> iterator) {
- this.context = context;
- this.variable = lambda.getItemVariable();
- this.innerIterator = iterator;
- }
-
- public boolean hasNext() {
- return innerIterator.hasNext();
- }
-
- public Object next() {
- context.setValue(variable, innerIterator.next());
- return lambda.evaluate(context);
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- Collect(Expression collection, LambdaExpression lambda) {
- super(collection, lambda);
- }
-
- public Object evaluate(IEvaluationContext context, Iterator<?> itor) {
- return evaluateAsIterator(context, itor);
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context, Iterator<?> itor) {
- return new CollectIterator(context, itor);
- }
-
- public int getExpressionType() {
- return TYPE_COLLECT;
- }
-
- public String getOperator() {
- return IQLConstants.KEYWORD_COLLECT;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Condition.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Condition.java
deleted file mode 100644
index 9de25672c..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Condition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * Comparisons for magnitude.
- */
-final class Condition extends Binary implements IQLConstants, IQLExpression {
- final Expression ifFalse;
-
- Condition(Expression test, Expression ifTrue, Expression ifFalse) {
- super(test, ifTrue);
- this.ifFalse = ifFalse;
- }
-
- public boolean equals(Object o) {
- return super.equals(o) && ifFalse.equals(((Condition) o).ifFalse);
- }
-
- public Object evaluate(IEvaluationContext context) {
- return lhs.evaluate(context) == Boolean.TRUE ? rhs.evaluate(context) : ifFalse.evaluate(context);
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- return lhs.evaluate(context) == Boolean.TRUE ? rhs.evaluateAsIterator(context) : ifFalse.evaluateAsIterator(context);
- }
-
- public int hashCode() {
- return super.hashCode() * 31 + ifFalse.hashCode();
- }
-
- public void toString(StringBuffer bld, Variable rootVariable) {
- super.toString(bld, rootVariable);
- bld.append(' ');
- bld.append(OPERATOR_ELSE);
- bld.append(' ');
- appendOperand(bld, rootVariable, ifFalse, getPriority());
- }
-
- public int getExpressionType() {
- return TYPE_CONDITION;
- }
-
- public String getOperator() {
- return OPERATOR_IF;
- }
-
- public int getPriority() {
- return IExpressionConstants.PRIORITY_CONDITION;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/CurryedLambdaExpression.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/CurryedLambdaExpression.java
deleted file mode 100644
index eae2c915d..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/CurryedLambdaExpression.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.metadata.expression.IExpressionVisitor;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * A function that executes some code
- */
-final class CurryedLambdaExpression extends LambdaExpression implements IQLConstants, IQLExpression {
- private static final Assignment[] emptyAssignmentArray = new Assignment[0];
- private final Assignment[] assignments;
-
- CurryedLambdaExpression(Variable each, Assignment[] assignments, Expression body) {
- super(each, body);
- if (assignments == null)
- assignments = emptyAssignmentArray;
- this.assignments = assignments;
- }
-
- public boolean accept(IExpressionVisitor visitor) {
- if (super.accept(visitor) && each.accept(visitor)) {
- for (int idx = 0; idx < assignments.length; ++idx)
- if (!assignments[idx].accept(visitor))
- return false;
- return true;
- }
- return false;
- }
-
- public int compareTo(Expression e) {
- int cmp = super.compareTo(e);
- if (cmp == 0)
- cmp = compare(assignments, ((CurryedLambdaExpression) e).assignments);
- return cmp;
- }
-
- public boolean equals(Object o) {
- return super.equals(o) && equals(assignments, ((CurryedLambdaExpression) o).assignments);
- }
-
- public int hashCode() {
- return 31 * super.hashCode() + hashCode(assignments);
- }
-
- public void toString(StringBuffer bld, Variable rootVariable) {
- int top = assignments.length;
- if (top > 0) {
- for (int idx = 0; idx < top; ++idx) {
- appendOperand(bld, rootVariable, assignments[idx].rhs, IExpressionConstants.PRIORITY_COMMA);
- bld.append(", "); //$NON-NLS-1$
- }
- bld.append(IQLConstants.OPERATOR_EACH);
- bld.append(", {"); //$NON-NLS-1$
- for (int idx = 0; idx < top; ++idx) {
- appendOperand(bld, rootVariable, assignments[idx].lhs, IExpressionConstants.PRIORITY_COMMA);
- bld.append(", "); //$NON-NLS-1$
- }
- }
- super.toString(bld, rootVariable);
- if (top > 0)
- bld.append('}');
- }
-
- public IEvaluationContext prolog(IEvaluationContext context) {
- IEvaluationContext lambdaContext;
- int top = assignments.length + 1;
- Variable[] vars = new Variable[top];
- vars[0] = getItemVariable();
- for (int idx = 1; idx < top; ++idx)
- vars[idx] = (Variable) assignments[idx - 1].lhs;
- lambdaContext = EvaluationContext.create(context, vars);
- for (int idx = 1; idx < top; ++idx)
- lambdaContext.setValue(vars[idx], assignments[idx - 1].rhs.evaluate(context));
- return lambdaContext;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/FilterFunction.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/FilterFunction.java
deleted file mode 100644
index 0a4f96995..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/FilterFunction.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.expression.Expression;
-import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
-
-/**
- * A function that creates an OSGi filter based on a String
- */
-public final class FilterFunction extends Function {
- public FilterFunction(Expression[] operands) {
- super(assertLength(operands, 1, 1, KEYWORD_FILTER));
- }
-
- boolean assertSingleArgumentClass(Object v) {
- return v instanceof String;
- }
-
- Object createInstance(Object arg) {
- return ExpressionUtil.parseLDAP((String) arg);
- }
-
- public String getOperator() {
- return KEYWORD_FILTER;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/First.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/First.java
deleted file mode 100644
index decd15906..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/First.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * A collection filter that yields the first element of the <code>collection</code> for which
- * the <code>filter</code> yields <code>true</code>
- */
-final class First extends CollectionFilter implements IQLExpression {
- First(Expression collection, LambdaExpression lambda) {
- super(collection, lambda);
- }
-
- protected Object evaluate(IEvaluationContext context, Iterator<?> itor) {
- Variable variable = lambda.getItemVariable();
- while (itor.hasNext()) {
- Object each = itor.next();
- variable.setValue(context, each);
- if (lambda.evaluate(context) == Boolean.TRUE)
- return each;
- }
- return null;
- }
-
- public int getExpressionType() {
- return TYPE_FIRST;
- }
-
- public String getOperator() {
- return IQLConstants.KEYWORD_FIRST;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Flatten.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Flatten.java
deleted file mode 100644
index 8aa33622c..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Flatten.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator;
-
-import java.util.Iterator;
-import org.eclipse.equinox.internal.p2.metadata.expression.Expression;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-
-/**
- * An expression that yields a new collection consisting of all elements of the
- * <code>collection</code> for which the <code>filter</code> yields <code>true</code>.
- */
-final class Flatten extends UnaryCollectionFilter {
- Flatten(Expression collection) {
- super(collection);
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- return new CompoundIterator<Object>(operand.evaluateAsIterator(context));
- }
-
- public int getExpressionType() {
- return TYPE_FLATTEN;
- }
-
- public String getOperator() {
- return KEYWORD_FLATTEN;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Function.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Function.java
deleted file mode 100644
index d704681f2..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Function.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * An expression that represents a function such as filter(&lt;expr&gt;) or version(&lt;expr&gt;)
- */
-public abstract class Function extends NAry implements IQLExpression {
-
- private Object instance;
-
- protected Function(Expression[] operands) {
- super(operands);
- }
-
- boolean assertSingleArgumentClass(Object v) {
- return true;
- }
-
- Object createInstance(Object arg) {
- throw new UnsupportedOperationException();
- }
-
- final Object createInstance(String arg) {
- throw new UnsupportedOperationException();
- }
-
- public Object evaluate(IEvaluationContext context) {
- if (instance != null)
- return instance;
-
- Expression operand = operands[0];
- Object arg = operand.evaluate(context);
- if (assertSingleArgumentClass(arg)) {
- Object result = createInstance(arg);
- if (operand instanceof Literal || operand instanceof Parameter)
- // operand won't change over time so we can cache this instance.
- instance = result;
- return result;
- }
- String what = arg == null ? "null" : ("a " + arg.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
- throw new IllegalArgumentException("Cannot create a " + getOperator() + " from " + what); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- Object value = evaluate(context);
- if (!(value instanceof Iterator<?>))
- value = RepeatableIterator.create(value);
- return (Iterator<?>) value;
- }
-
- public int getExpressionType() {
- return TYPE_FUNCTION;
- }
-
- public int getPriority() {
- return PRIORITY_FUNCTION;
- }
-
- public void toString(StringBuffer bld, Variable rootVariable) {
- bld.append(getOperator());
- bld.append('(');
- elementsToString(bld, rootVariable, operands);
- bld.append(')');
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/IQLConstants.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/IQLConstants.java
deleted file mode 100644
index 74a958003..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/IQLConstants.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-public interface IQLConstants {
- String KEYWORD_COLLECT = "collect"; //$NON-NLS-1$
- String KEYWORD_FIRST = "first"; //$NON-NLS-1$
- String KEYWORD_FLATTEN = "flatten"; //$NON-NLS-1$
- String KEYWORD_INTERSECT = "intersect"; //$NON-NLS-1$
- String KEYWORD_IQUERY = "iquery"; //$NON-NLS-1$
- String KEYWORD_LATEST = "latest"; //$NON-NLS-1$
- String KEYWORD_LIMIT = "limit"; //$NON-NLS-1$
- String KEYWORD_LOCALIZED_KEYS = "localizedKeys"; //$NON-NLS-1$
- String KEYWORD_LOCALIZED_MAP = "localizedMap"; //$NON-NLS-1$
- String KEYWORD_LOCALIZED_PROPERTY = "localizedProperty"; //$NON-NLS-1$
- String KEYWORD_SATISFIES_ALL = "satisfiesAll"; //$NON-NLS-1$
- String KEYWORD_SATISFIES_ANY = "satisfiesAny"; //$NON-NLS-1$
- String KEYWORD_SELECT = "select"; //$NON-NLS-1$
- String KEYWORD_SET = "set"; //$NON-NLS-1$
- String KEYWORD_TRAVERSE = "traverse"; //$NON-NLS-1$
- String KEYWORD_UNION = "union"; //$NON-NLS-1$
- String KEYWORD_UNIQUE = "unique"; //$NON-NLS-1$
-
- String OPERATOR_ARRAY = "[]"; //$NON-NLS-1$
- String OPERATOR_ASSIGN = "="; //$NON-NLS-1$
- String OPERATOR_EACH = "_"; //$NON-NLS-1$
- String OPERATOR_ELSE = ":"; //$NON-NLS-1$
- String OPERATOR_IF = "?"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Intersect.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Intersect.java
deleted file mode 100644
index db6b81a5f..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Intersect.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * n-ary <code>intersect</code> operator. The result is the set of elements that were found in all operands.
- */
-final class Intersect extends Binary implements IQLConstants, IQLExpression {
- Intersect(Expression operand, Expression param) {
- super(operand, param);
- }
-
- public Object evaluate(IEvaluationContext context) {
- return evaluateAsIterator(context);
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- Set<?> resultSet = QLUtil.asSet(lhs.evaluate(context), false); // Safe since it will not be modified
- Iterator<?> itor = rhs.evaluateAsIterator(context);
- Set<Object> retained = new HashSet<Object>();
- while (itor.hasNext()) {
- Object value = itor.next();
- if (resultSet.contains(value))
- retained.add(value);
- }
- return RepeatableIterator.create(retained);
- }
-
- public int getExpressionType() {
- return TYPE_INTERSECT;
- }
-
- public String getOperator() {
- return KEYWORD_INTERSECT;
- }
-
- public int getPriority() {
- return PRIORITY_COLLECTION;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Latest.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Latest.java
deleted file mode 100644
index b5c6c720e..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Latest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.IVersionedId;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-
-/**
- * An expression that is especially targeted towards {@link IVersionedId} instances. It will
- * reject any objects that is not an <code>IVersionedId</code> and it will ensure that the
- * resulting iterator only iterates over the latest version of any found id.
- */
-final class Latest extends UnaryCollectionFilter {
-
- Latest(Expression collection) {
- super(collection);
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- HashMap<String, IVersionedId> greatestIUVersion;
- if (operand instanceof Select) {
- // Inline element evaluation here so that we don't build a map that is
- // larger then it has to be
- Select select = (Select) operand;
- Iterator<?> iterator = select.operand.evaluateAsIterator(context);
- if (!iterator.hasNext())
- return Collections.EMPTY_SET.iterator();
-
- greatestIUVersion = new HashMap<String, IVersionedId>();
- LambdaExpression lambda = select.lambda;
- context = lambda.prolog(context);
- Variable variable = lambda.getItemVariable();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (!(next instanceof IVersionedId))
- continue;
-
- variable.setValue(context, next);
- if (lambda.evaluate(context) != Boolean.TRUE)
- continue;
-
- IVersionedId versionedID = (IVersionedId) next;
- String id = versionedID.getId();
- IVersionedId prev = greatestIUVersion.put(id, versionedID);
- if (prev == null)
- continue;
- if (prev.getVersion().compareTo(versionedID.getVersion()) > 0)
- greatestIUVersion.put(id, prev);
- }
- } else {
- Iterator<?> iterator = operand.evaluateAsIterator(context);
- if (iterator == null)
- return null;
- if (!iterator.hasNext())
- return Collections.EMPTY_SET.iterator();
-
- greatestIUVersion = new HashMap<String, IVersionedId>();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (!(next instanceof IVersionedId))
- continue;
-
- IVersionedId versionedID = (IVersionedId) next;
- String id = versionedID.getId();
-
- IVersionedId prev = greatestIUVersion.put(id, versionedID);
- if (prev == null)
- continue;
-
- if (prev.getVersion().compareTo(versionedID.getVersion()) > 0)
- greatestIUVersion.put(id, prev);
- }
- }
- return greatestIUVersion.values().iterator();
- }
-
- public int getExpressionType() {
- return TYPE_LATEST;
- }
-
- public String getOperator() {
- return KEYWORD_LATEST;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Limit.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Limit.java
deleted file mode 100644
index 36eb191e4..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Limit.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * A collection filter that limits the number of entries in the collection
- */
-final class Limit extends Binary implements IQLConstants, IQLExpression {
-
- /**
- * An iterator that stops iterating after a given number of iterations.
- */
- static final class CountingIterator<T> implements Iterator<T> {
- private final Iterator<? extends T> innerIterator;
- private int counter;
-
- public CountingIterator(Iterator<? extends T> iterator, int count) {
- this.innerIterator = iterator;
- this.counter = count;
- }
-
- public boolean hasNext() {
- return counter > 0 && innerIterator.hasNext();
- }
-
- public T next() {
- if (counter > 0) {
- --counter;
- return innerIterator.next();
- }
- throw new NoSuchElementException();
- }
-
- public void remove() {
- innerIterator.remove();
- }
- }
-
- Limit(Expression operand, Expression param) {
- super(operand, param);
- }
-
- Limit(Expression operand, int limit) {
- this(operand, (Expression) QLFactory.INSTANCE.constant(new Integer(limit)));
- }
-
- public Object evaluate(IEvaluationContext context) {
- return evaluateAsIterator(context);
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- Object rval = rhs.evaluate(context);
- int limit = -1;
- if (rval instanceof Integer)
- limit = ((Integer) rval).intValue();
- if (limit < 0)
- throw new IllegalArgumentException("limit expression did not evalutate to a positive integer"); //$NON-NLS-1$
- return limit == 0 ? CollectionUtils.emptySet().iterator() : new CountingIterator<Object>(lhs.evaluateAsIterator(context), limit);
- }
-
- public int getExpressionType() {
- return TYPE_LIMIT;
- }
-
- public void toString(StringBuffer bld, Variable rootVariable) {
- CollectionFilter.appendProlog(bld, rootVariable, lhs, getOperator());
- appendOperand(bld, rootVariable, rhs, IExpressionConstants.PRIORITY_COMMA);
- bld.append(')');
- }
-
- public String getOperator() {
- return KEYWORD_LIMIT;
- }
-
- public int getPriority() {
- return PRIORITY_COLLECTION;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Pipe.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Pipe.java
deleted file mode 100644
index 8dcd8c6f7..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Pipe.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.KeyWithLocale;
-import org.eclipse.equinox.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.index.IIndex;
-import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-import org.eclipse.equinox.p2.ql.IQLFactory;
-
-public class Pipe extends NAry implements IQLExpression {
-
- private class NoIndexProvider implements IIndexProvider<Object> {
- private final IIndexProvider<?> indexProvider;
- private Iterator<Object> everything;
-
- NoIndexProvider(IIndexProvider<?> indexProvider) { //
- this.indexProvider = indexProvider;
- }
-
- public IIndex<Object> getIndex(String memberName) {
- return null;
- }
-
- public Iterator<Object> everything() {
- return everything;
- }
-
- public Object getManagedProperty(Object client, String memberName, Object key) {
- if (indexProvider != null)
- return indexProvider.getManagedProperty(client, memberName, key);
- if (client instanceof IInstallableUnit && memberName.equals(InstallableUnit.MEMBER_TRANSLATED_PROPERTIES)) {
- IInstallableUnit iu = (IInstallableUnit) client;
- return key instanceof KeyWithLocale ? iu.getProperty(((KeyWithLocale) key).getKey()) : iu.getProperty(key.toString());
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- void setEverything(Iterator<?> everything) {
- this.everything = (Iterator<Object>) everything;
- }
- }
-
- public static Expression createPipe(Expression[] operands) {
- // We expect two types of expressions. The ones that act on THIS
- // i.e. boolean match expressions or the ones that act EVERYTHING
- // by iterating a collection.
- //
- // Our task here is to convert all booleans into collections so
- // that:
- // <boolean expression> becomes select(x | <boolean expression)
- //
- // If we find consecutive boolean expressions, we can actually
- // make one more optimization:
- // <expr1>, <expr2> becomes select(x | <expr1> && <expr2>)
-
- IQLFactory factory = (IQLFactory) ExpressionUtil.getFactory();
- ArrayList<Expression> pipeables = new ArrayList<Expression>();
- ArrayList<Expression> booleans = new ArrayList<Expression>();
- VariableFinder finder = new VariableFinder(ExpressionFactory.EVERYTHING);
- for (int idx = 0; idx < operands.length; ++idx) {
- Expression operand = operands[idx];
- finder.reset();
- operand.accept(finder);
- if (finder.isFound()) {
- if (!booleans.isEmpty()) {
- // Concatenate all found booleans.
- pipeables.add(makePipeableOfBooleans(factory, booleans));
- booleans.clear();
- }
- pipeables.add(operand);
- } else
- booleans.add(operand);
- }
-
- if (!booleans.isEmpty()) {
- if (pipeables.isEmpty())
- return normalizeBoolean(factory, booleans);
- pipeables.add(makePipeableOfBooleans(factory, booleans));
- }
- int top = pipeables.size();
- if (top > 1)
- return new Pipe(pipeables.toArray(new Expression[top]));
- return (top == 1) ? pipeables.get(0) : Literal.TRUE_CONSTANT;
- }
-
- private static Expression normalizeBoolean(IExpressionFactory factory, ArrayList<Expression> booleans) {
- int top = booleans.size();
- Expression boolExpr;
- if (top > 1)
- boolExpr = (Expression) factory.and(booleans.toArray(new IExpression[top]));
- else if (top == 1)
- boolExpr = booleans.get(0);
- else
- boolExpr = Literal.TRUE_CONSTANT;
- return boolExpr;
- }
-
- private static Expression makePipeableOfBooleans(IQLFactory factory, ArrayList<Expression> booleans) {
- Expression boolExpr = normalizeBoolean(factory, booleans);
- return (Expression) factory.select(ExpressionFactory.EVERYTHING, factory.lambda(ExpressionFactory.THIS, boolExpr));
- }
-
- private Pipe(Expression[] operands) {
- super(operands);
- }
-
- public int getExpressionType() {
- return TYPE_PIPE;
- }
-
- @Override
- public String getOperator() {
- return "pipe"; //$NON-NLS-1$
- }
-
- @Override
- public Object evaluate(IEvaluationContext context) {
- return evaluateAsIterator(context);
- }
-
- @Override
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- Iterator<?> iterator = operands[0].evaluateAsIterator(context);
- if (operands.length == 0 || !iterator.hasNext())
- return iterator;
-
- Class<Object> elementClass = Object.class;
- Variable everything = ExpressionFactory.EVERYTHING;
- IEvaluationContext nextContext = EvaluationContext.create(context, everything);
- NoIndexProvider noIndexProvider = new NoIndexProvider(context.getIndexProvider());
- nextContext.setIndexProvider(noIndexProvider);
- for (int idx = 1; idx < operands.length; ++idx) {
- Expression expr = operands[idx];
- noIndexProvider.setEverything(iterator);
- everything.setValue(nextContext, new Everything<Object>(elementClass, noIndexProvider));
- iterator = expr.evaluateAsIterator(nextContext);
- if (!iterator.hasNext())
- break;
- }
- return iterator;
- }
-
- @Override
- public int getPriority() {
- return PRIORITY_COLLECTION;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLFactory.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLFactory.java
deleted file mode 100644
index a238ed7dd..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLFactory.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IExpression;
-import org.eclipse.equinox.p2.ql.IQLFactory;
-import org.eclipse.equinox.p2.query.IQuery;
-
-public class QLFactory extends ExpressionFactory implements IQLFactory, IQLConstants {
- @SuppressWarnings("hiding")
- public static final IQLFactory INSTANCE = new QLFactory();
-
- protected static final Map<String, Constructor<?>> functionMap;
-
- static {
- Class<?>[] args = new Class[] {Expression[].class};
- Map<String, Constructor<?>> f = new HashMap<String, Constructor<?>>();
- try {
- f.put(KEYWORD_BOOLEAN, BooleanFunction.class.getConstructor(args));
- f.put(KEYWORD_FILTER, FilterFunction.class.getConstructor(args));
- f.put(KEYWORD_VERSION, VersionFunction.class.getConstructor(args));
- f.put(KEYWORD_RANGE, RangeFunction.class.getConstructor(args));
- f.put(KEYWORD_CLASS, ClassFunction.class.getConstructor(args));
- f.put(KEYWORD_SET, SetFunction.class.getConstructor(args));
- f.put(KEYWORD_IQUERY, WrappedIQuery.class.getConstructor(args));
- functionMap = Collections.unmodifiableMap(f);
- } catch (Exception e) {
- throw new ExceptionInInitializerError(e);
- }
- }
-
- public IExpression intersect(IExpression c1, IExpression c2) {
- return new Intersect((Expression) c1, (Expression) c2);
- }
-
- public IExpression array(IExpression... operands) {
- return new Array(convertArray(operands));
- }
-
- public IExpression assignment(IExpression variable, IExpression expression) {
- return new Assignment((Variable) variable, (Expression) expression);
- }
-
- public IExpression collect(IExpression collection, IExpression lambda) {
- return new Collect((Expression) collection, (LambdaExpression) lambda);
- }
-
- public IExpression condition(IExpression test, IExpression ifTrue, IExpression ifFalse) {
- return new Condition((Expression) test, (Expression) ifTrue, (Expression) ifFalse);
- }
-
- public IExpression first(IExpression collection, IExpression lambda) {
- return new First((Expression) collection, (LambdaExpression) lambda);
- }
-
- public IExpression flatten(IExpression collection) {
- return new Flatten((Expression) collection);
- }
-
- public IExpression function(Object function, IExpression... args) {
- try {
- return (IExpression) ((Constructor<?>) function).newInstance(new Object[] {convertArray(args)});
- } catch (IllegalArgumentException e) {
- throw e;
- } catch (InvocationTargetException e) {
- Throwable t = e.getCause();
- if (t instanceof RuntimeException)
- throw (RuntimeException) t;
- throw new RuntimeException(t);
- } catch (InstantiationException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- public Map<String, ? extends Object> getFunctionMap() {
- return functionMap;
- }
-
- public IExpression lambda(IExpression variable, IExpression[] assignments, IExpression body) {
- if (assignments.length == 0)
- return super.lambda(variable, body);
- Assignment[] asgns = new Assignment[assignments.length];
- System.arraycopy(assignments, 0, asgns, 0, assignments.length);
- return new CurryedLambdaExpression((Variable) variable, asgns, (Expression) body);
- }
-
- public IExpression latest(IExpression collection) {
- return new Latest((Expression) collection);
- }
-
- public IExpression limit(IExpression collection, int count) {
- return new Limit((Expression) collection, Literal.create(new Integer(count)));
- }
-
- public IExpression limit(IExpression collection, IExpression limit) {
- return new Limit((Expression) collection, (Expression) limit);
- }
-
- public IExpression memberCall(IExpression target, String name, IExpression... args) {
- if (args.length == 0)
- return member(target, name);
-
- Expression[] eargs = convertArray(args);
-
- // Insert functions that takes arguments here
-
- //
- StringBuffer bld = new StringBuffer();
- bld.append("Don't know how to do a member call with "); //$NON-NLS-1$
- bld.append(name);
- bld.append('(');
- Expression.elementsToString(bld, null, eargs);
- bld.append(')');
- throw new IllegalArgumentException(bld.toString());
- }
-
- public IExpression union(IExpression c1, IExpression c2) {
- return new Union((Expression) c1, (Expression) c2);
- }
-
- public IExpression pipe(IExpression... operands) {
- return Pipe.createPipe(convertArray(operands));
- }
-
- public IExpression select(IExpression collection, IExpression lambda) {
- return new Select((Expression) collection, (LambdaExpression) lambda);
- }
-
- public IExpression traverse(IExpression collection, IExpression lambda) {
- return new Traverse((Expression) collection, (LambdaExpression) lambda);
- }
-
- public IExpression toExpression(IQuery<?> query) {
- Literal queryConstant = Literal.create(query);
- return new WrappedIQuery(new Expression[] {queryConstant});
- }
-
- public IExpression unique(IExpression collection, IExpression cache) {
- return new Unique((Expression) collection, (Expression) cache);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLUtil.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLUtil.java
deleted file mode 100644
index 0c2d098ca..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLUtil.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-
-import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IExpression;
-import org.eclipse.equinox.p2.metadata.expression.IExpressionVisitor;
-import org.eclipse.equinox.p2.query.IQueryResult;
-
-/**
- * The base class of the expression tree.
- */
-public abstract class QLUtil implements IExpression, IQLConstants {
-
- static Set<?> asSet(Object val, boolean forcePrivateCopy) {
- if (val == null)
- throw new IllegalArgumentException("Cannot convert null into an set"); //$NON-NLS-1$
-
- if (val instanceof IRepeatableIterator<?>) {
- Object provider = ((IRepeatableIterator<?>) val).getIteratorProvider();
- if (!forcePrivateCopy) {
- if (provider instanceof Set<?>)
- return (Set<?>) provider;
- if (provider instanceof IQueryResult<?>)
- return ((IQueryResult<?>) provider).toUnmodifiableSet();
- }
-
- if (provider instanceof Collection<?>)
- val = provider;
- } else {
- if (!forcePrivateCopy) {
- if (val instanceof Set<?>)
- return (Set<?>) val;
- if (val instanceof IQueryResult<?>)
- return ((IQueryResult<?>) val).toUnmodifiableSet();
- }
- }
-
- HashSet<Object> result;
- if (val instanceof Collection<?>)
- result = new HashSet<Object>((Collection<?>) val);
- else {
- result = new HashSet<Object>();
- Iterator<?> iterator = RepeatableIterator.create(val);
- while (iterator.hasNext())
- result.add(iterator.next());
- }
- return result;
- }
-
- private static class TranslationSupportFinder implements IExpressionVisitor {
- private boolean found;
-
- TranslationSupportFinder() { //
- }
-
- public boolean visit(IExpression expression) {
- if (expression.getExpressionType() == TYPE_MEMBER && InstallableUnit.MEMBER_TRANSLATED_PROPERTIES.equals(((Member) expression).getName()))
- found = true;
- return !found;
- }
-
- boolean isFound() {
- return found;
- }
- }
-
- /**
- * Checks if the expression will make repeated requests for the 'everything' iterator.
- * @return <code>true</code> if repeated requests will be made, <code>false</code> if not.
- */
- public static boolean needsTranslationSupport(IExpression expression) {
- TranslationSupportFinder tsFinder = new TranslationSupportFinder();
- ((Expression) expression).accept(tsFinder);
- return tsFinder.isFound();
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/RangeFunction.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/RangeFunction.java
deleted file mode 100644
index 6733f73f9..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/RangeFunction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.expression.Expression;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
-/**
- * A function that creates a {@link VersionRange} from a String
- */
-public final class RangeFunction extends Function {
-
- public RangeFunction(Expression[] operands) {
- super(assertLength(operands, 1, 1, KEYWORD_RANGE));
- }
-
- boolean assertSingleArgumentClass(Object v) {
- return v instanceof String;
- }
-
- Object createInstance(Object arg) {
- return new VersionRange((String) arg);
- }
-
- public String getOperator() {
- return KEYWORD_RANGE;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Select.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Select.java
deleted file mode 100644
index 300d8d390..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Select.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * An expression that yields a new collection consisting of all elements of the
- * <code>collection</code> for which the <code>filter</code> yields <code>true</code>.
- */
-final class Select extends CollectionFilter implements IQLExpression {
- Select(Expression collection, LambdaExpression lambda) {
- super(collection, lambda);
- }
-
- protected Object evaluate(IEvaluationContext context, Iterator<?> itor) {
- return evaluateAsIterator(context, itor);
- }
-
- protected Iterator<?> evaluateAsIterator(final IEvaluationContext context, Iterator<?> itor) {
- return new MatchIteratorFilter<Object>(itor) {
- protected boolean isMatch(Object val) {
- lambda.getItemVariable().setValue(context, val);
- return lambda.evaluate(context) == Boolean.TRUE;
- }
- };
- }
-
- public int getExpressionType() {
- return TYPE_SELECT;
- }
-
- public String getOperator() {
- return IQLConstants.KEYWORD_SELECT;
- }
-
- boolean isCollection() {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/SetFunction.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/SetFunction.java
deleted file mode 100644
index f83275631..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/SetFunction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.HashSet;
-import org.eclipse.equinox.internal.p2.metadata.expression.Expression;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-
-public final class SetFunction extends Function implements IQLConstants {
-
- public SetFunction(Expression[] operands) {
- super(operands);
- }
-
- public Object evaluate(IEvaluationContext context) {
- HashSet<Object> result = new HashSet<Object>();
- for (int idx = 0; idx < operands.length; ++idx)
- result.add(operands[idx].evaluate(context));
- return result;
- }
-
- public String getOperator() {
- return KEYWORD_SET;
- }
-
- boolean isCollection() {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Traverse.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Traverse.java
deleted file mode 100644
index e8b0c0489..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Traverse.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * An expression that will collect items recursively based on a <code>rule</code>.
- * The <code>rule</code> is applied for each item in the <code>collection</code> and
- * is supposed to create a new collection. The <code>rule</code> is then applied for each item
- * in the new collection. All items are collected into a set and items that are already
- * in that set will not be perused again. The set becomes the result of the traversal.
- */
-final class Traverse extends CollectionFilter implements IQLExpression {
-
- Traverse(Expression collection, LambdaExpression lambda) {
- super(collection, lambda);
- }
-
- public Object evaluate(IEvaluationContext context, Iterator<?> itor) {
- return evaluateAsIterator(context, itor);
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context, Iterator<?> iterator) {
- HashSet<Object> collector = new HashSet<Object>();
- while (iterator.hasNext())
- traverse(collector, iterator.next(), context);
- return collector.iterator();
- }
-
- public int getExpressionType() {
- return TYPE_TRAVERSE;
- }
-
- public String getOperator() {
- return IQLConstants.KEYWORD_TRAVERSE;
- }
-
- void traverse(Set<Object> collector, Object parent, IEvaluationContext context) {
- if (collector.add(parent)) {
- Variable variable = lambda.getItemVariable();
- context = EvaluationContext.create(context, variable);
- variable.setValue(context, parent);
- Iterator<?> subIterator = lambda.evaluateAsIterator(context);
- while (subIterator.hasNext())
- traverse(collector, subIterator.next(), context);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/UnaryCollectionFilter.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/UnaryCollectionFilter.java
deleted file mode 100644
index 3de55abc8..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/UnaryCollectionFilter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-abstract class UnaryCollectionFilter extends Unary implements IQLConstants, IQLExpression {
-
- UnaryCollectionFilter(Expression collection) {
- super(collection);
- }
-
- public int hashCode() {
- return 5 * operand.hashCode();
- }
-
- public Object evaluate(IEvaluationContext context) {
- return evaluateAsIterator(context);
- }
-
- public void toString(StringBuffer bld, Variable rootVariable) {
- if (operand instanceof Select) {
- Select select = (Select) operand;
- CollectionFilter.appendProlog(bld, rootVariable, select.operand, getOperator());
- appendOperand(bld, rootVariable, select.lambda, getPriority());
- } else
- CollectionFilter.appendProlog(bld, rootVariable, operand, getOperator());
- bld.append(')');
- }
-
- public int getPriority() {
- return PRIORITY_COLLECTION;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Union.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Union.java
deleted file mode 100644
index df8049a31..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Union.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import java.util.Set;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- */
-final class Union extends Binary implements IQLConstants, IQLExpression {
- Union(Expression operand, Expression param) {
- super(operand, param);
- }
-
- public Object evaluate(IEvaluationContext context) {
- return evaluateAsIterator(context);
- }
-
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- @SuppressWarnings("unchecked")
- Set<Object> resultSet = (Set<Object>) QLUtil.asSet(lhs.evaluate(context), true);
- Iterator<?> itor = rhs.evaluateAsIterator(context);
- while (itor.hasNext())
- resultSet.add(itor.next());
- return RepeatableIterator.create(resultSet);
- }
-
- public int getExpressionType() {
- return TYPE_UNION;
- }
-
- public String getOperator() {
- return KEYWORD_UNION;
- }
-
- public int getPriority() {
- return PRIORITY_COLLECTION;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Unique.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Unique.java
deleted file mode 100644
index 270ac2b5e..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Unique.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * An expression that ensures that the elements of its collection is only returned
- * once throughout the whole query.
- */
-final class Unique extends Binary implements IQLConstants, IQLExpression {
- /**
- * A UniqueIterator that uses a set as a discriminator, ensuring that
- * no element is returned twice.
- */
- static class UniqueIterator<T> extends MatchIteratorFilter<T> {
- final Set<T> uniqueSet;
-
- public UniqueIterator(Iterator<? extends T> iterator, Set<T> uniqueSet) {
- super(iterator);
- this.uniqueSet = uniqueSet;
- }
-
- protected boolean isMatch(T val) {
- synchronized (uniqueSet) {
- return uniqueSet.add(val);
- }
- }
- }
-
- Unique(Expression collection, Expression explicitCache) {
- super(collection, explicitCache);
- }
-
- public Object evaluate(IEvaluationContext context) {
- return evaluateAsIterator(context);
- }
-
- @SuppressWarnings("unchecked")
- public Iterator<?> evaluateAsIterator(IEvaluationContext context) {
- Object explicitCache = rhs.evaluate(context);
- Set<Object> uniqueSet;
- if (explicitCache == null)
- // No cache, we just ensure that the iteration is unique
- uniqueSet = new HashSet<Object>();
- else {
- if (!(explicitCache instanceof Set<?>))
- throw new IllegalArgumentException("Unique cache must be a java.util.Set"); //$NON-NLS-1$
- uniqueSet = (Set<Object>) explicitCache;
- }
- return new UniqueIterator<Object>(lhs.evaluateAsIterator(context), uniqueSet);
- }
-
- public int getExpressionType() {
- return TYPE_UNIQUE;
- }
-
- public void toString(StringBuffer bld, Variable rootVariable) {
- CollectionFilter.appendProlog(bld, rootVariable, lhs, getOperator());
- if (rhs != Literal.NULL_CONSTANT)
- appendOperand(bld, rootVariable, rhs, IExpressionConstants.PRIORITY_COMMA);
- bld.append(')');
- }
-
- public String getOperator() {
- return KEYWORD_UNIQUE;
- }
-
- public int getPriority() {
- return PRIORITY_COLLECTION;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/VersionFunction.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/VersionFunction.java
deleted file mode 100644
index cef9a70b9..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/VersionFunction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.expression.Expression;
-import org.eclipse.equinox.p2.metadata.Version;
-
-/**
- * A function that creates a {@link Version} from a string
- */
-public final class VersionFunction extends Function {
-
- public VersionFunction(Expression[] operands) {
- super(assertLength(operands, 1, 1, KEYWORD_VERSION));
- }
-
- boolean assertSingleArgumentClass(Object v) {
- return v instanceof String;
- }
-
- Object createInstance(Object arg) {
- return Version.create((String) arg);
- }
-
- public String getOperator() {
- return KEYWORD_VERSION;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/WrappedIQuery.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/WrappedIQuery.java
deleted file mode 100644
index b0e6c0b0e..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/WrappedIQuery.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.Iterator;
-import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.query.IMatchQuery;
-import org.eclipse.equinox.p2.query.IQuery;
-
-public final class WrappedIQuery extends Function implements IQLConstants {
-
- /**
- * <p>The WrappedIQuery constructor takes an array with one or two arguments.
- * The first argument must evaluate to an instance of {@link IQuery}. The second
- * argument is optional. The following applies:</p><ul>
- * <li>If first argument evaluates to an instance of {@link IMatchQuery}, then
- * a provided second argument assumed to be the candidate to match. The
- * variable <code>this</code> will be used if no second argument is not provided.</li>
- * <li>For all other types of queries the second argument must evaluate
- * to an iterator. If it is not provided, it defaults to the variable
- * <code>everything</code>.
- * </ul>
- * @param operands
- */
- public WrappedIQuery(Expression[] operands) {
- super(assertLength(operands, 1, 2, KEYWORD_IQUERY));
- }
-
- @SuppressWarnings("unchecked")
- public Object evaluate(IEvaluationContext context) {
- Object query = operands[0].evaluate(context);
-
- if (query instanceof IMatchQuery<?>) {
- Object value = null;
- if (operands.length > 1)
- value = operands[1].evaluate(context);
- else
- value = ExpressionFactory.THIS.evaluate(context);
- return Boolean.valueOf(((IMatchQuery<Object>) query).isMatch(value));
- }
-
- if (!(query instanceof IQuery<?>))
- throw new IllegalArgumentException("iquery first argument must be an IQuery instance"); //$NON-NLS-1$
-
- Iterator<?> iterator = null;
- if (operands.length > 1)
- iterator = operands[1].evaluateAsIterator(context);
- else
- iterator = ExpressionFactory.EVERYTHING.evaluateAsIterator(context);
-
- return ((IQuery<Object>) query).perform((Iterator<Object>) iterator);
- }
-
- public String getOperator() {
- return KEYWORD_IQUERY;
- }
-
- @Override
- public boolean isReferenceTo(Variable variable) {
- Object firstOp = operands[0];
- if (firstOp instanceof Literal) {
- Object query = ((Literal) firstOp).value;
- return (query instanceof IMatchQuery<?>) ? variable == ExpressionFactory.THIS : variable == ExpressionFactory.EVERYTHING;
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/parser/QLParser.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/parser/QLParser.java
deleted file mode 100644
index c9bc6a4f8..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/parser/QLParser.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.parser;
-
-import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.expression.Variable;
-import org.eclipse.equinox.internal.p2.metadata.expression.parser.ExpressionParser;
-import org.eclipse.equinox.internal.p2.ql.expression.IQLConstants;
-import org.eclipse.equinox.p2.metadata.expression.IExpression;
-import org.eclipse.equinox.p2.metadata.expression.IExpressionFactory;
-import org.eclipse.equinox.p2.ql.IQLFactory;
-
-public class QLParser extends ExpressionParser implements IQLConstants {
- private static final long serialVersionUID = 882034383978853143L;
-
- private static final int TOKEN_ANY = 42;
-
- private static final int TOKEN_LATEST = 70;
- private static final int TOKEN_LIMIT = 71;
- private static final int TOKEN_FIRST = 72;
- private static final int TOKEN_FLATTEN = 73;
- private static final int TOKEN_UNIQUE = 74;
- private static final int TOKEN_SELECT = 75;
- private static final int TOKEN_COLLECT = 76;
- private static final int TOKEN_TRAVERSE = 77;
- private static final int TOKEN_INTERSECT = 78;
- private static final int TOKEN_UNION = 79;
-
- private static final Map<String, Integer> qlKeywords;
- static {
- qlKeywords = new HashMap<String, Integer>();
- qlKeywords.putAll(keywords);
- qlKeywords.put(KEYWORD_COLLECT, new Integer(TOKEN_COLLECT));
- qlKeywords.put(KEYWORD_FALSE, new Integer(TOKEN_FALSE));
- qlKeywords.put(KEYWORD_FIRST, new Integer(TOKEN_FIRST));
- qlKeywords.put(KEYWORD_FLATTEN, new Integer(TOKEN_FLATTEN));
- qlKeywords.put(KEYWORD_LATEST, new Integer(TOKEN_LATEST));
- qlKeywords.put(KEYWORD_LIMIT, new Integer(TOKEN_LIMIT));
- qlKeywords.put(KEYWORD_NULL, new Integer(TOKEN_NULL));
- qlKeywords.put(KEYWORD_SELECT, new Integer(TOKEN_SELECT));
- qlKeywords.put(KEYWORD_TRAVERSE, new Integer(TOKEN_TRAVERSE));
- qlKeywords.put(KEYWORD_TRUE, new Integer(TOKEN_TRUE));
- qlKeywords.put(KEYWORD_UNIQUE, new Integer(TOKEN_UNIQUE));
- qlKeywords.put(KEYWORD_INTERSECT, new Integer(TOKEN_INTERSECT));
- qlKeywords.put(KEYWORD_UNION, new Integer(TOKEN_UNION));
- qlKeywords.put(OPERATOR_EACH, new Integer(TOKEN_ANY));
- }
-
- protected Map<String, Integer> keywordToTokenMap() {
- return qlKeywords;
- }
-
- protected IExpression parseCondition() {
- IExpression expr = parseOr();
- if (currentToken == TOKEN_IF) {
- nextToken();
- IExpression ifTrue = parseOr();
- assertToken(TOKEN_ELSE);
- nextToken();
- expr = qlFactory().condition(expr, ifTrue, parseOr());
- }
- return expr;
- }
-
- protected IExpression parseMember() {
- IExpression expr = parseFunction();
- String name;
- while (currentToken == TOKEN_DOT || currentToken == TOKEN_LB) {
- int savePos = tokenPos;
- int saveToken = currentToken;
- Object saveTokenValue = tokenValue;
- nextToken();
- if (saveToken == TOKEN_DOT) {
- switch (currentToken) {
- case TOKEN_IDENTIFIER :
- name = (String) tokenValue;
- nextToken();
- if (currentToken == TOKEN_LP) {
- nextToken();
- IExpression[] callArgs = parseArray();
- assertToken(TOKEN_RP);
- nextToken();
- expr = qlFactory().memberCall(expr, name, callArgs);
- } else
- expr = factory.member(expr, name);
- break;
-
- default :
- tokenPos = savePos;
- currentToken = saveToken;
- tokenValue = saveTokenValue;
- return expr;
- }
- } else {
- IExpression atExpr = parseMember();
- assertToken(TOKEN_RB);
- nextToken();
- expr = factory.at(expr, atExpr);
- }
- }
- return expr;
- }
-
- protected IExpression parseFunction() {
- if (currentToken == TOKEN_IDENTIFIER) {
- Object function = qlFactory().getFunctionMap().get(tokenValue);
- if (function != null) {
- int savePos = tokenPos;
- int saveToken = currentToken;
- Object saveTokenValue = tokenValue;
-
- nextToken();
- if (currentToken == TOKEN_LP) {
- nextToken();
- IExpression[] args = currentToken == TOKEN_RP ? IExpressionFactory.NO_ARGS : parseArray();
- assertToken(TOKEN_RP);
- nextToken();
- return qlFactory().function(function, args);
- }
- tokenPos = savePos;
- currentToken = saveToken;
- tokenValue = saveTokenValue;
- }
- }
- return parseUnary();
- }
-
- protected IQLFactory qlFactory() {
- return (IQLFactory) factory;
- }
-
- protected IExpression parseCollectionLHS() {
- IExpression expr;
- switch (currentToken) {
- case TOKEN_SELECT :
- case TOKEN_COLLECT :
- case TOKEN_FIRST :
- case TOKEN_FLATTEN :
- case TOKEN_TRAVERSE :
- case TOKEN_LATEST :
- case TOKEN_LIMIT :
- case TOKEN_INTERSECT :
- case TOKEN_UNION :
- case TOKEN_UNIQUE :
- expr = getVariableOrRootMember(rootVariable);
- break;
- default :
- expr = super.parseCollectionLHS();
- }
- return expr;
- }
-
- protected IExpression parseCollectionRHS(IExpression expr, int funcToken) {
- switch (funcToken) {
- case TOKEN_SELECT :
- expr = qlFactory().select(expr, parseLambdaDefinition());
- break;
- case TOKEN_COLLECT :
- expr = qlFactory().collect(expr, parseLambdaDefinition());
- break;
- case TOKEN_FIRST :
- expr = qlFactory().first(expr, parseLambdaDefinition());
- break;
- case TOKEN_TRAVERSE :
- expr = qlFactory().traverse(expr, parseLambdaDefinition());
- break;
- case TOKEN_LATEST :
- if (currentToken == TOKEN_RP) {
- expr = qlFactory().latest(expr);
- assertToken(TOKEN_RP);
- nextToken();
- } else
- expr = qlFactory().latest(qlFactory().select(expr, parseLambdaDefinition()));
- break;
- case TOKEN_FLATTEN :
- if (currentToken == TOKEN_RP) {
- expr = qlFactory().flatten(expr);
- assertToken(TOKEN_RP);
- nextToken();
- } else
- expr = qlFactory().flatten(qlFactory().select(expr, parseLambdaDefinition()));
- break;
- case TOKEN_LIMIT :
- expr = qlFactory().limit(expr, parseCondition());
- assertToken(TOKEN_RP);
- nextToken();
- break;
- case TOKEN_INTERSECT :
- expr = qlFactory().intersect(expr, parseCondition());
- assertToken(TOKEN_RP);
- nextToken();
- break;
- case TOKEN_UNION :
- expr = qlFactory().union(expr, parseCondition());
- assertToken(TOKEN_RP);
- nextToken();
- break;
- case TOKEN_UNIQUE :
- if (currentToken == TOKEN_RP)
- expr = qlFactory().unique(expr, factory.constant(null));
- else {
- expr = qlFactory().unique(expr, parseMember());
- assertToken(TOKEN_RP);
- nextToken();
- }
- break;
- default :
- expr = super.parseCollectionRHS(expr, funcToken);
- }
- return expr;
- }
-
- protected IExpression parseUnary() {
- IExpression expr;
- switch (currentToken) {
- case TOKEN_LB :
- nextToken();
- expr = qlFactory().array(parseArray());
- assertToken(TOKEN_RB);
- nextToken();
- break;
- case TOKEN_ANY :
- expr = factory.variable(IQLConstants.OPERATOR_EACH);
- nextToken();
- break;
- default :
- expr = super.parseUnary();
- }
- return expr;
- }
-
- protected IExpression parseLambdaDefinition() {
- boolean endingRC = false;
- int anyIndex = -1;
- IExpression[] initializers = IExpressionFactory.NO_ARGS;
- IExpression[] variables;
- if (currentToken == TOKEN_LC) {
- // Lambda starts without currying.
- endingRC = true;
- nextToken();
- anyIndex = 0;
- variables = parseVariables();
- if (variables == null)
- // empty means no pipe at the end.
- throw syntaxError();
- } else {
- anyIndex = 0;
- variables = parseVariables();
- if (variables == null) {
- anyIndex = -1;
- initializers = parseArray();
- assertToken(TOKEN_LC);
- nextToken();
- endingRC = true;
- for (int idx = 0; idx < initializers.length; ++idx) {
- IExpression initializer = initializers[idx];
- if (initializer instanceof Variable && IQLConstants.OPERATOR_EACH.equals(initializer.toString())) {
- if (anyIndex == -1)
- anyIndex = idx;
- else
- anyIndex = -1; // Second Each. This is illegal
- break;
- }
- }
- if (anyIndex == -1)
- throw new IllegalArgumentException("Exaclty one _ must be present among the currying expressions"); //$NON-NLS-1$
-
- variables = parseVariables();
- if (variables == null)
- // empty means no pipe at the end.
- throw syntaxError();
- }
-
- }
- nextToken();
- IExpression body = parseCondition();
- if (endingRC) {
- assertToken(TOKEN_RC);
- nextToken();
- }
-
- assertToken(TOKEN_RP);
- nextToken();
- IExpression each;
- IExpression[] assignments;
- IQLFactory qlFactory = qlFactory();
- if (initializers.length == 0) {
- if (variables.length != 1)
- throw new IllegalArgumentException("Must have exactly one variable unless currying is used"); //$NON-NLS-1$
- each = variables[0];
- assignments = IExpressionFactory.NO_ARGS;
- } else {
- if (initializers.length != variables.length)
- throw new IllegalArgumentException("Number of currying expressions and variables differ"); //$NON-NLS-1$
-
- if (initializers.length == 1) {
- // This is just a map from _ to some variable
- each = variables[0];
- assignments = IExpressionFactory.NO_ARGS;
- } else {
- int idx;
- each = variables[anyIndex];
- assignments = new IExpression[initializers.length - 1];
- for (idx = 0; idx < anyIndex; ++idx)
- assignments[idx] = qlFactory.assignment(variables[idx], initializers[idx]);
- for (++idx; idx < initializers.length; ++idx)
- assignments[idx] = qlFactory.assignment(variables[idx], initializers[idx]);
- }
- }
- return qlFactory.lambda(each, assignments, body);
- }
-
- private IExpression[] parseVariables() {
- int savePos = tokenPos;
- int saveToken = currentToken;
- Object saveTokenValue = tokenValue;
- List<Object> ids = null;
- while (currentToken == TOKEN_IDENTIFIER) {
- if (ids == null)
- ids = new ArrayList<Object>();
- ids.add(tokenValue);
- nextToken();
- if (currentToken == TOKEN_COMMA) {
- nextToken();
- continue;
- }
- break;
- }
-
- if (currentToken != TOKEN_PIPE) {
- // This was not a variable list
- tokenPos = savePos;
- currentToken = saveToken;
- tokenValue = saveTokenValue;
- return null;
- }
-
- if (ids == null)
- // Empty list but otherwise OK
- return IExpressionFactory.NO_ARGS;
-
- int top = ids.size();
- IExpression[] result = new IExpression[top];
- for (int idx = 0; idx < top; ++idx) {
- String name = (String) ids.get(idx);
- IExpression var = factory.variable(name);
- push(var);
- result[idx] = var;
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLExpression.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLExpression.java
index b53bd6941..60b277ccb 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLExpression.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLExpression.java
@@ -18,19 +18,5 @@ import org.eclipse.equinox.p2.metadata.expression.IExpression;
* @since 2.0
*/
public interface IQLExpression extends IExpression {
- int TYPE_ARRAY = 20;
- int TYPE_ASSIGNMENT = 21;
- int TYPE_COLLECT = 22;
- int TYPE_CONDITION = 23;
- int TYPE_FIRST = 24;
- int TYPE_FLATTEN = 25;
- int TYPE_FUNCTION = 26;
- int TYPE_INTERSECT = 27;
- int TYPE_LATEST = 28;
- int TYPE_LIMIT = 29;
- int TYPE_PIPE = 30;
- int TYPE_SELECT = 31;
- int TYPE_TRAVERSE = 32;
- int TYPE_UNION = 33;
- int TYPE_UNIQUE = 34;
+ //
}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLFactory.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLFactory.java
index cc89e2da0..b87c00959 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLFactory.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IQLFactory.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ql;
-import java.util.Map;
-import org.eclipse.equinox.p2.metadata.expression.IExpression;
import org.eclipse.equinox.p2.metadata.expression.IExpressionFactory;
/**
@@ -19,117 +17,5 @@ import org.eclipse.equinox.p2.metadata.expression.IExpressionFactory;
* nodes of the expression tree.
*/
public interface IQLFactory extends IExpressionFactory {
- /**
- * Create an array of elements.
- * @param elements The elements of the array
- * @return An array expression
- */
- IExpression array(IExpression... elements);
-
- /**
- * Creates an expression that represents a variable assignment
- * @param variable The variable
- * @param expression The expression that yields the value to assign to the variable
- * @return An assignment expression
- */
- IExpression assignment(IExpression variable, IExpression expression);
-
- /**
- * Create an expression that collects the result of evaluating each element in a new collection.
- * @param collection The collection providing the elements to evaluate
- * @param lambda The lambda that creates each new element
- * @return A collection expression
- */
- IExpression collect(IExpression collection, IExpression lambda);
-
- /**
- * Create an expression that first evaluates a <code>test</code> and then, depending on the outcome,
- * evaluates either <code>ifTrue</code> or <code>ifFalse</code>. The expression yields the result
- * of the <code>ifTrue</code> or <code>ifFalse</code> evaluation.
- * @param test The test
- * @param ifTrue The code to evaluate when the test evaluates to <code>true</code>
- * @param ifFalse The code to evaluate when the test evaluates to <code>false</code>
- * @return The conditional expression
- */
- IExpression condition(IExpression test, IExpression ifTrue, IExpression ifFalse);
-
- /**
- * Create an expression that yields the first element of the
- * <code>collection</code> for which the <code>lambda</code> yields <code>true</code>.
- * @param collection The collection providing the elements to test
- * @param lambda The lambda that performs the test
- * @return An element expression
- */
- IExpression first(IExpression collection, IExpression lambda);
-
- /**
- * Intended to be applied on collections of collections. Yields a single collection with
- * all elements from the source collections, in the order they are evaluated.
- * @param collection The collection providing the collections that provides all elements
- * @return A collection expression
- */
- IExpression flatten(IExpression collection);
-
- /**
- * Given one of the values in the map returned by {@link #getFunctionMap()}, this method
- * returns a function expression.
- * @param function The value obtained from the map.
- * @param args The arguments to evaluate and pass when evaluating the function.
- * @return A function expression
- */
- IExpression function(Object function, IExpression... args);
-
- /**
- * Returns a map of functions supported by this factory. The map is keyed by
- * function names and the value is an object suitable to pass to the {@link #function(Object, IExpression[])}
- * method.
- * @return A key/function map.
- */
- Map<String, ? extends Object> getFunctionMap();
-
- /**
- * Creates a lambda expression that takes more then one variable (currying). Suitable for use
- * in most collection expressions.
- * @param variable The element variable that the lambda uses
- * @param body The body of the lambda
- * @param initialAssignments Assignments to evaluate once before calling the body for each element.
- * @return A lambda expression with currying
- */
- IExpression lambda(IExpression variable, IExpression[] initialAssignments, IExpression body);
-
- /**
- * Creates a member call expression.
- * @param target The target for the member call
- * @param name The name of the member
- * @param args The arguments to use for the call
- * @return A member expression
- */
- IExpression memberCall(IExpression target, String name, IExpression... args);
-
- /**
- * <p>Recursively traverse and collect elements based on a condition</p>
- * <p>A common scenario in p2 is that you want to start with a set of roots and then find
- * all items that fulfill the root requirements. Those items in turn introduce new
- * requirements so you want to find them too. The process continues until no more
- * requirements can be satisfied. This type of query can be performed using the traverse
- * function.</p>
- * <p>The function will evaluate an expression, once for each element, collect
- * elements for which the evaluation returned true, then then re-evaluate using the
- * collected result as source of elements. No element is evaluated twice. This continues
- * until no more elements are found.</p>
- * @param collection The collection providing the elements to test
- * @param lambda The lambda that collects the children for the next iteration
- * @return A collection expression
- */
- IExpression traverse(IExpression collection, IExpression lambda);
-
- /**
- * Create an expression that yields a new collection where each element is unique. An
- * optional <code>cache</code> can be provided if the uniqueness should span a larger
- * scope then just the source collection.
- * @param collection The source collection
- * @param cache Optional cache to use when uniqueness should span over several invocations
- * @return A collection expression
- */
- IExpression unique(IExpression collection, IExpression cache);
+ //
}

Back to the top