private void gatherCheckConstraint(final CheckConstraint check, PatternModelAcceptor<?> acceptor) throws SpecificationBuilderException { XExpression expression = check.getExpression(); acceptor.acceptExpressionEvaluation(expression, null); }
@Check(CheckType.NORMAL) public void checkForImpureJavaCallsInCheckConstraints(CheckConstraint checkConstraint) { checkForImpureJavaCallsInternal(checkConstraint.getExpression(), PatternLanguagePackage.Literals.CHECK_CONSTRAINT__EXPRESSION); }
/** * This validator looks up all variables in the {@link CheckConstraint} and reports an error if one them is not an * {@link EDataType} instance. We do not allow arbitrary EMF elements in, so the checks are less likely to have * side-effects. */ @Check public void checkForWrongVariablesInXExpressions(CheckConstraint checkConstraint) { checkForWrongVariablesInXExpressionsInternal(checkConstraint.getExpression()); } /**
@Check public void checkReturnTypeOfCheckConstraints(CheckConstraint checkConstraint) { XExpression xExpression = checkConstraint.getExpression(); if (xExpression != null) { final IResolvedTypes resolvedType = typeResolver.resolveTypes(xExpression); LightweightTypeReference type = resolvedType.getReturnType(xExpression); if (type.getPrimitiveIfWrapperType().getPrimitiveKind() != Primitive.Boolean) { error("Check expressions must return boolean instead of " + type.getSimpleName(), checkConstraint, PatternLanguagePackage.Literals.CHECK_CONSTRAINT__EXPRESSION, IssueCodes.CHECK_MUST_BE_BOOLEAN); } } }
/** * Contexts: * Constraint returns CheckConstraint * CheckConstraint returns CheckConstraint * * Constraint: * expression=XExpression */ protected void sequence_CheckConstraint(ISerializationContext context, CheckConstraint semanticObject) { if (errorAcceptor != null) { if (transientValues.isValueTransient(semanticObject, PatternLanguagePackage.Literals.CHECK_CONSTRAINT__EXPRESSION) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PatternLanguagePackage.Literals.CHECK_CONSTRAINT__EXPRESSION)); } SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); feeder.accept(grammarAccess.getCheckConstraintAccess().getExpressionXExpressionParserRuleCall_3_0(), semanticObject.getExpression()); feeder.finish(); }
.getReferencedPatternVariablesOfXExpression(checkConstraint.getExpression(), associations));