Search in sources :

Example 1 with XCastedExpression

use of org.eclipse.xtext.xbase.XCastedExpression in project xtext-xtend by eclipse.

the class ErrorTest method testErrorModel_077.

@Test
public void testErrorModel_077() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("try return \'literal\' as as Boolean");
    _builder.newLine();
    _builder.append("\t\t  ");
    _builder.append("catch(NullPointerException e) return \'second thing is thrown\'\t\t  ");
    _builder.newLine();
    _builder.append("\t\t  ");
    _builder.append("catch(ClassCastException e) throw new NullPointerException()");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this.processWithoutException(_builder);
    final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(file);
    final XCastedExpression casted = IteratorExtensions.<XCastedExpression>last(Iterators.<XCastedExpression>filter(file.eAllContents(), XCastedExpression.class));
    Assert.assertNull(casted.getType());
    Assert.assertNotNull(resolvedTypes.getActualType(casted));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XCastedExpression(org.eclipse.xtext.xbase.XCastedExpression) IResolvedTypes(org.eclipse.xtext.xbase.typesystem.IResolvedTypes) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 2 with XCastedExpression

use of org.eclipse.xtext.xbase.XCastedExpression in project xtext-xtend by eclipse.

the class AbstractXtendSemanticSequencer 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 == TypesPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case TypesPackage.JVM_GENERIC_ARRAY_TYPE_REFERENCE:
                if (rule == grammarAccess.getMultiTypeReferenceRule() || action == grammarAccess.getMultiTypeReferenceAccess().getJvmSynonymTypeReferenceReferencesAction_1_0() || rule == grammarAccess.getJvmTypeReferenceRule() || action == grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0() || rule == grammarAccess.getJvmArgumentTypeReferenceRule()) {
                    sequence_JvmTypeReference(context, (JvmGenericArrayTypeReference) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeReferenceWithTypeArgsRule()) {
                    sequence_TypeReferenceWithTypeArgs(context, (JvmGenericArrayTypeReference) semanticObject);
                    return;
                } else if (action == grammarAccess.getTypeReferenceWithTypeArgsAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0()) {
                    sequence_TypeReferenceWithTypeArgs_JvmGenericArrayTypeReference_0_1_0_0(context, (JvmGenericArrayTypeReference) semanticObject);
                    return;
                } else if (action == grammarAccess.getTypeReferenceWithTypeArgsAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_1_1_0_0()) {
                    sequence_TypeReferenceWithTypeArgs_JvmGenericArrayTypeReference_1_1_0_0(context, (JvmGenericArrayTypeReference) semanticObject);
                    return;
                } else
                    break;
            case TypesPackage.JVM_INNER_TYPE_REFERENCE:
                if (rule == grammarAccess.getJvmSuperTypeReferenceRule() || rule == grammarAccess.getMultiTypeReferenceRule() || action == grammarAccess.getMultiTypeReferenceAccess().getJvmSynonymTypeReferenceReferencesAction_1_0() || rule == grammarAccess.getJvmTypeReferenceRule() || action == grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0() || rule == grammarAccess.getJvmParameterizedTypeReferenceRule() || action == grammarAccess.getJvmParameterizedTypeReferenceAccess().getJvmInnerTypeReferenceOuterAction_1_4_0_0_0() || rule == grammarAccess.getJvmArgumentTypeReferenceRule()) {
                    sequence_JvmParameterizedTypeReference(context, (JvmInnerTypeReference) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeReferenceWithTypeArgsRule() || action == grammarAccess.getTypeReferenceWithTypeArgsAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0() || rule == grammarAccess.getParameterizedTypeReferenceWithTypeArgsRule() || action == grammarAccess.getParameterizedTypeReferenceWithTypeArgsAccess().getJvmInnerTypeReferenceOuterAction_1_4_0_0_0()) {
                    sequence_ParameterizedTypeReferenceWithTypeArgs(context, (JvmInnerTypeReference) semanticObject);
                    return;
                } else
                    break;
            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.getJvmSuperTypeReferenceRule() || rule == grammarAccess.getMultiTypeReferenceRule() || action == grammarAccess.getMultiTypeReferenceAccess().getJvmSynonymTypeReferenceReferencesAction_1_0() || rule == grammarAccess.getJvmTypeReferenceRule() || action == grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0() || rule == grammarAccess.getJvmParameterizedTypeReferenceRule() || rule == grammarAccess.getJvmArgumentTypeReferenceRule()) {
                    sequence_JvmParameterizedTypeReference(context, (JvmParameterizedTypeReference) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeReferenceWithTypeArgsRule() || action == grammarAccess.getTypeReferenceWithTypeArgsAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0() || rule == grammarAccess.getParameterizedTypeReferenceWithTypeArgsRule() || action == grammarAccess.getParameterizedTypeReferenceWithTypeArgsAccess().getJvmInnerTypeReferenceOuterAction_1_4_0_0_0()) {
                    sequence_ParameterizedTypeReferenceWithTypeArgs(context, (JvmParameterizedTypeReference) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeReferenceNoTypeArgsRule() || action == grammarAccess.getTypeReferenceWithTypeArgsAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_1_1_0_0()) {
                    sequence_TypeReferenceNoTypeArgs(context, (JvmParameterizedTypeReference) semanticObject);
                    return;
                } else
                    break;
            case TypesPackage.JVM_SYNONYM_TYPE_REFERENCE:
                sequence_MultiTypeReference(context, (JvmSynonymTypeReference) semanticObject);
                return;
            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.getXAssignmentRule() || action == grammarAccess.getXAssignmentAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXConditionalExpressionRule() || action == grammarAccess.getXConditionalExpressionAccess().getXIfExpressionIfAction_1_0_0_0() || rule == grammarAccess.getXExpressionOrSimpleConstructorCallRule() || rule == grammarAccess.getRichStringPartRule() || rule == grammarAccess.getXAnnotationElementValueOrCommaListRule() || action == grammarAccess.getXAnnotationElementValueOrCommaListAccess().getXListLiteralElementsAction_1_1_0() || rule == grammarAccess.getXAnnotationElementValueRule() || rule == grammarAccess.getXAnnotationOrExpressionRule() || rule == grammarAccess.getXExpressionRule() || 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.getXPrimaryExpressionRule() || 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.getXAssignmentRule() || action == grammarAccess.getXAssignmentAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXConditionalExpressionRule() || action == grammarAccess.getXConditionalExpressionAccess().getXIfExpressionIfAction_1_0_0_0() || rule == grammarAccess.getXExpressionOrSimpleConstructorCallRule() || rule == grammarAccess.getRichStringPartRule() || rule == grammarAccess.getXAnnotationElementValueOrCommaListRule() || action == grammarAccess.getXAnnotationElementValueOrCommaListAccess().getXListLiteralElementsAction_1_1_0() || rule == grammarAccess.getXAnnotationElementValueRule() || rule == grammarAccess.getXAnnotationOrExpressionRule() || rule == grammarAccess.getXExpressionRule() || 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.getXPrimaryExpressionRule() || 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_XbaseConstructorCall(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:
                if (rule == grammarAccess.getXAssignmentRule() || action == grammarAccess.getXAssignmentAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXConditionalExpressionRule() || action == grammarAccess.getXConditionalExpressionAccess().getXIfExpressionIfAction_1_0_0_0() || rule == grammarAccess.getXExpressionOrSimpleConstructorCallRule() || rule == grammarAccess.getRichStringPartRule() || rule == grammarAccess.getXAnnotationElementValueOrCommaListRule() || action == grammarAccess.getXAnnotationElementValueOrCommaListAccess().getXListLiteralElementsAction_1_1_0() || rule == grammarAccess.getXAnnotationElementValueRule() || rule == grammarAccess.getXAnnotationOrExpressionRule() || rule == grammarAccess.getXExpressionRule() || 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.getXPrimaryExpressionRule() || rule == grammarAccess.getXParenthesizedExpressionRule() || rule == grammarAccess.getXExpressionOrVarDeclarationRule()) {
                    sequence_XConditionalExpression_XIfExpression(context, (XIfExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getXIfExpressionRule()) {
                    sequence_XIfExpression(context, (XIfExpression) semanticObject);
                    return;
                } else
                    break;
            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.getXAssignmentRule() || action == grammarAccess.getXAssignmentAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXConditionalExpressionRule() || action == grammarAccess.getXConditionalExpressionAccess().getXIfExpressionIfAction_1_0_0_0() || rule == grammarAccess.getXExpressionOrSimpleConstructorCallRule() || rule == grammarAccess.getRichStringPartRule() || action == grammarAccess.getXAnnotationElementValueOrCommaListAccess().getXListLiteralElementsAction_1_1_0() || rule == grammarAccess.getXAnnotationOrExpressionRule() || rule == grammarAccess.getXExpressionRule() || 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.getXPrimaryExpressionRule() || 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_SimpleStringLiteral(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:
                sequence_XUnaryOperation(context, (XUnaryOperation) semanticObject);
                return;
            case XbasePackage.XWHILE_EXPRESSION:
                sequence_XWhileExpression(context, (XWhileExpression) semanticObject);
                return;
        }
    else if (epackage == XtendPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case XtendPackage.ANONYMOUS_CLASS:
                sequence_XConstructorCall(context, (AnonymousClass) semanticObject);
                return;
            case XtendPackage.CREATE_EXTENSION_INFO:
                sequence_CreateExtensionInfo(context, (CreateExtensionInfo) semanticObject);
                return;
            case XtendPackage.RICH_STRING:
                if (rule == grammarAccess.getInternalRichStringRule()) {
                    sequence_InternalRichString(context, (RichString) semanticObject);
                    return;
                } else if (rule == grammarAccess.getXAssignmentRule() || action == grammarAccess.getXAssignmentAccess().getXBinaryOperationLeftOperandAction_1_1_0_0_0() || rule == grammarAccess.getXConditionalExpressionRule() || action == grammarAccess.getXConditionalExpressionAccess().getXIfExpressionIfAction_1_0_0_0() || rule == grammarAccess.getXStringLiteralRule() || rule == grammarAccess.getXExpressionOrSimpleConstructorCallRule() || rule == grammarAccess.getRichStringRule() || rule == grammarAccess.getRichStringPartRule() || rule == grammarAccess.getXAnnotationElementValueOrCommaListRule() || action == grammarAccess.getXAnnotationElementValueOrCommaListAccess().getXListLiteralElementsAction_1_1_0() || rule == grammarAccess.getXAnnotationElementValueRule() || rule == grammarAccess.getXAnnotationOrExpressionRule() || rule == grammarAccess.getXExpressionRule() || 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.getXPrimaryExpressionRule() || rule == grammarAccess.getXLiteralRule() || rule == grammarAccess.getXParenthesizedExpressionRule() || rule == grammarAccess.getXExpressionOrVarDeclarationRule()) {
                    sequence_RichString(context, (RichString) semanticObject);
                    return;
                } else
                    break;
            case XtendPackage.RICH_STRING_ELSE_IF:
                sequence_RichStringElseIf(context, (RichStringElseIf) semanticObject);
                return;
            case XtendPackage.RICH_STRING_FOR_LOOP:
                sequence_RichStringForLoop(context, (RichStringForLoop) semanticObject);
                return;
            case XtendPackage.RICH_STRING_IF:
                sequence_RichStringIf(context, (RichStringIf) semanticObject);
                return;
            case XtendPackage.RICH_STRING_LITERAL:
                if (rule == grammarAccess.getRichStringLiteralEndRule()) {
                    sequence_RichStringLiteralEnd(context, (RichStringLiteral) semanticObject);
                    return;
                } else if (rule == grammarAccess.getRichStringLiteralInbetweenRule()) {
                    sequence_RichStringLiteralInbetween(context, (RichStringLiteral) semanticObject);
                    return;
                } else if (rule == grammarAccess.getRichStringLiteralStartRule()) {
                    sequence_RichStringLiteralStart(context, (RichStringLiteral) semanticObject);
                    return;
                } else if (rule == grammarAccess.getRichStringLiteralRule()) {
                    sequence_RichStringLiteral(context, (RichStringLiteral) semanticObject);
                    return;
                } else
                    break;
            case XtendPackage.XTEND_ANNOTATION_TYPE:
                if (rule == grammarAccess.getAnnotationFieldRule()) {
                    sequence_AnnotationField(context, (XtendAnnotationType) semanticObject);
                    return;
                } else if (rule == grammarAccess.getMemberRule()) {
                    sequence_Member(context, (XtendAnnotationType) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeRule()) {
                    sequence_Type(context, (XtendAnnotationType) semanticObject);
                    return;
                } else
                    break;
            case XtendPackage.XTEND_CLASS:
                if (rule == grammarAccess.getAnnotationFieldRule()) {
                    sequence_AnnotationField(context, (XtendClass) semanticObject);
                    return;
                } else if (rule == grammarAccess.getMemberRule()) {
                    sequence_Member(context, (XtendClass) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeRule()) {
                    sequence_Type(context, (XtendClass) semanticObject);
                    return;
                } else
                    break;
            case XtendPackage.XTEND_CONSTRUCTOR:
                sequence_Member(context, (XtendConstructor) semanticObject);
                return;
            case XtendPackage.XTEND_ENUM:
                if (rule == grammarAccess.getAnnotationFieldRule()) {
                    sequence_AnnotationField(context, (XtendEnum) semanticObject);
                    return;
                } else if (rule == grammarAccess.getMemberRule()) {
                    sequence_Member(context, (XtendEnum) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeRule()) {
                    sequence_Type(context, (XtendEnum) semanticObject);
                    return;
                } else
                    break;
            case XtendPackage.XTEND_ENUM_LITERAL:
                sequence_XtendEnumLiteral(context, (XtendEnumLiteral) semanticObject);
                return;
            case XtendPackage.XTEND_FIELD:
                if (rule == grammarAccess.getAnnotationFieldRule()) {
                    sequence_AnnotationField(context, (XtendField) semanticObject);
                    return;
                } else if (rule == grammarAccess.getMemberRule()) {
                    sequence_Member(context, (XtendField) semanticObject);
                    return;
                } else
                    break;
            case XtendPackage.XTEND_FILE:
                sequence_File(context, (XtendFile) semanticObject);
                return;
            case XtendPackage.XTEND_FORMAL_PARAMETER:
                if (rule == grammarAccess.getFullJvmFormalParameterRule()) {
                    sequence_FullJvmFormalParameter(context, (XtendFormalParameter) semanticObject);
                    return;
                } else if (rule == grammarAccess.getJvmFormalParameterRule()) {
                    sequence_JvmFormalParameter(context, (XtendFormalParameter) semanticObject);
                    return;
                } else
                    break;
            case XtendPackage.XTEND_FUNCTION:
                sequence_Member(context, (XtendFunction) semanticObject);
                return;
            case XtendPackage.XTEND_INTERFACE:
                if (rule == grammarAccess.getAnnotationFieldRule()) {
                    sequence_AnnotationField(context, (XtendInterface) semanticObject);
                    return;
                } else if (rule == grammarAccess.getMemberRule()) {
                    sequence_Member(context, (XtendInterface) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeRule()) {
                    sequence_Type(context, (XtendInterface) semanticObject);
                    return;
                } else
                    break;
            case XtendPackage.XTEND_MEMBER:
                if (action == grammarAccess.getAnnotationFieldAccess().getXtendFieldAnnotationInfoAction_2_0_0_0_0() || action == grammarAccess.getAnnotationFieldAccess().getXtendFieldAnnotationInfoAction_2_0_0_1_0() || action == grammarAccess.getAnnotationFieldAccess().getXtendClassAnnotationInfoAction_2_1_0() || action == grammarAccess.getAnnotationFieldAccess().getXtendInterfaceAnnotationInfoAction_2_2_0() || action == grammarAccess.getAnnotationFieldAccess().getXtendEnumAnnotationInfoAction_2_3_0() || action == grammarAccess.getAnnotationFieldAccess().getXtendAnnotationTypeAnnotationInfoAction_2_4_0()) {
                    sequence_AnnotationField_XtendAnnotationType_2_4_0_XtendClass_2_1_0_XtendEnum_2_3_0_XtendField_2_0_0_0_0_XtendField_2_0_0_1_0_XtendInterface_2_2_0(context, (XtendMember) semanticObject);
                    return;
                } else if (action == grammarAccess.getMemberAccess().getXtendFieldAnnotationInfoAction_2_0_0() || action == grammarAccess.getMemberAccess().getXtendFunctionAnnotationInfoAction_2_1_0() || action == grammarAccess.getMemberAccess().getXtendConstructorAnnotationInfoAction_2_2_0() || action == grammarAccess.getMemberAccess().getXtendClassAnnotationInfoAction_2_3_0() || action == grammarAccess.getMemberAccess().getXtendInterfaceAnnotationInfoAction_2_4_0() || action == grammarAccess.getMemberAccess().getXtendEnumAnnotationInfoAction_2_5_0() || action == grammarAccess.getMemberAccess().getXtendAnnotationTypeAnnotationInfoAction_2_6_0()) {
                    sequence_Member_XtendAnnotationType_2_6_0_XtendClass_2_3_0_XtendConstructor_2_2_0_XtendEnum_2_5_0_XtendField_2_0_0_XtendFunction_2_1_0_XtendInterface_2_4_0(context, (XtendMember) semanticObject);
                    return;
                } else
                    break;
            case XtendPackage.XTEND_PARAMETER:
                sequence_Parameter(context, (XtendParameter) semanticObject);
                return;
            case XtendPackage.XTEND_TYPE_DECLARATION:
                sequence_Type_XtendAnnotationType_2_3_0_XtendClass_2_0_0_XtendEnum_2_2_0_XtendInterface_2_1_0(context, (XtendTypeDeclaration) semanticObject);
                return;
            case XtendPackage.XTEND_VARIABLE_DECLARATION:
                if (rule == grammarAccess.getInitializedVariableDeclarationRule()) {
                    sequence_InitializedVariableDeclaration_VariableModifier(context, (XtendVariableDeclaration) semanticObject);
                    return;
                } else if (rule == grammarAccess.getXVariableDeclarationRule() || rule == grammarAccess.getRichStringPartRule() || rule == grammarAccess.getXExpressionOrVarDeclarationRule()) {
                    sequence_VariableModifier_XVariableDeclaration(context, (XtendVariableDeclaration) semanticObject);
                    return;
                } else
                    break;
        }
    else if (epackage == XtypePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case XtypePackage.XFUNCTION_TYPE_REF:
                if (rule == grammarAccess.getJvmSuperTypeReferenceRule() || rule == grammarAccess.getXFunctionSuperTypeRefRule()) {
                    sequence_XFunctionSuperTypeRef(context, (XFunctionTypeRef) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeReferenceWithTypeArgsRule() || rule == grammarAccess.getMultiTypeReferenceRule() || action == grammarAccess.getMultiTypeReferenceAccess().getJvmSynonymTypeReferenceReferencesAction_1_0() || rule == grammarAccess.getJvmTypeReferenceRule() || rule == grammarAccess.getXFunctionTypeRefRule() || rule == grammarAccess.getJvmArgumentTypeReferenceRule()) {
                    sequence_XFunctionTypeRef(context, (XFunctionTypeRef) semanticObject);
                    return;
                } else
                    break;
            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) XBasicForLoopExpression(org.eclipse.xtext.xbase.XBasicForLoopExpression) XtendVariableDeclaration(org.eclipse.xtend.core.xtend.XtendVariableDeclaration) XFunctionTypeRef(org.eclipse.xtext.xtype.XFunctionTypeRef) XClosure(org.eclipse.xtext.xbase.XClosure) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) XSwitchExpression(org.eclipse.xtext.xbase.XSwitchExpression) XBinaryOperation(org.eclipse.xtext.xbase.XBinaryOperation) EPackage(org.eclipse.emf.ecore.EPackage) XIfExpression(org.eclipse.xtext.xbase.XIfExpression) XCasePart(org.eclipse.xtext.xbase.XCasePart) JvmSynonymTypeReference(org.eclipse.xtext.common.types.JvmSynonymTypeReference) XForLoopExpression(org.eclipse.xtext.xbase.XForLoopExpression) XNumberLiteral(org.eclipse.xtext.xbase.XNumberLiteral) XThrowExpression(org.eclipse.xtext.xbase.XThrowExpression) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XCastedExpression(org.eclipse.xtext.xbase.XCastedExpression) JvmGenericArrayTypeReference(org.eclipse.xtext.common.types.JvmGenericArrayTypeReference) XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) JvmLowerBound(org.eclipse.xtext.common.types.JvmLowerBound) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) XConstructorCall(org.eclipse.xtext.xbase.XConstructorCall) XTypeLiteral(org.eclipse.xtext.xbase.XTypeLiteral) XtendFormalParameter(org.eclipse.xtend.core.xtend.XtendFormalParameter) XImportDeclaration(org.eclipse.xtext.xtype.XImportDeclaration) XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) XUnaryOperation(org.eclipse.xtext.xbase.XUnaryOperation) XWhileExpression(org.eclipse.xtext.xbase.XWhileExpression) XCatchClause(org.eclipse.xtext.xbase.XCatchClause) XDoWhileExpression(org.eclipse.xtext.xbase.XDoWhileExpression) Action(org.eclipse.xtext.Action) RichString(org.eclipse.xtend.core.xtend.RichString) XImportSection(org.eclipse.xtext.xtype.XImportSection) XPostfixOperation(org.eclipse.xtext.xbase.XPostfixOperation) XListLiteral(org.eclipse.xtext.xbase.XListLiteral) XtendField(org.eclipse.xtend.core.xtend.XtendField) XInstanceOfExpression(org.eclipse.xtext.xbase.XInstanceOfExpression) XtendAnnotationType(org.eclipse.xtend.core.xtend.XtendAnnotationType) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) XtendEnum(org.eclipse.xtend.core.xtend.XtendEnum) XReturnExpression(org.eclipse.xtext.xbase.XReturnExpression) XAssignment(org.eclipse.xtext.xbase.XAssignment) JvmInnerTypeReference(org.eclipse.xtext.common.types.JvmInnerTypeReference) JvmWildcardTypeReference(org.eclipse.xtext.common.types.JvmWildcardTypeReference) XSetLiteral(org.eclipse.xtext.xbase.XSetLiteral) JvmUpperBound(org.eclipse.xtext.common.types.JvmUpperBound) XSynchronizedExpression(org.eclipse.xtext.xbase.XSynchronizedExpression) XBooleanLiteral(org.eclipse.xtext.xbase.XBooleanLiteral) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XNullLiteral(org.eclipse.xtext.xbase.XNullLiteral) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) XtendFormalParameter(org.eclipse.xtend.core.xtend.XtendFormalParameter) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) Parameter(org.eclipse.xtext.Parameter) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral) XTryCatchFinallyExpression(org.eclipse.xtext.xbase.XTryCatchFinallyExpression) JvmParameterizedTypeReference(org.eclipse.xtext.common.types.JvmParameterizedTypeReference)

Example 3 with XCastedExpression

use of org.eclipse.xtext.xbase.XCastedExpression in project xtext-xtend by eclipse.

the class JavaConverterTest method testLambdaCase3.

@Test
public void testLambdaCase3() throws Exception {
    this.j2x.useRobustSyntax();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.Iterator;");
    _builder.newLine();
    _builder.append("class Clazz {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("Iterable<String> iter = new AbstractIterable<String>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("@Override");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("public Iterator<String> internalIterator() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("return null;");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("};");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("abstract static class AbstractIterable<T> implements Iterable<T> {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("@Override");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("public Iterator<T> iterator() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("return internalIterator();");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("public abstract Iterator<T> internalIterator();");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    XtendClass clazz = this.toValidXtendClass(_builder);
    Assert.assertNotNull(clazz);
    XtendField xtendMember = this.field(clazz, 0);
    Assert.assertEquals("iter", xtendMember.getName());
    XExpression _initialValue = xtendMember.getInitialValue();
    Assert.assertTrue((_initialValue instanceof XCastedExpression));
    XExpression _initialValue_1 = xtendMember.getInitialValue();
    XExpression _target = ((XCastedExpression) _initialValue_1).getTarget();
    Assert.assertTrue((_target instanceof XClosure));
}
Also used : XCastedExpression(org.eclipse.xtext.xbase.XCastedExpression) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XClosure(org.eclipse.xtext.xbase.XClosure) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XExpression(org.eclipse.xtext.xbase.XExpression) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 4 with XCastedExpression

use of org.eclipse.xtext.xbase.XCastedExpression in project xtext-xtend by eclipse.

the class XtendTypeComputer method _computeTypes.

protected void _computeTypes(RichString object, ITypeComputationState state) {
    List<XExpression> expressions = object.getExpressions();
    if (!expressions.isEmpty()) {
        for (XExpression expression : expressions) {
            ITypeComputationState expressionState = state.withoutExpectation();
            expressionState.computeTypes(expression);
            if (expression instanceof XVariableDeclaration) {
                addLocalToCurrentScope((XVariableDeclaration) expression, state);
            }
        }
    }
    for (ITypeExpectation expectation : state.getExpectations()) {
        LightweightTypeReference expectedType = expectation.getExpectedType();
        if (expectedType != null && expectedType.isType(StringConcatenation.class)) {
            expectation.acceptActualType(expectedType, ConformanceFlags.CHECKED_SUCCESS | ConformanceFlags.DEMAND_CONVERSION);
        } else if (expectedType != null && expectedType.isType(StringConcatenationClient.class)) {
            expectation.acceptActualType(expectedType, ConformanceFlags.CHECKED_SUCCESS | ConformanceFlags.DEMAND_CONVERSION);
        } else if (expectedType != null && expectedType.isType(String.class)) {
            expectation.acceptActualType(expectedType, ConformanceFlags.CHECKED_SUCCESS | ConformanceFlags.DEMAND_CONVERSION);
        // TODO this special treatment here should become obsolete as soon as the expectations are properly propagated
        } else if (!(object.eContainer() instanceof XCastedExpression) && object.eContainingFeature() != XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET && (expectedType != null && !expectedType.isResolved() || expectedType == null && !expectation.isVoidTypeAllowed())) {
            LightweightTypeReference type = getRawTypeForName(String.class, state);
            expectation.acceptActualType(type, ConformanceFlags.UNCHECKED | ConformanceFlags.DEMAND_CONVERSION);
        } else {
            LightweightTypeReference type = getRawTypeForName(CharSequence.class, state);
            expectation.acceptActualType(type, ConformanceFlags.UNCHECKED);
        }
    }
}
Also used : ITypeComputationState(org.eclipse.xtext.xbase.typesystem.computation.ITypeComputationState) XVariableDeclaration(org.eclipse.xtext.xbase.XVariableDeclaration) XCastedExpression(org.eclipse.xtext.xbase.XCastedExpression) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XExpression(org.eclipse.xtext.xbase.XExpression) RichString(org.eclipse.xtend.core.xtend.RichString) ITypeExpectation(org.eclipse.xtext.xbase.typesystem.computation.ITypeExpectation)

Example 5 with XCastedExpression

use of org.eclipse.xtext.xbase.XCastedExpression in project xtext-eclipse by eclipse.

the class RuleEngineSemanticSequencer 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 == RuleEnginePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case RuleEnginePackage.DEVICE:
                sequence_Device(context, (Device) semanticObject);
                return;
            case RuleEnginePackage.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
            case RuleEnginePackage.RULE:
                sequence_Rule(context, (Rule) semanticObject);
                return;
            case RuleEnginePackage.STATE:
                sequence_State(context, (State) 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 == 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.getXBlockExpressionRule() || 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.getXPrimaryExpressionRule() || rule == grammarAccess.getXParenthesizedExpressionRule() || 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.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.getXPrimaryExpressionRule() || 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:
                sequence_XListLiteral(context, (XListLiteral) semanticObject);
                return;
            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:
                sequence_XUnaryOperation(context, (XUnaryOperation) semanticObject);
                return;
            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 : XCatchClause(org.eclipse.xtext.xbase.XCatchClause) XDoWhileExpression(org.eclipse.xtext.xbase.XDoWhileExpression) ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) XBasicForLoopExpression(org.eclipse.xtext.xbase.XBasicForLoopExpression) XClosure(org.eclipse.xtext.xbase.XClosure) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) XPostfixOperation(org.eclipse.xtext.xbase.XPostfixOperation) XSwitchExpression(org.eclipse.xtext.xbase.XSwitchExpression) XBinaryOperation(org.eclipse.xtext.xbase.XBinaryOperation) XListLiteral(org.eclipse.xtext.xbase.XListLiteral) EPackage(org.eclipse.emf.ecore.EPackage) XInstanceOfExpression(org.eclipse.xtext.xbase.XInstanceOfExpression) XIfExpression(org.eclipse.xtext.xbase.XIfExpression) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) XCasePart(org.eclipse.xtext.xbase.XCasePart) XForLoopExpression(org.eclipse.xtext.xbase.XForLoopExpression) XNumberLiteral(org.eclipse.xtext.xbase.XNumberLiteral) XReturnExpression(org.eclipse.xtext.xbase.XReturnExpression) XAssignment(org.eclipse.xtext.xbase.XAssignment) XThrowExpression(org.eclipse.xtext.xbase.XThrowExpression) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XCastedExpression(org.eclipse.xtext.xbase.XCastedExpression) XVariableDeclaration(org.eclipse.xtext.xbase.XVariableDeclaration) XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) JvmLowerBound(org.eclipse.xtext.common.types.JvmLowerBound) Device(org.eclipse.xtext.example.homeautomation.ruleEngine.Device) XSetLiteral(org.eclipse.xtext.xbase.XSetLiteral) XConstructorCall(org.eclipse.xtext.xbase.XConstructorCall) XTypeLiteral(org.eclipse.xtext.xbase.XTypeLiteral) JvmUpperBound(org.eclipse.xtext.common.types.JvmUpperBound) XSynchronizedExpression(org.eclipse.xtext.xbase.XSynchronizedExpression) XBooleanLiteral(org.eclipse.xtext.xbase.XBooleanLiteral) JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) State(org.eclipse.xtext.example.homeautomation.ruleEngine.State) XNullLiteral(org.eclipse.xtext.xbase.XNullLiteral) XUnaryOperation(org.eclipse.xtext.xbase.XUnaryOperation) XWhileExpression(org.eclipse.xtext.xbase.XWhileExpression) Model(org.eclipse.xtext.example.homeautomation.ruleEngine.Model) JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) Parameter(org.eclipse.xtext.Parameter) ParserRule(org.eclipse.xtext.ParserRule) Rule(org.eclipse.xtext.example.homeautomation.ruleEngine.Rule) XTryCatchFinallyExpression(org.eclipse.xtext.xbase.XTryCatchFinallyExpression) JvmParameterizedTypeReference(org.eclipse.xtext.common.types.JvmParameterizedTypeReference)

Aggregations

XCastedExpression (org.eclipse.xtext.xbase.XCastedExpression)7 XClosure (org.eclipse.xtext.xbase.XClosure)4 EPackage (org.eclipse.emf.ecore.EPackage)3 Action (org.eclipse.xtext.Action)3 Parameter (org.eclipse.xtext.Parameter)3 ParserRule (org.eclipse.xtext.ParserRule)3 JvmLowerBound (org.eclipse.xtext.common.types.JvmLowerBound)3 JvmParameterizedTypeReference (org.eclipse.xtext.common.types.JvmParameterizedTypeReference)3 JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)3 JvmUpperBound (org.eclipse.xtext.common.types.JvmUpperBound)3 XAssignment (org.eclipse.xtext.xbase.XAssignment)3 XBasicForLoopExpression (org.eclipse.xtext.xbase.XBasicForLoopExpression)3 XBinaryOperation (org.eclipse.xtext.xbase.XBinaryOperation)3 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)3 XBooleanLiteral (org.eclipse.xtext.xbase.XBooleanLiteral)3 XCasePart (org.eclipse.xtext.xbase.XCasePart)3 XCatchClause (org.eclipse.xtext.xbase.XCatchClause)3 XConstructorCall (org.eclipse.xtext.xbase.XConstructorCall)3 XDoWhileExpression (org.eclipse.xtext.xbase.XDoWhileExpression)3 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)3