Search in sources :

Example 1 with XGuardExpression

use of com.avaloq.tools.ddk.check.check.XGuardExpression in project dsl-devkit by dsldevkit.

the class AbstractCheckSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == CheckPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case CheckPackage.CATEGORY:
                sequence_Category(context, (Category) semanticObject);
                return;
            case CheckPackage.CHECK:
                sequence_Check(context, (Check) semanticObject);
                return;
            case CheckPackage.CHECK_CATALOG:
                sequence_CheckCatalog(context, (CheckCatalog) semanticObject);
                return;
            case CheckPackage.CONTEXT:
                sequence_Context(context, (Context) semanticObject);
                return;
            case CheckPackage.CONTEXT_VARIABLE:
                sequence_ContextVariable(context, (ContextVariable) semanticObject);
                return;
            case CheckPackage.FORMAL_PARAMETER:
                sequence_FormalParameter(context, (FormalParameter) semanticObject);
                return;
            case CheckPackage.IMPLEMENTATION:
                sequence_Implementation(context, (Implementation) semanticObject);
                return;
            case CheckPackage.MEMBER:
                sequence_Member(context, (Member) semanticObject);
                return;
            case CheckPackage.SEVERITY_RANGE:
                sequence_SeverityRange(context, (SeverityRange) semanticObject);
                return;
            case CheckPackage.XGUARD_EXPRESSION:
                sequence_XGuardExpression(context, (XGuardExpression) semanticObject);
                return;
            case CheckPackage.XISSUE_EXPRESSION:
                sequence_XIssueExpression(context, (XIssueExpression) semanticObject);
                return;
        }
    else if (epackage == TypesPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case TypesPackage.JVM_FORMAL_PARAMETER:
                if (rule == grammarAccess.getFullJvmFormalParameterRule()) {
                    sequence_FullJvmFormalParameter(context, (JvmFormalParameter) semanticObject);
                    return;
                } else if (rule == grammarAccess.getJvmFormalParameterRule()) {
                    sequence_JvmFormalParameter(context, (JvmFormalParameter) semanticObject);
                    return;
                } else
                    break;
            case TypesPackage.JVM_GENERIC_ARRAY_TYPE_REFERENCE:
                sequence_JvmTypeReference(context, (JvmGenericArrayTypeReference) semanticObject);
                return;
            case TypesPackage.JVM_INNER_TYPE_REFERENCE:
                sequence_JvmParameterizedTypeReference(context, (JvmInnerTypeReference) semanticObject);
                return;
            case TypesPackage.JVM_LOWER_BOUND:
                if (rule == grammarAccess.getJvmLowerBoundAndedRule()) {
                    sequence_JvmLowerBoundAnded(context, (JvmLowerBound) semanticObject);
                    return;
                } else if (rule == grammarAccess.getJvmLowerBoundRule()) {
                    sequence_JvmLowerBound(context, (JvmLowerBound) semanticObject);
                    return;
                } else
                    break;
            case TypesPackage.JVM_PARAMETERIZED_TYPE_REFERENCE:
                if (action == grammarAccess.getJvmParameterizedTypeReferenceAccess().getJvmInnerTypeReferenceOuterAction_1_4_0_0_0()) {
                    sequence_JvmParameterizedTypeReference_JvmInnerTypeReference_1_4_0_0_0(context, (JvmParameterizedTypeReference) semanticObject);
                    return;
                } else if (rule == grammarAccess.getJvmTypeReferenceRule() || action == grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0() || rule == grammarAccess.getJvmParameterizedTypeReferenceRule() || rule == grammarAccess.getJvmArgumentTypeReferenceRule()) {
                    sequence_JvmParameterizedTypeReference(context, (JvmParameterizedTypeReference) semanticObject);
                    return;
                } else
                    break;
            case TypesPackage.JVM_TYPE_PARAMETER:
                sequence_JvmTypeParameter(context, (JvmTypeParameter) semanticObject);
                return;
            case TypesPackage.JVM_UPPER_BOUND:
                if (rule == grammarAccess.getJvmUpperBoundAndedRule()) {
                    sequence_JvmUpperBoundAnded(context, (JvmUpperBound) semanticObject);
                    return;
                } else if (rule == grammarAccess.getJvmUpperBoundRule()) {
                    sequence_JvmUpperBound(context, (JvmUpperBound) semanticObject);
                    return;
                } else
                    break;
            case TypesPackage.JVM_WILDCARD_TYPE_REFERENCE:
                sequence_JvmWildcardTypeReference(context, (JvmWildcardTypeReference) semanticObject);
                return;
        }
    else if (epackage == XAnnotationsPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case XAnnotationsPackage.XANNOTATION:
                sequence_XAnnotation(context, (XAnnotation) semanticObject);
                return;
            case XAnnotationsPackage.XANNOTATION_ELEMENT_VALUE_PAIR:
                sequence_XAnnotationElementValuePair(context, (XAnnotationElementValuePair) semanticObject);
                return;
        }
    else if (epackage == XbasePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case XbasePackage.XASSIGNMENT:
                sequence_XAssignment_XMemberFeatureCall(context, (XAssignment) semanticObject);
                return;
            case XbasePackage.XBASIC_FOR_LOOP_EXPRESSION:
                sequence_XBasicForLoopExpression(context, (XBasicForLoopExpression) semanticObject);
                return;
            case XbasePackage.XBINARY_OPERATION:
                sequence_XAdditiveExpression_XAndExpression_XAssignment_XEqualityExpression_XMultiplicativeExpression_XOrExpression_XOtherOperatorExpression_XRelationalExpression(context, (XBinaryOperation) semanticObject);
                return;
            case XbasePackage.XBLOCK_EXPRESSION:
                if (rule == grammarAccess.getXPrimaryExpressionRule() || rule == grammarAccess.getXAnnotationElementValueOrCommaListRule() || action == grammarAccess.getXAnnotationElementValueOrCommaListAccess().getXListLiteralElementsAction_1_1_0() || rule == grammarAccess.getXAnnotationElementValueRule() || rule == grammarAccess.getXAnnotationOrExpressionRule() || rule == grammarAccess.getXExpressionRule() || rule == grammarAccess.getXAssignmentRule() || action == grammarAccess.getXAssignmentAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXOrExpressionRule() || action == grammarAccess.getXOrExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXAndExpressionRule() || action == grammarAccess.getXAndExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXEqualityExpressionRule() || action == grammarAccess.getXEqualityExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXRelationalExpressionRule() || action == grammarAccess.getXRelationalExpressionAccess().getXInstanceOfExpressionExpressionAction_1_0_0_0_0() || action == grammarAccess.getXRelationalExpressionAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXOtherOperatorExpressionRule() || action == grammarAccess.getXOtherOperatorExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXAdditiveExpressionRule() || action == grammarAccess.getXAdditiveExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXMultiplicativeExpressionRule() || action == grammarAccess.getXMultiplicativeExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXUnaryOperationRule() || rule == grammarAccess.getXCastedExpressionRule() || action == grammarAccess.getXCastedExpressionAccess().getXCastedExpressionTargetAction_1_0_0_0() || rule == grammarAccess.getXPostfixOperationRule() || action == grammarAccess.getXPostfixOperationAccess().getXPostfixOperationOperandAction_1_0_0() || rule == grammarAccess.getXMemberFeatureCallRule() || action == grammarAccess.getXMemberFeatureCallAccess().getXAssignmentAssignableAction_1_0_0_0_0() || action == grammarAccess.getXMemberFeatureCallAccess().getXMemberFeatureCallMemberCallTargetAction_1_1_0_0_0() || rule == grammarAccess.getXParenthesizedExpressionRule() || rule == grammarAccess.getXBlockExpressionRule() || rule == grammarAccess.getXExpressionOrVarDeclarationRule()) {
                    sequence_XBlockExpression(context, (XBlockExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getXExpressionInClosureRule()) {
                    sequence_XExpressionInClosure(context, (XBlockExpression) semanticObject);
                    return;
                } else
                    break;
            case XbasePackage.XBOOLEAN_LITERAL:
                sequence_XBooleanLiteral(context, (XBooleanLiteral) semanticObject);
                return;
            case XbasePackage.XCASE_PART:
                sequence_XCasePart(context, (XCasePart) semanticObject);
                return;
            case XbasePackage.XCASTED_EXPRESSION:
                sequence_XCastedExpression(context, (XCastedExpression) semanticObject);
                return;
            case XbasePackage.XCATCH_CLAUSE:
                sequence_XCatchClause(context, (XCatchClause) semanticObject);
                return;
            case XbasePackage.XCLOSURE:
                if (rule == grammarAccess.getXPrimaryExpressionRule() || rule == grammarAccess.getXAnnotationElementValueOrCommaListRule() || action == grammarAccess.getXAnnotationElementValueOrCommaListAccess().getXListLiteralElementsAction_1_1_0() || rule == grammarAccess.getXAnnotationElementValueRule() || rule == grammarAccess.getXAnnotationOrExpressionRule() || rule == grammarAccess.getXExpressionRule() || rule == grammarAccess.getXAssignmentRule() || action == grammarAccess.getXAssignmentAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXOrExpressionRule() || action == grammarAccess.getXOrExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXAndExpressionRule() || action == grammarAccess.getXAndExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXEqualityExpressionRule() || action == grammarAccess.getXEqualityExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXRelationalExpressionRule() || action == grammarAccess.getXRelationalExpressionAccess().getXInstanceOfExpressionExpressionAction_1_0_0_0_0() || action == grammarAccess.getXRelationalExpressionAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXOtherOperatorExpressionRule() || action == grammarAccess.getXOtherOperatorExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXAdditiveExpressionRule() || action == grammarAccess.getXAdditiveExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXMultiplicativeExpressionRule() || action == grammarAccess.getXMultiplicativeExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXUnaryOperationRule() || rule == grammarAccess.getXCastedExpressionRule() || action == grammarAccess.getXCastedExpressionAccess().getXCastedExpressionTargetAction_1_0_0_0() || rule == grammarAccess.getXPostfixOperationRule() || action == grammarAccess.getXPostfixOperationAccess().getXPostfixOperationOperandAction_1_0_0() || rule == grammarAccess.getXMemberFeatureCallRule() || action == grammarAccess.getXMemberFeatureCallAccess().getXAssignmentAssignableAction_1_0_0_0_0() || action == grammarAccess.getXMemberFeatureCallAccess().getXMemberFeatureCallMemberCallTargetAction_1_1_0_0_0() || rule == grammarAccess.getXLiteralRule() || rule == grammarAccess.getXClosureRule() || rule == grammarAccess.getXParenthesizedExpressionRule() || rule == grammarAccess.getXExpressionOrVarDeclarationRule()) {
                    sequence_XClosure(context, (XClosure) semanticObject);
                    return;
                } else if (rule == grammarAccess.getXShortClosureRule()) {
                    sequence_XShortClosure(context, (XClosure) semanticObject);
                    return;
                } else
                    break;
            case XbasePackage.XCONSTRUCTOR_CALL:
                sequence_XConstructorCall(context, (XConstructorCall) semanticObject);
                return;
            case XbasePackage.XDO_WHILE_EXPRESSION:
                sequence_XDoWhileExpression(context, (XDoWhileExpression) semanticObject);
                return;
            case XbasePackage.XFEATURE_CALL:
                sequence_XFeatureCall(context, (XFeatureCall) semanticObject);
                return;
            case XbasePackage.XFOR_LOOP_EXPRESSION:
                sequence_XForLoopExpression(context, (XForLoopExpression) semanticObject);
                return;
            case XbasePackage.XIF_EXPRESSION:
                sequence_XIfExpression(context, (XIfExpression) semanticObject);
                return;
            case XbasePackage.XINSTANCE_OF_EXPRESSION:
                sequence_XRelationalExpression(context, (XInstanceOfExpression) semanticObject);
                return;
            case XbasePackage.XLIST_LITERAL:
                if (rule == grammarAccess.getXAnnotationElementValueOrCommaListRule()) {
                    sequence_XAnnotationElementValueOrCommaList_XListLiteral(context, (XListLiteral) semanticObject);
                    return;
                } else if (rule == grammarAccess.getXAnnotationElementValueRule()) {
                    sequence_XAnnotationElementValue_XListLiteral(context, (XListLiteral) semanticObject);
                    return;
                } else if (rule == grammarAccess.getXFormalParameterDefaultValueLiteralRule() || rule == grammarAccess.getXConstantListLiteralRule()) {
                    sequence_XConstantListLiteral(context, (XListLiteral) semanticObject);
                    return;
                } else if (rule == grammarAccess.getXPrimaryExpressionRule() || action == grammarAccess.getXAnnotationElementValueOrCommaListAccess().getXListLiteralElementsAction_1_1_0() || rule == grammarAccess.getXAnnotationOrExpressionRule() || rule == grammarAccess.getXExpressionRule() || rule == grammarAccess.getXAssignmentRule() || action == grammarAccess.getXAssignmentAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXOrExpressionRule() || action == grammarAccess.getXOrExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXAndExpressionRule() || action == grammarAccess.getXAndExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXEqualityExpressionRule() || action == grammarAccess.getXEqualityExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXRelationalExpressionRule() || action == grammarAccess.getXRelationalExpressionAccess().getXInstanceOfExpressionExpressionAction_1_0_0_0_0() || action == grammarAccess.getXRelationalExpressionAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXOtherOperatorExpressionRule() || action == grammarAccess.getXOtherOperatorExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXAdditiveExpressionRule() || action == grammarAccess.getXAdditiveExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXMultiplicativeExpressionRule() || action == grammarAccess.getXMultiplicativeExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXUnaryOperationRule() || rule == grammarAccess.getXCastedExpressionRule() || action == grammarAccess.getXCastedExpressionAccess().getXCastedExpressionTargetAction_1_0_0_0() || rule == grammarAccess.getXPostfixOperationRule() || action == grammarAccess.getXPostfixOperationAccess().getXPostfixOperationOperandAction_1_0_0() || rule == grammarAccess.getXMemberFeatureCallRule() || action == grammarAccess.getXMemberFeatureCallAccess().getXAssignmentAssignableAction_1_0_0_0_0() || action == grammarAccess.getXMemberFeatureCallAccess().getXMemberFeatureCallMemberCallTargetAction_1_1_0_0_0() || rule == grammarAccess.getXLiteralRule() || rule == grammarAccess.getXCollectionLiteralRule() || rule == grammarAccess.getXListLiteralRule() || rule == grammarAccess.getXParenthesizedExpressionRule() || rule == grammarAccess.getXExpressionOrVarDeclarationRule()) {
                    sequence_XListLiteral(context, (XListLiteral) semanticObject);
                    return;
                } else
                    break;
            case XbasePackage.XMEMBER_FEATURE_CALL:
                sequence_XMemberFeatureCall(context, (XMemberFeatureCall) semanticObject);
                return;
            case XbasePackage.XNULL_LITERAL:
                sequence_XNullLiteral(context, (XNullLiteral) semanticObject);
                return;
            case XbasePackage.XNUMBER_LITERAL:
                sequence_XNumberLiteral(context, (XNumberLiteral) semanticObject);
                return;
            case XbasePackage.XPOSTFIX_OPERATION:
                sequence_XPostfixOperation(context, (XPostfixOperation) semanticObject);
                return;
            case XbasePackage.XRETURN_EXPRESSION:
                sequence_XReturnExpression(context, (XReturnExpression) semanticObject);
                return;
            case XbasePackage.XSET_LITERAL:
                sequence_XSetLiteral(context, (XSetLiteral) semanticObject);
                return;
            case XbasePackage.XSTRING_LITERAL:
                sequence_XStringLiteral(context, (XStringLiteral) semanticObject);
                return;
            case XbasePackage.XSWITCH_EXPRESSION:
                sequence_XSwitchExpression(context, (XSwitchExpression) semanticObject);
                return;
            case XbasePackage.XSYNCHRONIZED_EXPRESSION:
                sequence_XSynchronizedExpression(context, (XSynchronizedExpression) semanticObject);
                return;
            case XbasePackage.XTHROW_EXPRESSION:
                sequence_XThrowExpression(context, (XThrowExpression) semanticObject);
                return;
            case XbasePackage.XTRY_CATCH_FINALLY_EXPRESSION:
                sequence_XTryCatchFinallyExpression(context, (XTryCatchFinallyExpression) semanticObject);
                return;
            case XbasePackage.XTYPE_LITERAL:
                sequence_XTypeLiteral(context, (XTypeLiteral) semanticObject);
                return;
            case XbasePackage.XUNARY_OPERATION:
                if (rule == grammarAccess.getXConstantUnaryOperationRule() || rule == grammarAccess.getXFormalParameterDefaultValueLiteralRule()) {
                    sequence_XConstantUnaryOperation(context, (XUnaryOperation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getXPrimaryExpressionRule() || rule == grammarAccess.getXAnnotationElementValueOrCommaListRule() || action == grammarAccess.getXAnnotationElementValueOrCommaListAccess().getXListLiteralElementsAction_1_1_0() || rule == grammarAccess.getXAnnotationElementValueRule() || rule == grammarAccess.getXAnnotationOrExpressionRule() || rule == grammarAccess.getXExpressionRule() || rule == grammarAccess.getXAssignmentRule() || action == grammarAccess.getXAssignmentAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXOrExpressionRule() || action == grammarAccess.getXOrExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXAndExpressionRule() || action == grammarAccess.getXAndExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXEqualityExpressionRule() || action == grammarAccess.getXEqualityExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXRelationalExpressionRule() || action == grammarAccess.getXRelationalExpressionAccess().getXInstanceOfExpressionExpressionAction_1_0_0_0_0() || action == grammarAccess.getXRelationalExpressionAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXOtherOperatorExpressionRule() || action == grammarAccess.getXOtherOperatorExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXAdditiveExpressionRule() || action == grammarAccess.getXAdditiveExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXMultiplicativeExpressionRule() || action == grammarAccess.getXMultiplicativeExpressionAccess().getXBinaryOperationLeftOperandAction_1_0_0_0() || rule == grammarAccess.getXUnaryOperationRule() || rule == grammarAccess.getXCastedExpressionRule() || action == grammarAccess.getXCastedExpressionAccess().getXCastedExpressionTargetAction_1_0_0_0() || rule == grammarAccess.getXPostfixOperationRule() || action == grammarAccess.getXPostfixOperationAccess().getXPostfixOperationOperandAction_1_0_0() || rule == grammarAccess.getXMemberFeatureCallRule() || action == grammarAccess.getXMemberFeatureCallAccess().getXAssignmentAssignableAction_1_0_0_0_0() || action == grammarAccess.getXMemberFeatureCallAccess().getXMemberFeatureCallMemberCallTargetAction_1_1_0_0_0() || rule == grammarAccess.getXParenthesizedExpressionRule() || rule == grammarAccess.getXExpressionOrVarDeclarationRule()) {
                    sequence_XUnaryOperation(context, (XUnaryOperation) semanticObject);
                    return;
                } else
                    break;
            case XbasePackage.XVARIABLE_DECLARATION:
                sequence_XVariableDeclaration(context, (XVariableDeclaration) semanticObject);
                return;
            case XbasePackage.XWHILE_EXPRESSION:
                sequence_XWhileExpression(context, (XWhileExpression) semanticObject);
                return;
        }
    else if (epackage == XtypePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case XtypePackage.XFUNCTION_TYPE_REF:
                sequence_XFunctionTypeRef(context, (XFunctionTypeRef) semanticObject);
                return;
            case XtypePackage.XIMPORT_DECLARATION:
                sequence_XImportDeclaration(context, (XImportDeclaration) semanticObject);
                return;
            case XtypePackage.XIMPORT_SECTION:
                sequence_XImportSection(context, (XImportSection) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) XAnnotationElementValuePair(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair) Action(org.eclipse.xtext.Action) Category(com.avaloq.tools.ddk.check.check.Category) XFunctionTypeRef(org.eclipse.xtext.xtype.XFunctionTypeRef) XClosure(org.eclipse.xtext.xbase.XClosure) XImportSection(org.eclipse.xtext.xtype.XImportSection) ContextVariable(com.avaloq.tools.ddk.check.check.ContextVariable) Check(com.avaloq.tools.ddk.check.check.Check) XListLiteral(org.eclipse.xtext.xbase.XListLiteral) Implementation(com.avaloq.tools.ddk.check.check.Implementation) EPackage(org.eclipse.emf.ecore.EPackage) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation) CheckCatalog(com.avaloq.tools.ddk.check.check.CheckCatalog) Member(com.avaloq.tools.ddk.check.check.Member) ISerializationContext(org.eclipse.xtext.serializer.ISerializationContext) Context(com.avaloq.tools.ddk.check.check.Context) FormalParameter(com.avaloq.tools.ddk.check.check.FormalParameter) JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XGuardExpression(com.avaloq.tools.ddk.check.check.XGuardExpression) JvmLowerBound(org.eclipse.xtext.common.types.JvmLowerBound) SeverityRange(com.avaloq.tools.ddk.check.check.SeverityRange) XImportDeclaration(org.eclipse.xtext.xtype.XImportDeclaration) JvmUpperBound(org.eclipse.xtext.common.types.JvmUpperBound) XIssueExpression(com.avaloq.tools.ddk.check.check.XIssueExpression) JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) XUnaryOperation(org.eclipse.xtext.xbase.XUnaryOperation) FormalParameter(com.avaloq.tools.ddk.check.check.FormalParameter) JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) Parameter(org.eclipse.xtext.Parameter) JvmParameterizedTypeReference(org.eclipse.xtext.common.types.JvmParameterizedTypeReference)

Example 2 with XGuardExpression

use of com.avaloq.tools.ddk.check.check.XGuardExpression in project dsl-devkit by dsldevkit.

the class CheckJavaValidator method checkGuardsFirst.

/**
 * Checks that if guards have been provided as part of a context's constraint, they appear in the
 * beginning of a block expression.
 *
 * @param context
 *          the context for which the constraint is checked
 */
@SuppressWarnings("unchecked")
@Check
public void checkGuardsFirst(final Context context) {
    if (context.getContextVariable() == null || context.getConstraint() == null) {
        return;
    }
    List<XGuardExpression> guards = EcoreUtil2.eAllOfType(context.getConstraint(), XGuardExpression.class);
    if (Iterables.isEmpty(guards)) {
        // no guards makes check irrelevant
        return;
    }
    EList<XExpression> topLevelExpressions = (EList<XExpression>) ((XBlockExpression) context.getConstraint()).eGet(XbasePackage.Literals.XBLOCK_EXPRESSION__EXPRESSIONS);
    for (final XGuardExpression guard : guards) {
        final EStructuralFeature eContainingFeature = guard.eContainingFeature();
        if (guard.eContainer() != null && eContainingFeature != null) {
            if (guard.eContainer().eGet(eContainingFeature) != topLevelExpressions) {
                // guards not allowed in nested expressions, must be on root level
                error(Messages.CheckJavaValidator_GUARDS_COME_FIRST, guard, null, IssueCodes.GUARDS_COME_FIRST);
            } else {
                // check that guards precede other expressions
                int pos = topLevelExpressions.indexOf(guard);
                if (pos > 0) {
                    for (int i = 0; i < pos; i++) {
                        if (!(topLevelExpressions.get(i) instanceof XGuardExpression)) {
                            error(Messages.CheckJavaValidator_GUARDS_COME_FIRST, guard, null, IssueCodes.GUARDS_COME_FIRST);
                            break;
                        }
                    }
                }
            }
        }
    }
}
Also used : EList(org.eclipse.emf.common.util.EList) XGuardExpression(com.avaloq.tools.ddk.check.check.XGuardExpression) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) XExpression(org.eclipse.xtext.xbase.XExpression) Check(org.eclipse.xtext.validation.Check)

Example 3 with XGuardExpression

use of com.avaloq.tools.ddk.check.check.XGuardExpression in project dsl-devkit by dsldevkit.

the class CheckValidator method checkGuardsFirst.

/**
 * Checks that if guards have been provided as part of a context's constraint, they appear in the
 * beginning of a block expression.
 *
 * @param context
 *          the context for which the constraint is checked
 */
@SuppressWarnings("unchecked")
@Check
public void checkGuardsFirst(final Context context) {
    if (context.getContextVariable() == null || context.getConstraint() == null) {
        return;
    }
    List<XGuardExpression> guards = EcoreUtil2.eAllOfType(context.getConstraint(), XGuardExpression.class);
    if (Iterables.isEmpty(guards)) {
        // no guards makes check irrelevant
        return;
    }
    EList<XExpression> topLevelExpressions = (EList<XExpression>) ((XBlockExpression) context.getConstraint()).eGet(XbasePackage.Literals.XBLOCK_EXPRESSION__EXPRESSIONS);
    for (final XGuardExpression guard : guards) {
        final EStructuralFeature eContainingFeature = guard.eContainingFeature();
        if (guard.eContainer() != null && eContainingFeature != null) {
            if (guard.eContainer().eGet(eContainingFeature) != topLevelExpressions) {
                // guards not allowed in nested expressions, must be on root level
                error(Messages.CheckJavaValidator_GUARDS_COME_FIRST, guard, null, IssueCodes.GUARDS_COME_FIRST);
            } else {
                // check that guards precede other expressions
                int pos = topLevelExpressions.indexOf(guard);
                if (pos > 0) {
                    for (int i = 0; i < pos; i++) {
                        if (!(topLevelExpressions.get(i) instanceof XGuardExpression)) {
                            error(Messages.CheckJavaValidator_GUARDS_COME_FIRST, guard, null, IssueCodes.GUARDS_COME_FIRST);
                            break;
                        }
                    }
                }
            }
        }
    }
}
Also used : EList(org.eclipse.emf.common.util.EList) XGuardExpression(com.avaloq.tools.ddk.check.check.XGuardExpression) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) XExpression(org.eclipse.xtext.xbase.XExpression) Check(org.eclipse.xtext.validation.Check)

Aggregations

XGuardExpression (com.avaloq.tools.ddk.check.check.XGuardExpression)3 EList (org.eclipse.emf.common.util.EList)2 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)2 Check (org.eclipse.xtext.validation.Check)2 XExpression (org.eclipse.xtext.xbase.XExpression)2 Category (com.avaloq.tools.ddk.check.check.Category)1 Check (com.avaloq.tools.ddk.check.check.Check)1 CheckCatalog (com.avaloq.tools.ddk.check.check.CheckCatalog)1 Context (com.avaloq.tools.ddk.check.check.Context)1 ContextVariable (com.avaloq.tools.ddk.check.check.ContextVariable)1 FormalParameter (com.avaloq.tools.ddk.check.check.FormalParameter)1 Implementation (com.avaloq.tools.ddk.check.check.Implementation)1 Member (com.avaloq.tools.ddk.check.check.Member)1 SeverityRange (com.avaloq.tools.ddk.check.check.SeverityRange)1 XIssueExpression (com.avaloq.tools.ddk.check.check.XIssueExpression)1 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)1