/** * @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(); }
protected Object _internalEvaluate(final XBooleanLiteral it, final Context ctx) { return Boolean.valueOf(it.isIsTrue()); }
public void _toJavaExpression(XBooleanLiteral expr, ITreeAppendable b) { b.append(Boolean.toString(expr.isIsTrue())); }
protected EvaluationResult _internalEvaluate(final XBooleanLiteral it, final EvaluationContext context) { boolean _isIsTrue = it.isIsTrue(); return new EvaluationResult(Boolean.valueOf(_isIsTrue), true); }
@Override public String caseBoolValue(BoolValue object) { return "Boolean " + Optional.ofNullable(object.getValue()).map(l -> l.isIsTrue() ? "true" : "false").orElse(UNDEFINED); }
/** Append the inline code for the given XBooleanLiteral. * * @param expression the expression of the operation. * @param parentExpression is the expression that contains this one, or {@code null} if the current expression is * the root expression. * @param feature the feature that contains the expression. * @param output the output. * @return {@code true} if a text was appended. */ @SuppressWarnings("static-method") protected Boolean _generate(XBooleanLiteral expression, XExpression parentExpression, XtendExecutable feature, InlineAnnotationTreeAppendable output) { output.appendConstant(Boolean.toString(expression.isIsTrue())); return Boolean.TRUE; }
/** Generate the given object. * * @param literal the boolean literal. * @param it the target for the generated content. * @param context the context. * @return the literal. */ @SuppressWarnings("static-method") protected XExpression _generate(XBooleanLiteral literal, IAppendable it, IExtraLanguageGeneratorContext context) { appendReturnIfExpectedReturnedExpression(it, context); it.append(literal.isIsTrue() ? "True" : "False"); //$NON-NLS-1$ //$NON-NLS-2$ return literal; }
private static boolean isConstantExpression(JvmAnnotationReference reference) { for (final JvmAnnotationValue annotationValue: reference.getValues()) { if ("constantExpression".equals(annotationValue.getValueName())) { if (annotationValue instanceof JvmBooleanAnnotationValue) { return ((JvmBooleanAnnotationValue) annotationValue).getValues().get(0).booleanValue(); } else if (annotationValue instanceof JvmCustomAnnotationValue) { final EObject value = ((JvmCustomAnnotationValue) annotationValue).getValues().get(0); if (value instanceof XBooleanLiteral) { return ((XBooleanLiteral) value).isIsTrue(); } } } } return false; }
/** Convert the boolean constant to the object equivalent if possible. * * @param expression the expression to convert. * @return one of the boolean constants {@link Boolean#TRUE} or {@link Boolean#FALSE}, * or {@code null} if the expression is not a constant boolean expression. */ @SuppressWarnings("static-method") public Boolean toBooleanPrimitiveWrapperConstant(XExpression expression) { if (expression instanceof XBooleanLiteral) { return ((XBooleanLiteral) expression).isIsTrue() ? Boolean.TRUE : Boolean.FALSE; } if (expression instanceof XMemberFeatureCall) { final XMemberFeatureCall call = (XMemberFeatureCall) expression; final XExpression receiver = call.getMemberCallTarget(); if (receiver instanceof XFeatureCall) { final XFeatureCall call2 = (XFeatureCall) receiver; final String call2Identifier = call2.getConcreteSyntaxFeatureName(); if (Boolean.class.getSimpleName().equals(call2Identifier) || Boolean.class.getName().equals(call2Identifier)) { final String callIdentifier = call.getConcreteSyntaxFeatureName(); if ("TRUE".equals(callIdentifier)) { //$NON-NLS-1$ return Boolean.TRUE; } else if ("FALSE".equals(callIdentifier)) { //$NON-NLS-1$ return Boolean.FALSE; } } } } return null; }
@SuppressWarnings("restriction") private static Object getValue(ValueReference ref) { Object value = null; if (ref instanceof BoolValue) { value = ((BoolValue)ref).getValue().isIsTrue(); } else if (ref instanceof NumberValue) { NumberLiterals literals = new NumberLiterals(); XNumberLiteral xLiteral = ((NumberValue)ref).getValue(); value = literals.numberValue(xLiteral, literals.getJavaType(xLiteral)); } else if (ref instanceof StringValue) { value = ((StringValue)ref).getValue(); } else if (ref instanceof VariableReference) { value = new ParameterReference(((VariableReference) ref).getVar()); } else if (ref instanceof ListValue) { value = ((ListValue) ref).getValues().stream().map(PatternLanguageHelper::getValue).collect(Collectors.toList()); } else { throw new UnsupportedOperationException("Unknown attribute parameter type"); } return value; }
if (booleanLiteral.isIsTrue()) { if (!isIgnored(DISCOURAGED_BOOLEAN_EXPRESSION)) { addIssue(Messages.SARLValidator_54,
} else if (guard instanceof XBooleanLiteral) { final XBooleanLiteral literal = (XBooleanLiteral) guard; if (literal.isIsTrue()) { isTrueGuard = true; } else {