Search in sources :

Example 6 with ISetting

use of org.eclipse.titan.designer.AST.ISetting in project titan.EclipsePlug-ins by eclipse.

the class TableConstraint method collectTypesOfOpenType.

private void collectTypesOfOpenType(final CompilationTimeStamp aTimestamp, ObjectSet aObjectSet, final Open_Type aOpenType, final Identifier aObjectSetId) {
    if (aObjectSet instanceof Referenced_ObjectSet) {
        if (((Referenced_ObjectSet) aObjectSet).isReferencedDefinedReference()) {
            aObjectSet = aObjectSet.getRefdLast(aTimestamp, null);
        } else if (((Referenced_ObjectSet) aObjectSet).isReferencedInformationFromObj()) {
            // TODO: How to handle this?
            return;
        } else {
            // impossible, try it
            return;
        }
    }
    // now aObjectSet is instanceof ObjectSet_definition:
    List<IObjectSet_Element> oses = ((ObjectSet_definition) aObjectSet).getObjectSetElements();
    for (IObjectSet_Element ose : oses) {
        if (ose instanceof ReferencedObject) {
            // fspec
            ose = ((ReferencedObject) ose).getRefdLast(aTimestamp);
        }
        if (ose instanceof Object_Definition) {
            final Object_Definition od = (Object_Definition) ose;
            FieldSetting fs = od.getFieldSettingWithNameDefault(objectClassFieldname, false);
            if (fs != null) {
                // TODO: handle FieldSetting options: FieldSetting_Type, FieldSetting_ObjectSet, FieldSetting_Value
                if (fs instanceof FieldSetting_Type) {
                    final FieldSetting_Type fst = (FieldSetting_Type) fs;
                    final IASN1Type type = fst.getSetting();
                    final AtomicBoolean isStrange = new AtomicBoolean();
                    Identifier id = getOpenTypeAlternativeName(aTimestamp, (Type) type, isStrange);
                    if (!aOpenType.hasComponentWithName(id)) {
                        aOpenType.addComponent(new CompField(id, (Type) type, false, null));
                        if (isStrange.get()) {
                            aOpenType.getLocation().reportSemanticWarning(MessageFormat.format("Strange alternative name (`{0}') was added to open type `{1}'", id.getDisplayName(), aOpenType.getFullName()));
                        }
                    }
                } else {
                    // TODO: is it possible FieldSetting_ObjectSet, FieldSetting_Value ??
                    continue;
                }
            } else {
                fs = od.getFieldSettingWithNameDefault(aObjectSetId, false);
                if (fs == null) {
                    continue;
                }
                if (fs instanceof FieldSetting_ObjectSet) {
                    final ISetting objectSet1 = fs.getSetting();
                    ObjectSet objectSet2;
                    if (objectSet1 instanceof ObjectSet) {
                        objectSet2 = (ObjectSet) objectSet1;
                    } else {
                        // unexpected case
                        continue;
                    }
                    if (objectSet2 == aObjectSet) {
                        // to prevent infinite loop
                        continue;
                    }
                    collectTypesOfOpenType(aTimestamp, objectSet2, aOpenType, aObjectSetId);
                } else {
                    // TODO: is it possible??
                    continue;
                }
            }
        }
    }
    // for
    aOpenType.check(aTimestamp);
}
Also used : FieldSetting_Type(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_Type) ObjectSet_definition(org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition) FieldSetting_ObjectSet(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_ObjectSet) ISetting(org.eclipse.titan.designer.AST.ISetting) Referenced_ObjectSet(org.eclipse.titan.designer.AST.ASN1.Object.Referenced_ObjectSet) FieldSetting_ObjectSet(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_ObjectSet) FieldSetting(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) TTCN3_Set_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Type) ASN1_Sequence_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type) TTCN3_Choice_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type) Open_Type(org.eclipse.titan.designer.AST.ASN1.types.Open_Type) ASN1_Set_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type) FieldSetting_Type(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_Type) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) ObjectClassField_Type(org.eclipse.titan.designer.AST.ASN1.types.ObjectClassField_Type) TTCN3_Sequence_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type) Type(org.eclipse.titan.designer.AST.Type) ASN1_Choice_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type) IType(org.eclipse.titan.designer.AST.IType) Object_Definition(org.eclipse.titan.designer.AST.ASN1.Object.Object_Definition) Identifier(org.eclipse.titan.designer.AST.Identifier) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) ReferencedObject(org.eclipse.titan.designer.AST.ASN1.Object.ReferencedObject) Referenced_ObjectSet(org.eclipse.titan.designer.AST.ASN1.Object.Referenced_ObjectSet)

Example 7 with ISetting

use of org.eclipse.titan.designer.AST.ISetting in project titan.EclipsePlug-ins by eclipse.

the class ObjectClass_refd method getRefd.

protected ObjectClass getRefd(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    if (null != reference && referenceChain.add(this)) {
        final Assignment assignment = reference.getRefdAssignment(timestamp, true, referenceChain);
        if (null == assignment) {
            return newObjectClassDefinitionInstance();
        }
        final ISetting setting = reference.getRefdSetting(timestamp);
        if (Setting_type.S_ERROR.equals(setting.getSettingtype())) {
            return newObjectClassDefinitionInstance();
        } else if (!Setting_type.S_OC.equals(setting.getSettingtype())) {
            reference.getLocation().reportSemanticError(OBJECTCLASSEXPECTED);
            return newObjectClassDefinitionInstance();
        }
        return (ObjectClass) setting;
    }
    return newObjectClassDefinitionInstance();
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass) ISetting(org.eclipse.titan.designer.AST.ISetting)

Aggregations

ISetting (org.eclipse.titan.designer.AST.ISetting)7 Assignment (org.eclipse.titan.designer.AST.Assignment)5 ObjectSet_definition (org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition)2 Object_Definition (org.eclipse.titan.designer.AST.ASN1.Object.Object_Definition)2 ObjectClassField_Type (org.eclipse.titan.designer.AST.ASN1.types.ObjectClassField_Type)2 Open_Type (org.eclipse.titan.designer.AST.ASN1.types.Open_Type)2 IType (org.eclipse.titan.designer.AST.IType)2 Identifier (org.eclipse.titan.designer.AST.Identifier)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 ASN1Objects (org.eclipse.titan.designer.AST.ASN1.Object.ASN1Objects)1 FieldSetting (org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting)1 FieldSetting_ObjectSet (org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_ObjectSet)1 FieldSetting_Type (org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_Type)1 FieldSpecification (org.eclipse.titan.designer.AST.ASN1.Object.FieldSpecification)1 FixedTypeValue_FieldSpecification (org.eclipse.titan.designer.AST.ASN1.Object.FixedTypeValue_FieldSpecification)1 ObjectClass_Definition (org.eclipse.titan.designer.AST.ASN1.Object.ObjectClass_Definition)1 ObjectSetElementVisitor_objectCollector (org.eclipse.titan.designer.AST.ASN1.Object.ObjectSetElementVisitor_objectCollector)1 ObjectSet_FieldSpecification (org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_FieldSpecification)1 Object_FieldSpecification (org.eclipse.titan.designer.AST.ASN1.Object.Object_FieldSpecification)1 ReferencedObject (org.eclipse.titan.designer.AST.ASN1.Object.ReferencedObject)1