use of org.eclipse.core.expressions.EvaluationContext in project egit by eclipse.
the class SwitchToMenuTest method mockSelection.
private void mockSelection(ISelection selection) {
EvaluationContext context = new EvaluationContext(null, new Object());
context.addVariable(ISources.ACTIVE_MENU_SELECTION_NAME, selection);
when(handlerService.getCurrentState()).thenReturn(context);
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionWithAdapterManagerIfEmptyTrue.
public void testIterateExpressionWithAdapterManagerIfEmptyTrue() throws Exception {
// $NON-NLS-1$
IterateExpression exp = new IterateExpression("or", "true");
final List<String> input = new ArrayList<>();
CollectionWrapper wrapper = new CollectionWrapper();
wrapper.collection = input;
EvaluationContext context = new EvaluationContext(null, wrapper);
assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testVariableResolver.
public void testVariableResolver() throws Exception {
final Object result = new Object();
IVariableResolver resolver = new IVariableResolver() {
@Override
public Object resolve(String name, Object[] args) throws CoreException {
// $NON-NLS-1$
assertEquals("variable", name);
// $NON-NLS-1$
assertEquals("arg1", args[0]);
assertEquals(Boolean.TRUE, args[1]);
return result;
}
};
EvaluationContext context = new EvaluationContext(null, new Object(), new IVariableResolver[] { resolver });
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue(result == context.resolveVariable("variable", new Object[] { "arg1", Boolean.TRUE }));
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionOrFalse.
public void testIterateExpressionOrFalse() throws Exception {
final List<Object> result = new ArrayList<>();
Expression myExpression = new Expression() {
@Override
public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
result.add(context.getDefaultVariable());
return EvaluationResult.FALSE;
}
};
// $NON-NLS-1$
IterateExpression exp = new IterateExpression("or");
exp.add(myExpression);
List<String> input = new ArrayList<>();
// $NON-NLS-1$
input.add("one");
// $NON-NLS-1$
input.add("two");
EvaluationContext context = new EvaluationContext(null, input);
assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
assertTrue(result.equals(input));
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionAnd_IfEmptyFalse.
public void testIterateExpressionAnd_IfEmptyFalse() throws Exception {
// $NON-NLS-1$
IterateExpression exp = new IterateExpression("and", "false");
List<?> input = new ArrayList<>();
EvaluationContext context = new EvaluationContext(null, input);
assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
}
Aggregations