use of org.eclipse.n4js.ts.typeRefs.UnionTypeExpression in project n4js by eclipse.
the class InternalTypeSystem method applyRuleExpectedTypeInRelationalExpression.
protected Result<TypeRef> applyRuleExpectedTypeInRelationalExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final RelationalExpression e, final Expression expression) throws RuleFailedException {
// output parameter
TypeRef T = null;
RelationalOperator _op = e.getOp();
if (_op != null) {
switch(_op) {
case INSTANCEOF:
Expression _rhs = e.getRhs();
boolean _tripleEquals = (expression == _rhs);
if (_tripleEquals) {
T = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.functionTypeRef(G), TypeUtils.createTypeTypeRef(RuleEnvironmentExtensions.objectTypeRef(G), false), TypeUtils.createTypeTypeRef(RuleEnvironmentExtensions.n4EnumTypeRef(G), false));
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
break;
case IN:
Expression _rhs_1 = e.getRhs();
boolean _tripleEquals_1 = (expression == _rhs_1);
if (_tripleEquals_1) {
T = RuleEnvironmentExtensions.objectTypeRef(G);
} else {
boolean _isTypeAware = this.jsVariantHelper.isTypeAware(e);
if (_isTypeAware) {
T = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G));
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
}
break;
default:
boolean _isTypeAware_1 = this.jsVariantHelper.isTypeAware(e);
if (_isTypeAware_1) {
final UnionTypeExpression primsTR = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G), RuleEnvironmentExtensions.booleanTypeRef(G));
Expression _xifexpression = null;
Expression _lhs = e.getLhs();
boolean _tripleEquals_2 = (expression == _lhs);
if (_tripleEquals_2) {
_xifexpression = e.getRhs();
} else {
_xifexpression = e.getLhs();
}
final Expression otherSide = _xifexpression;
/* G |- otherSide : var TypeRef otherSideTR */
TypeRef otherSideTR = null;
Result<TypeRef> result = typeInternal(G, _trace_, otherSide);
checkAssignableTo(result.getFirst(), TypeRef.class);
otherSideTR = (TypeRef) result.getFirst();
boolean _and = false;
/* G |- otherSideTR <: primsTR */
boolean _ruleinvocation = subtypeSucceeded(G, _trace_, otherSideTR, primsTR);
if (!_ruleinvocation) {
_and = false;
} else {
/* G |- otherSideTR <: G.nullTypeRef */
ParameterizedTypeRef _nullTypeRef = RuleEnvironmentExtensions.nullTypeRef(G);
boolean _ruleinvocation_1 = subtypeSucceeded(G, _trace_, otherSideTR, _nullTypeRef);
boolean _not = (!_ruleinvocation_1);
_and = _not;
}
if (_and) {
T = otherSideTR;
} else {
T = primsTR;
}
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
break;
}
} else {
boolean _isTypeAware_1 = this.jsVariantHelper.isTypeAware(e);
if (_isTypeAware_1) {
final UnionTypeExpression primsTR = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G), RuleEnvironmentExtensions.booleanTypeRef(G));
Expression _xifexpression = null;
Expression _lhs = e.getLhs();
boolean _tripleEquals_2 = (expression == _lhs);
if (_tripleEquals_2) {
_xifexpression = e.getRhs();
} else {
_xifexpression = e.getLhs();
}
final Expression otherSide = _xifexpression;
/* G |- otherSide : var TypeRef otherSideTR */
TypeRef otherSideTR = null;
Result<TypeRef> result = typeInternal(G, _trace_, otherSide);
checkAssignableTo(result.getFirst(), TypeRef.class);
otherSideTR = (TypeRef) result.getFirst();
boolean _and = false;
/* G |- otherSideTR <: primsTR */
boolean _ruleinvocation = subtypeSucceeded(G, _trace_, otherSideTR, primsTR);
if (!_ruleinvocation) {
_and = false;
} else {
/* G |- otherSideTR <: G.nullTypeRef */
ParameterizedTypeRef _nullTypeRef = RuleEnvironmentExtensions.nullTypeRef(G);
boolean _ruleinvocation_1 = subtypeSucceeded(G, _trace_, otherSideTR, _nullTypeRef);
boolean _not = (!_ruleinvocation_1);
_and = _not;
}
if (_and) {
T = otherSideTR;
} else {
T = primsTR;
}
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
}
return new Result<TypeRef>(T);
}
use of org.eclipse.n4js.ts.typeRefs.UnionTypeExpression in project n4js by eclipse.
the class MemberVisibilityChecker method isVisible.
/**
* Returns the MemberVisibility of the <i>member</i> of the <i>receiverType</> in the given <i>context</i>
* <i>supercall</i> indicates if the target of the context is the super type.
*/
private MemberVisibility isVisible(EObject context, TypeRef receiverType, TMember member, boolean supercall) {
// special case: union types
if (receiverType instanceof UnionTypeExpression) {
// because we use the combined accessibility for all members
for (TypeRef currUnitedTypeRef : ((UnionTypeExpression) receiverType).getTypeRefs()) if (!isVisible(context, currUnitedTypeRef, member, supercall).visibility)
return new MemberVisibility(false);
return new MemberVisibility(true);
}
// standard case:
Resource contextResource = context.eResource();
N4TypeDefinition typeDefiningContainer = EcoreUtil2.getContainerOfType(context, N4TypeDefinition.class);
Script script = EcoreUtil2.getContainerOfType(typeDefiningContainer != null ? typeDefiningContainer : context, Script.class);
Type contextType = null;
TModule contextModule = script.getModule();
if (typeDefiningContainer != null) {
contextType = typeDefiningContainer.getDefinedType();
}
Type declaredReceiverType = getActualDeclaredReceiverType(context, receiverType, contextResource.getResourceSet());
if (declaredReceiverType != null && typeVisibilityChecker.isVisible(contextResource, declaredReceiverType).visibility) {
// check for local usage of locally defined member
if (shortcutIsVisible(member, contextType, contextModule, declaredReceiverType)) {
return new MemberVisibility(true);
}
return isVisible(contextModule, contextType, declaredReceiverType, member, supercall);
}
return new MemberVisibility(false);
}
use of org.eclipse.n4js.ts.typeRefs.UnionTypeExpression in project n4js by eclipse.
the class TypeUtils method createNonSimplifiedUnionType.
/**
* Creates a new union type with the given elements. The elements are copied if they have a container. The created
* union type may contain duplicates or nested union types, that is, it is not simplified! Thus, the returned type
* is expected to be processed further!
*
* @see org.eclipse.n4js.typesystem.N4JSTypeSystem#createSimplifiedUnion(List, Resource)
* @see org.eclipse.n4js.typesystem.TypeSystemHelper#simplify(RuleEnvironment, ComposedTypeRef)
*/
@SuppressWarnings("javadoc")
public static UnionTypeExpression createNonSimplifiedUnionType(Iterable<? extends TypeRef> elements) {
UnionTypeExpression unionType = TypeRefsFactory.eINSTANCE.createUnionTypeExpression();
EList<TypeRef> unionElements = unionType.getTypeRefs();
for (TypeRef e : elements) {
unionElements.add(TypeUtils.copyIfContained(e));
}
return unionType;
}
use of org.eclipse.n4js.ts.typeRefs.UnionTypeExpression in project n4js by eclipse.
the class TypesSemanticSequencer 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 == TypeRefsPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case TypeRefsPackage.FUNCTION_TYPE_EXPRESSION:
if (rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_ArrowFunctionTypeExpression_ColonSepReturnTypeRef_FunctionTypeExpressionOLD_TAnonymousFormalParameterList_TypeRef_TypeRefWithModifiers(context, (FunctionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getArrowFunctionTypeExpressionRule()) {
sequence_ArrowFunctionTypeExpression_TAnonymousFormalParameterList(context, (FunctionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule() || rule == grammarAccess.getFunctionTypeExpressionOLDRule()) {
sequence_ColonSepReturnTypeRef_FunctionTypeExpressionOLD_TAnonymousFormalParameterList(context, (FunctionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_ColonSepReturnTypeRef_FunctionTypeExpressionOLD_TAnonymousFormalParameterList_TypeRefWithModifiers(context, (FunctionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_ColonSepReturnTypeRef_FunctionTypeExpressionOLD_TAnonymousFormalParameterList_TypeRef(context, (FunctionTypeExpression) semanticObject);
return;
} else
break;
case TypeRefsPackage.INTERSECTION_TYPE_EXPRESSION:
if (rule == grammarAccess.getTypeRefWithoutModifiersRule() || rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getIntersectionTypeExpressionOLDRule()) {
sequence_IntersectionTypeExpressionOLD(context, (IntersectionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_IntersectionTypeExpressionOLD_TypeRefWithModifiers(context, (IntersectionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_IntersectionTypeExpressionOLD_TypeRef(context, (IntersectionTypeExpression) semanticObject);
return;
} else if (action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_IntersectionTypeExpressionOLD_TypeRef_TypeRefWithModifiers(context, (IntersectionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getIntersectionTypeExpressionRule()) {
sequence_IntersectionTypeExpression_IntersectionTypeExpressionOLD_TypeRef_TypeRefWithModifiers(context, (IntersectionTypeExpression) semanticObject);
return;
} else
break;
case TypeRefsPackage.PARAMETERIZED_TYPE_REF:
if (rule == grammarAccess.getArrayTypeRefRule()) {
sequence_ArrayTypeRef(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefFunctionTypeExpressionRule()) {
sequence_ArrayTypeRef_TypeAndTypeArguments_TypeArguments(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_ArrayTypeRef_TypeAndTypeArguments_TypeArguments_TypeRef_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeArgInTypeTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefNominalRule() || rule == grammarAccess.getTypeAndTypeArgumentsRule()) {
sequence_TypeAndTypeArguments_TypeArguments(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRefWithoutModifiers(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRef_TypeRefWithoutModifiers(context, (ParameterizedTypeRef) semanticObject);
return;
} else
break;
case TypeRefsPackage.PARAMETERIZED_TYPE_REF_STRUCTURAL:
if (rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getParameterizedTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefStructuralRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments(context, (ParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRefWithoutModifiers(context, (ParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRef_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRef_TypeRefWithoutModifiers(context, (ParameterizedTypeRefStructural) semanticObject);
return;
} else
break;
case TypeRefsPackage.THIS_TYPE_REF_NOMINAL:
if (rule == grammarAccess.getTypeArgInTypeTypeRefRule() || rule == grammarAccess.getThisTypeRefRule() || rule == grammarAccess.getThisTypeRefNominalRule()) {
sequence_ThisTypeRefNominal(context, (ThisTypeRefNominal) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_ThisTypeRefNominal_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ThisTypeRefNominal) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_ThisTypeRefNominal_TypeRefWithoutModifiers(context, (ThisTypeRefNominal) semanticObject);
return;
} else if (rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_ThisTypeRefNominal_TypeRef_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ThisTypeRefNominal) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_ThisTypeRefNominal_TypeRef_TypeRefWithoutModifiers(context, (ThisTypeRefNominal) semanticObject);
return;
} else
break;
case TypeRefsPackage.THIS_TYPE_REF_STRUCTURAL:
if (rule == grammarAccess.getThisTypeRefRule() || rule == grammarAccess.getThisTypeRefStructuralRule()) {
sequence_TStructMemberList_ThisTypeRefStructural(context, (ThisTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_TStructMemberList_ThisTypeRefStructural_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ThisTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_TStructMemberList_ThisTypeRefStructural_TypeRefWithoutModifiers(context, (ThisTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_TStructMemberList_ThisTypeRefStructural_TypeRef_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ThisTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_TStructMemberList_ThisTypeRefStructural_TypeRef_TypeRefWithoutModifiers(context, (ThisTypeRefStructural) semanticObject);
return;
} else
break;
case TypeRefsPackage.TYPE_TYPE_REF:
if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_TypeRefWithModifiers_TypeTypeRef(context, (TypeTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_TypeRef_TypeRefWithModifiers_TypeTypeRef(context, (TypeTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_TypeRef_TypeTypeRef(context, (TypeTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule() || rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getTypeTypeRefRule()) {
sequence_TypeTypeRef(context, (TypeTypeRef) semanticObject);
return;
} else
break;
case TypeRefsPackage.UNION_TYPE_EXPRESSION:
if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_TypeRefWithModifiers_UnionTypeExpressionOLD(context, (UnionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_TypeRef_TypeRefWithModifiers_UnionTypeExpressionOLD(context, (UnionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_TypeRef_UnionTypeExpressionOLD(context, (UnionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule() || rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getUnionTypeExpressionOLDRule()) {
sequence_UnionTypeExpressionOLD(context, (UnionTypeExpression) semanticObject);
return;
} else
break;
case TypeRefsPackage.VERSIONED_PARAMETERIZED_TYPE_REF:
if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRefWithModifiers_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRef_TypeRefWithModifiers_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRef_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getTypeArgInTypeTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefNominalRule() || rule == grammarAccess.getTypeAndTypeArgumentsRule()) {
sequence_TypeAndTypeArguments_TypeArguments_VersionRequest(context, (VersionedParameterizedTypeRef) semanticObject);
return;
} else
break;
case TypeRefsPackage.VERSIONED_PARAMETERIZED_TYPE_REF_STRUCTURAL:
if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRefWithModifiers_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRef_TypeRefWithModifiers_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRef_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getParameterizedTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefStructuralRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_VersionRequest(context, (VersionedParameterizedTypeRefStructural) semanticObject);
return;
} else
break;
case TypeRefsPackage.WILDCARD:
if (rule == grammarAccess.getWildcardNewNotationRule()) {
sequence_WildcardNewNotation(context, (Wildcard) semanticObject);
return;
} else if (rule == grammarAccess.getTypeArgInTypeTypeRefRule() || rule == grammarAccess.getWildcardRule()) {
sequence_Wildcard(context, (Wildcard) semanticObject);
return;
} else if (rule == grammarAccess.getTypeArgumentRule()) {
sequence_Wildcard_WildcardNewNotation(context, (Wildcard) semanticObject);
return;
} else
break;
}
else if (epackage == TypesPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case TypesPackage.ANY_TYPE:
sequence_AnyType(context, (AnyType) semanticObject);
return;
case TypesPackage.NULL_TYPE:
sequence_NullType(context, (NullType) semanticObject);
return;
case TypesPackage.PRIMITIVE_TYPE:
sequence_PrimitiveType(context, (PrimitiveType) semanticObject);
return;
case TypesPackage.TANNOTATION:
sequence_TAnnotation(context, (TAnnotation) semanticObject);
return;
case TypesPackage.TANNOTATION_STRING_ARGUMENT:
sequence_TAnnotationStringArgument(context, (TAnnotationStringArgument) semanticObject);
return;
case TypesPackage.TANNOTATION_TYPE_REF_ARGUMENT:
sequence_TAnnotationTypeRefArgument(context, (TAnnotationTypeRefArgument) semanticObject);
return;
case TypesPackage.TANONYMOUS_FORMAL_PARAMETER:
sequence_ColonSepTypeRef_DefaultFormalParameter_TAnonymousFormalParameter(context, (TAnonymousFormalParameter) semanticObject);
return;
case TypesPackage.TCLASS:
sequence_TClass_TClassOrInterfaceHeader(context, (TClass) semanticObject);
return;
case TypesPackage.TENUM:
sequence_TEnum(context, (TEnum) semanticObject);
return;
case TypesPackage.TENUM_LITERAL:
sequence_TEnumLiteral(context, (TEnumLiteral) semanticObject);
return;
case TypesPackage.TFIELD:
sequence_ColonSepTypeRef_TField(context, (TField) semanticObject);
return;
case TypesPackage.TFORMAL_PARAMETER:
sequence_ColonSepTypeRef_DefaultFormalParameter_TFormalParameter(context, (TFormalParameter) semanticObject);
return;
case TypesPackage.TFUNCTION:
sequence_ColonSepReturnTypeRef_TFormalParameters_TFunction_TypeVariables(context, (TFunction) semanticObject);
return;
case TypesPackage.TGETTER:
sequence_ColonSepDeclaredTypeRef_TGetter(context, (TGetter) semanticObject);
return;
case TypesPackage.TINTERFACE:
sequence_TClassOrInterfaceHeader_TInterface(context, (TInterface) semanticObject);
return;
case TypesPackage.TMETHOD:
if (rule == grammarAccess.getCallableCtorRule()) {
sequence_CallableCtor_ColonSepReturnTypeRef_TFormalParameters(context, (TMethod) semanticObject);
return;
} else if (rule == grammarAccess.getTMemberRule() || rule == grammarAccess.getTMethodRule()) {
sequence_ColonSepReturnTypeRef_TFormalParameters_TMethod_TypeVariables(context, (TMethod) semanticObject);
return;
} else
break;
case TypesPackage.TOBJECT_PROTOTYPE:
sequence_TObjectPrototype_TypeVariables(context, (TObjectPrototype) semanticObject);
return;
case TypesPackage.TSETTER:
sequence_TSetter(context, (TSetter) semanticObject);
return;
case TypesPackage.TSTRUCT_FIELD:
sequence_ColonSepTypeRef_TStructField(context, (TStructField) semanticObject);
return;
case TypesPackage.TSTRUCT_GETTER:
sequence_ColonSepDeclaredTypeRef_TStructGetter(context, (TStructGetter) semanticObject);
return;
case TypesPackage.TSTRUCT_METHOD:
sequence_ColonSepReturnTypeRef_TAnonymousFormalParameterList_TStructMethod_TypeVariables(context, (TStructMethod) semanticObject);
return;
case TypesPackage.TSTRUCT_SETTER:
sequence_TStructSetter(context, (TStructSetter) semanticObject);
return;
case TypesPackage.TYPE_DEFS:
sequence_TypeDefs(context, (TypeDefs) semanticObject);
return;
case TypesPackage.TYPE_VARIABLE:
if (rule == grammarAccess.getTypeRule() || rule == grammarAccess.getTypeVariableRule()) {
sequence_TypeVariable(context, (TypeVariable) semanticObject);
return;
} else if (rule == grammarAccess.getTypeExpressionsTypeVariableRule()) {
sequence_TypeVariable(context, (TypeVariable) semanticObject);
return;
} else
break;
case TypesPackage.UNDEFINED_TYPE:
sequence_UndefinedType(context, (UndefinedType) semanticObject);
return;
case TypesPackage.VIRTUAL_BASE_TYPE:
sequence_VirtualBaseType(context, (VirtualBaseType) semanticObject);
return;
case TypesPackage.VOID_TYPE:
sequence_VoidType(context, (VoidType) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.n4js.ts.typeRefs.UnionTypeExpression in project n4js by eclipse.
the class TypeExpressionsSemanticSequencer 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 == TypeRefsPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case TypeRefsPackage.FUNCTION_TYPE_EXPRESSION:
if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_ArrowFunctionTypeExpression_ColonSepReturnTypeRef_FunctionTypeExpressionOLD_TAnonymousFormalParameterList_TypeRefWithModifiers(context, (FunctionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getArrowFunctionTypeExpressionRule()) {
sequence_ArrowFunctionTypeExpression_TAnonymousFormalParameterList(context, (FunctionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule() || rule == grammarAccess.getFunctionTypeExpressionOLDRule()) {
sequence_ColonSepReturnTypeRef_FunctionTypeExpressionOLD_TAnonymousFormalParameterList(context, (FunctionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_ColonSepReturnTypeRef_FunctionTypeExpressionOLD_TAnonymousFormalParameterList_TypeRefWithModifiers(context, (FunctionTypeExpression) semanticObject);
return;
} else
break;
case TypeRefsPackage.INTERSECTION_TYPE_EXPRESSION:
if (rule == grammarAccess.getTypeRefWithoutModifiersRule() || rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getIntersectionTypeExpressionOLDRule()) {
sequence_IntersectionTypeExpressionOLD(context, (IntersectionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_IntersectionTypeExpressionOLD_TypeRefWithModifiers(context, (IntersectionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_IntersectionTypeExpression_IntersectionTypeExpressionOLD_TypeRefWithModifiers(context, (IntersectionTypeExpression) semanticObject);
return;
} else
break;
case TypeRefsPackage.PARAMETERIZED_TYPE_REF:
if (rule == grammarAccess.getArrayTypeRefRule()) {
sequence_ArrayTypeRef(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefFunctionTypeExpressionRule()) {
sequence_ArrayTypeRef_TypeAndTypeArguments_TypeArguments(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_ArrayTypeRef_TypeAndTypeArguments_TypeArguments_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeArgInTypeTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefNominalRule() || rule == grammarAccess.getTypeAndTypeArgumentsRule()) {
sequence_TypeAndTypeArguments_TypeArguments(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRefWithoutModifiers(context, (ParameterizedTypeRef) semanticObject);
return;
} else
break;
case TypeRefsPackage.PARAMETERIZED_TYPE_REF_STRUCTURAL:
if (rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getParameterizedTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefStructuralRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments(context, (ParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeRefWithModifiersRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRefWithoutModifiers(context, (ParameterizedTypeRefStructural) semanticObject);
return;
} else
break;
case TypeRefsPackage.THIS_TYPE_REF_NOMINAL:
if (rule == grammarAccess.getTypeArgInTypeTypeRefRule() || rule == grammarAccess.getThisTypeRefRule() || rule == grammarAccess.getThisTypeRefNominalRule()) {
sequence_ThisTypeRefNominal(context, (ThisTypeRefNominal) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeRefWithModifiersRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_ThisTypeRefNominal_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ThisTypeRefNominal) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_ThisTypeRefNominal_TypeRefWithoutModifiers(context, (ThisTypeRefNominal) semanticObject);
return;
} else
break;
case TypeRefsPackage.THIS_TYPE_REF_STRUCTURAL:
if (rule == grammarAccess.getThisTypeRefRule() || rule == grammarAccess.getThisTypeRefStructuralRule()) {
sequence_TStructMemberList_ThisTypeRefStructural(context, (ThisTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeRefWithModifiersRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_TStructMemberList_ThisTypeRefStructural_TypeRefWithModifiers_TypeRefWithoutModifiers(context, (ThisTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_TStructMemberList_ThisTypeRefStructural_TypeRefWithoutModifiers(context, (ThisTypeRefStructural) semanticObject);
return;
} else
break;
case TypeRefsPackage.TYPE_TYPE_REF:
if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeRefWithModifiersRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_TypeRefWithModifiers_TypeTypeRef(context, (TypeTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule() || rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getTypeTypeRefRule()) {
sequence_TypeTypeRef(context, (TypeTypeRef) semanticObject);
return;
} else
break;
case TypeRefsPackage.UNION_TYPE_EXPRESSION:
if (rule == grammarAccess.getTypeRefWithModifiersRule()) {
sequence_TypeRefWithModifiers_UnionTypeExpressionOLD(context, (UnionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_TypeRef_TypeRefWithModifiers_UnionTypeExpressionOLD(context, (UnionTypeExpression) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule() || rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getUnionTypeExpressionOLDRule()) {
sequence_UnionTypeExpressionOLD(context, (UnionTypeExpression) semanticObject);
return;
} else
break;
case TypeRefsPackage.VERSIONED_PARAMETERIZED_TYPE_REF:
if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeRefWithModifiersRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRefWithModifiers_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_TypeAndTypeArguments_TypeArguments_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRef) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getTypeArgInTypeTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefNominalRule() || rule == grammarAccess.getTypeAndTypeArgumentsRule()) {
sequence_TypeAndTypeArguments_TypeArguments_VersionRequest(context, (VersionedParameterizedTypeRef) semanticObject);
return;
} else
break;
case TypeRefsPackage.VERSIONED_PARAMETERIZED_TYPE_REF_STRUCTURAL:
if (rule == grammarAccess.getTypeRefRule() || action == grammarAccess.getTypeRefAccess().getUnionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getIntersectionTypeExpressionRule() || action == grammarAccess.getIntersectionTypeExpressionAccess().getIntersectionTypeExpressionTypeRefsAction_1_0() || rule == grammarAccess.getPrimaryTypeExpressionRule() || rule == grammarAccess.getTypeRefWithModifiersRule() || rule == grammarAccess.getTypeArgumentRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRefWithModifiers_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefWithoutModifiersRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_TypeRefWithoutModifiers_VersionRequest(context, (VersionedParameterizedTypeRefStructural) semanticObject);
return;
} else if (rule == grammarAccess.getTypeRefFunctionTypeExpressionRule() || rule == grammarAccess.getParameterizedTypeRefRule() || rule == grammarAccess.getParameterizedTypeRefStructuralRule()) {
sequence_ParameterizedTypeRefStructural_TStructMemberList_TypeArguments_VersionRequest(context, (VersionedParameterizedTypeRefStructural) semanticObject);
return;
} else
break;
case TypeRefsPackage.WILDCARD:
if (rule == grammarAccess.getWildcardNewNotationRule()) {
sequence_WildcardNewNotation(context, (Wildcard) semanticObject);
return;
} else if (rule == grammarAccess.getTypeArgInTypeTypeRefRule() || rule == grammarAccess.getWildcardRule()) {
sequence_Wildcard(context, (Wildcard) semanticObject);
return;
} else if (rule == grammarAccess.getTypeArgumentRule()) {
sequence_Wildcard_WildcardNewNotation(context, (Wildcard) semanticObject);
return;
} else
break;
}
else if (epackage == TypesPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case TypesPackage.TANONYMOUS_FORMAL_PARAMETER:
sequence_ColonSepTypeRef_DefaultFormalParameter_TAnonymousFormalParameter(context, (TAnonymousFormalParameter) semanticObject);
return;
case TypesPackage.TFORMAL_PARAMETER:
sequence_ColonSepTypeRef_DefaultFormalParameter_TFormalParameter(context, (TFormalParameter) semanticObject);
return;
case TypesPackage.TSTRUCT_FIELD:
sequence_ColonSepTypeRef_TStructField(context, (TStructField) semanticObject);
return;
case TypesPackage.TSTRUCT_GETTER:
sequence_ColonSepDeclaredTypeRef_TStructGetter(context, (TStructGetter) semanticObject);
return;
case TypesPackage.TSTRUCT_METHOD:
sequence_ColonSepReturnTypeRef_TAnonymousFormalParameterList_TStructMethod_TypeVariables(context, (TStructMethod) semanticObject);
return;
case TypesPackage.TSTRUCT_SETTER:
sequence_TStructSetter(context, (TStructSetter) semanticObject);
return;
case TypesPackage.TYPE_VARIABLE:
sequence_TypeVariable(context, (TypeVariable) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Aggregations