Search in sources :

Example 1 with AnytypeAttribute

use of org.eclipse.titan.designer.AST.TTCN3.attributes.AnytypeAttribute in project titan.EclipsePlug-ins by eclipse.

the class Anytype_Type method analyzeExtensionAttributes.

/**
 * Convert and check the anytype attributes applied to the module of this type.
 *
 * @param timestamp
 *                the timestamp of the actual build cycle.
 */
private void analyzeExtensionAttributes(final CompilationTimeStamp timestamp) {
    clear();
    final TTCN3Module myModule = (TTCN3Module) getMyScope().getModuleScope();
    final WithAttributesPath moduleAttributePath = myModule.getAttributePath();
    if (moduleAttributePath == null) {
        return;
    }
    final List<SingleWithAttribute> realAttributes = moduleAttributePath.getRealAttributes(timestamp);
    SingleWithAttribute attribute;
    List<AttributeSpecification> specifications = null;
    for (int i = 0; i < realAttributes.size(); i++) {
        attribute = realAttributes.get(i);
        if (Attribute_Type.Extension_Attribute.equals(attribute.getAttributeType())) {
            final Qualifiers qualifiers = attribute.getQualifiers();
            if (qualifiers == null || qualifiers.getNofQualifiers() == 0) {
                if (specifications == null) {
                    specifications = new ArrayList<AttributeSpecification>();
                }
                specifications.add(attribute.getAttributeSpecification());
            }
        }
    }
    if (specifications == null) {
        return;
    }
    final List<ExtensionAttribute> attributes = new ArrayList<ExtensionAttribute>();
    AttributeSpecification specification;
    for (int i = 0; i < specifications.size(); i++) {
        specification = specifications.get(i);
        final ExtensionAttributeAnalyzer analyzer = new ExtensionAttributeAnalyzer();
        analyzer.parse(specification);
        final List<ExtensionAttribute> temp = analyzer.getAttributes();
        if (temp != null) {
            attributes.addAll(temp);
        }
    }
    final Scope definitionsScope = myModule.getDefinitions();
    ExtensionAttribute extensionAttribute;
    for (int i = 0; i < attributes.size(); i++) {
        extensionAttribute = attributes.get(i);
        if (ExtensionAttribute_type.ANYTYPE.equals(extensionAttribute.getAttributeType())) {
            final AnytypeAttribute anytypeAttribute = (AnytypeAttribute) extensionAttribute;
            for (int j = 0; j < anytypeAttribute.getNofTypes(); j++) {
                final Type tempType = anytypeAttribute.getType(j);
                String fieldName;
                Identifier identifier = null;
                if (Type_type.TYPE_REFERENCED.equals(tempType.getTypetype())) {
                    final Reference reference = ((Referenced_Type) tempType).getReference();
                    identifier = reference.getId();
                    fieldName = identifier.getTtcnName();
                } else {
                    fieldName = tempType.getTypename();
                    identifier = new Identifier(Identifier_type.ID_TTCN, fieldName);
                }
                tempType.setMyScope(definitionsScope);
                addComp(new CompField(identifier, tempType, false, null));
            }
        }
    }
}
Also used : WithAttributesPath(org.eclipse.titan.designer.AST.TTCN3.attributes.WithAttributesPath) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) ArrayList(java.util.ArrayList) SingleWithAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute) AnytypeAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.AnytypeAttribute) ExtensionAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionAttribute) AttributeSpecification(org.eclipse.titan.designer.AST.TTCN3.attributes.AttributeSpecification) Attribute_Type(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) Scope(org.eclipse.titan.designer.AST.Scope) ExtensionAttributeAnalyzer(org.eclipse.titan.designer.parsers.extensionattributeparser.ExtensionAttributeAnalyzer) Qualifiers(org.eclipse.titan.designer.AST.TTCN3.attributes.Qualifiers)

Aggregations

ArrayList (java.util.ArrayList)1 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)1 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)1 ISubReference (org.eclipse.titan.designer.AST.ISubReference)1 IType (org.eclipse.titan.designer.AST.IType)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)1 Reference (org.eclipse.titan.designer.AST.Reference)1 Scope (org.eclipse.titan.designer.AST.Scope)1 AnytypeAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.AnytypeAttribute)1 AttributeSpecification (org.eclipse.titan.designer.AST.TTCN3.attributes.AttributeSpecification)1 ExtensionAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionAttribute)1 Qualifiers (org.eclipse.titan.designer.AST.TTCN3.attributes.Qualifiers)1 SingleWithAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute)1 Attribute_Type (org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type)1 WithAttributesPath (org.eclipse.titan.designer.AST.TTCN3.attributes.WithAttributesPath)1 TTCN3Module (org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)1 Type (org.eclipse.titan.designer.AST.Type)1 ExtensionAttributeAnalyzer (org.eclipse.titan.designer.parsers.extensionattributeparser.ExtensionAttributeAnalyzer)1