Search in sources :

Example 1 with EvaluationResult

use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testIterateExpressionFailure.

public void testIterateExpressionFailure() throws Exception {
    IterateExpression exp = new IterateExpression((String) null);
    EvaluationContext context = new EvaluationContext(null, new Object());
    try {
        EvaluationResult result = exp.evaluate(context);
        fail("Count should've failed for non-Collection variable.  Result = " + result.toString());
    } catch (CoreException e) {
        assertEquals(ExpressionStatus.VARIABLE_IS_NOT_A_COLLECTION, e.getStatus().getCode());
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IterateExpression(org.eclipse.core.internal.expressions.IterateExpression) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 2 with EvaluationResult

use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testAdaptExpressionWithNull.

/**
 * Bug 484325
 */
public void testAdaptExpressionWithNull() throws Exception {
    // it's surprisingly difficult to craft an EvaluationContext that
    // provides
    // a defaultVariable == null
    IEvaluationContext testContext = new EvaluationContext(null, new Adaptee());
    testContext.addVariable("nullCarrier", Arrays.asList((Object) null, (Object) null, (Object) null));
    WithExpression withExpression = new WithExpression("nullCarrier");
    IterateExpression iterateExpression = new IterateExpression("and");
    iterateExpression.add(new AdaptExpression("org.eclipse.core.internal.expressions.tests.NotExisting"));
    withExpression.add(iterateExpression);
    EvaluationResult result = withExpression.evaluate(testContext);
    assertTrue(result == EvaluationResult.FALSE);
}
Also used : IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) IterateExpression(org.eclipse.core.internal.expressions.IterateExpression) WithExpression(org.eclipse.core.internal.expressions.WithExpression) AdaptExpression(org.eclipse.core.internal.expressions.AdaptExpression) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 3 with EvaluationResult

use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testAdaptExpressionAdaptable.

public void testAdaptExpressionAdaptable() throws Exception {
    // $NON-NLS-1$
    AdaptExpression expression = new AdaptExpression("org.eclipse.core.internal.expressions.tests.Adapter");
    // $NON-NLS-1$
    expression.add(new InstanceofExpression("org.eclipse.core.internal.expressions.tests.Adapter"));
    EvaluationResult result = expression.evaluate(new EvaluationContext(null, new AdaptableAdaptee()));
    assertTrue(result == EvaluationResult.TRUE);
}
Also used : InstanceofExpression(org.eclipse.core.internal.expressions.InstanceofExpression) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) AdaptExpression(org.eclipse.core.internal.expressions.AdaptExpression) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 4 with EvaluationResult

use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.

the class EnablementExpression method evaluate.

@Override
public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
    long start = 0;
    if (Expressions.TRACING)
        start = System.currentTimeMillis();
    EvaluationResult result = evaluateAnd(context);
    if (Expressions.TRACING) {
        System.out.println(// $NON-NLS-1$
        "[Enablement Expression] - evaluation time: " + (System.currentTimeMillis() - start) + // $NON-NLS-1$
        " ms.");
    }
    return result;
}
Also used : EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 5 with EvaluationResult

use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.

the class PropertyTesterTests method testPlatformTester.

public void testPlatformTester() throws Exception {
    TestExpression exp = new TestExpression("org.eclipse.core.runtime", "bundleState", new Object[] { "org.eclipse.core.expressions" }, "ACTIVE", false);
    EvaluationContext context = new EvaluationContext(null, Platform.class);
    EvaluationResult result = exp.evaluate(context);
    assertEquals(EvaluationResult.TRUE, result);
}
Also used : TestExpression(org.eclipse.core.internal.expressions.TestExpression) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Aggregations

EvaluationResult (org.eclipse.core.expressions.EvaluationResult)14 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)10 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)8 AdaptExpression (org.eclipse.core.internal.expressions.AdaptExpression)5 InstanceofExpression (org.eclipse.core.internal.expressions.InstanceofExpression)3 CoreException (org.eclipse.core.runtime.CoreException)3 Expression (org.eclipse.core.expressions.Expression)2 IterateExpression (org.eclipse.core.internal.expressions.IterateExpression)2 TestExpression (org.eclipse.core.internal.expressions.TestExpression)2 ActionUI (eu.esdihumboldt.hale.ui.io.action.ActionUI)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 List (java.util.List)1 CountExpression (org.eclipse.core.internal.expressions.CountExpression)1 Property (org.eclipse.core.internal.expressions.Property)1 SystemTestExpression (org.eclipse.core.internal.expressions.SystemTestExpression)1 WithExpression (org.eclipse.core.internal.expressions.WithExpression)1 IEvaluationService (org.eclipse.ui.services.IEvaluationService)1 Bundle (org.osgi.framework.Bundle)1