Java Code Examples for org.eclipse.xtext.xbase.XBooleanLiteral#isIsTrue()
The following examples show how to use
org.eclipse.xtext.xbase.XBooleanLiteral#isIsTrue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RichStringEvaluationTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public void acceptElseIfCondition(/* @NonNull */ XExpression condition) { if (!internalIgnore()) { if (printElse.peek()) { XBooleanLiteral literal = (XBooleanLiteral) condition; boolean conditionResult = literal.isIsTrue(); if (conditionResult) { printElse.pop(); printElse.push(Boolean.FALSE); } printNext.pop(); printNext.push(conditionResult); } else { printNext.pop(); printNext.push(Boolean.FALSE); } } }
Example 2
Source File: ShouldExtensions.java From sarl with Apache License 2.0 | 6 votes |
/** Ensure that the given boolean literal is equal to the given value. * * @param actual the boolean literal to test. * @param expected the expected value. * @return the validation status */ public static boolean shouldBe(XBooleanLiteral actual, Object expected) { if (actual == null) { return false; } final Boolean b; if (expected instanceof Boolean) { b = (Boolean) expected; } else { try { b = new Boolean(expected.toString()); } catch (Throwable exception) { return false; } } return b.booleanValue() == actual.isIsTrue(); }
Example 3
Source File: RichStringEvaluationTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public void acceptIfCondition(/* @NonNull */ XExpression condition) { if (ignore()) { ignoreStack.push(Boolean.TRUE); } else { printElse.push(Boolean.TRUE); XBooleanLiteral literal = (XBooleanLiteral) condition; boolean conditionResult = literal.isIsTrue(); if (conditionResult) { printElse.pop(); printElse.push(Boolean.FALSE); } printNext.push(conditionResult); } }
Example 4
Source File: ConstantConditionsInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected EvaluationResult _internalEvaluate(final XBooleanLiteral it, final EvaluationContext context) { boolean _isIsTrue = it.isIsTrue(); return new EvaluationResult(Boolean.valueOf(_isIsTrue), true); }
Example 5
Source File: SARLValidator.java From sarl with Apache License 2.0 | 4 votes |
/** Check the type of the behavior unit's guard. * * @param behaviorUnit the behavior unit. */ @Check(CheckType.FAST) public void checkBehaviorUnitGuardType(SarlBehaviorUnit behaviorUnit) { final XExpression guard = behaviorUnit.getGuard(); if (guard != null) { if (this.operationHelper.hasSideEffects(null, guard)) { error(Messages.SARLValidator_53, guard, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, INVALID_INNER_EXPRESSION); return; } if (guard instanceof XBooleanLiteral) { final XBooleanLiteral booleanLiteral = (XBooleanLiteral) guard; if (booleanLiteral.isIsTrue()) { if (!isIgnored(DISCOURAGED_BOOLEAN_EXPRESSION)) { addIssue(Messages.SARLValidator_54, booleanLiteral, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, DISCOURAGED_BOOLEAN_EXPRESSION); } } else if (!isIgnored(UNREACHABLE_BEHAVIOR_UNIT)) { addIssue(Messages.SARLValidator_55, behaviorUnit, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, UNREACHABLE_BEHAVIOR_UNIT, behaviorUnit.getName().getSimpleName()); } return; } final LightweightTypeReference fromType = getActualType(guard); if (!fromType.isAssignableFrom(Boolean.TYPE)) { error(MessageFormat.format( Messages.SARLValidator_38, getNameOfTypes(fromType), boolean.class.getName()), guard, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, INCOMPATIBLE_TYPES); } } }
Example 6
Source File: XbaseInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 2 votes |
/** * @param context unused in this context but required for dispatching * @param indicator unused in this context but required for dispatching */ protected Object _doEvaluate(XBooleanLiteral literal, IEvaluationContext context, CancelIndicator indicator) { return literal.isIsTrue(); }