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));
}
}
}
}
Aggregations