use of org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute in project titan.EclipsePlug-ins by eclipse.
the class Type method checkDoneAttribute.
@Override
public final /**
* {@inheritDoc}
*/
void checkDoneAttribute(final CompilationTimeStamp timestamp) {
hasDone = false;
if (withAttributesPath == null) {
return;
}
final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
for (int i = 0, size = realAttributes.size(); i < size; i++) {
final SingleWithAttribute singleAttribute = realAttributes.get(i);
if (Attribute_Type.Extension_Attribute.equals(singleAttribute.getAttributeType()) && "done".equals(singleAttribute.getAttributeSpecification().getSpecification())) {
hasDone = true;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute in project titan.EclipsePlug-ins by eclipse.
the class Type method checkThisVariant.
@Override
public /**
* {@inheritDoc}
*/
void checkThisVariant(final CompilationTimeStamp timestamp, final SingleWithAttribute singleWithAttribute, final boolean global) {
final IType type = getTypeWithCodingTable(timestamp, false);
if (type == null) {
// FIXME as only RAW is supported for now, we can not report this error
// if (!global) {
// singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("No encoding rules defined for type `{0}''", getTypename()));
// }
} else {
final List<String> codingStrings = singleWithAttribute.getAttributeSpecification().getEncodings();
// gather the built-in codecs referred to by the variant's encoding strings
final ArrayList<MessageEncoding_type> codings = new ArrayList<IType.MessageEncoding_type>();
boolean erroneous = false;
if (codingStrings == null) {
if (type.getCodingTable().size() > 1) {
if (!global) {
singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("The encoding reference is mandatory for variant attributes of type `{0}''", getTypename()));
}
erroneous = true;
} else if (type.getCodingTable().get(0).builtIn) {
codings.add(type.getCodingTable().get(0).builtInCoding);
} else {
// PER or custom encoding
final MessageEncoding_type coding = "PER".equals(type.getCodingTable().get(0).customCoding.name) ? MessageEncoding_type.PER : MessageEncoding_type.CUSTOM;
singleWithAttribute.getLocation().reportSemanticWarning(MessageFormat.format("Variant attributes related to `{0}'' encoding are ignored", coding.getEncodingName()));
}
} else {
for (int i = 0; i < codingStrings.size(); i++) {
final String encodingString = codingStrings.get(i);
final MessageEncoding_type coding = getEncodingType(encodingString);
if (!hasEncoding(timestamp, coding, encodingString)) {
erroneous = true;
// FIXME RAW restriction only exists because that is the only supported encoding right now
if (!global && coding == MessageEncoding_type.RAW) {
if (coding == MessageEncoding_type.CUSTOM) {
singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not support {1} encoding", getTypename(), coding.getEncodingName()));
} else {
singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not support custom encoding `{1}''", getTypename(), encodingString));
}
}
} else if (coding != MessageEncoding_type.PER && coding != MessageEncoding_type.CUSTOM) {
codings.add(coding);
} else {
// PER or custom encoding
singleWithAttribute.getLocation().reportSemanticWarning(MessageFormat.format("Variant attributes related to {0} encoding are ignored", coding.getEncodingName()));
}
}
}
// FIXME implement checks
// TODO only raw data is extracted
final VariantAttributeAnalyzer analyzer = new VariantAttributeAnalyzer();
boolean newRaw = false;
final AtomicBoolean rawFoud = new AtomicBoolean(false);
if (rawAttribute == null) {
IType t_refd = this;
while (t_refd.getRawAttribute() == null && t_refd instanceof Referenced_Type) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
t_refd = ((Referenced_Type) t_refd).getTypeRefd(timestamp, referenceChain);
referenceChain.release();
}
rawAttribute = new RawAST(t_refd.getRawAttribute(), getDefaultRawFieldLength());
newRaw = true;
}
analyzer.parse(rawAttribute, singleWithAttribute.getAttributeSpecification(), getLengthMultiplier(), rawFoud);
if (!rawFoud.get() && newRaw) {
rawAttribute = null;
}
}
if (global) {
// send global variant attributes to field/element types
switch(getTypetype()) {
case TYPE_TTCN3_CHOICE:
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
for (int i = 0; i < ((TTCN3_Set_Seq_Choice_BaseType) this).getNofComponents(); i++) {
((TTCN3_Set_Seq_Choice_BaseType) this).getComponentByIndex(i).getType().checkThisVariant(timestamp, singleWithAttribute, global);
}
break;
case TYPE_ASN1_CHOICE:
case TYPE_ASN1_SEQUENCE:
case TYPE_ASN1_SET:
for (int i = 0; i < ((ASN1_Set_Seq_Choice_BaseType) this).getNofComponents(timestamp); i++) {
((ASN1_Set_Seq_Choice_BaseType) this).getComponentByIndex(i).getType().checkThisVariant(timestamp, singleWithAttribute, global);
}
break;
case TYPE_ANYTYPE:
for (int i = 0; i < ((Anytype_Type) this).getNofComponents(); i++) {
((Anytype_Type) this).getComponentByIndex(i).getType().checkThisVariant(timestamp, singleWithAttribute, global);
}
break;
case TYPE_OPENTYPE:
for (int i = 0; i < ((Open_Type) this).getNofComponents(); i++) {
((Open_Type) this).getComponentByIndex(i).getType().checkThisVariant(timestamp, singleWithAttribute, global);
}
break;
case TYPE_ARRAY:
((Array_Type) this).getElementType().checkThisVariant(timestamp, singleWithAttribute, global);
break;
case TYPE_SEQUENCE_OF:
((SequenceOf_Type) this).getOfType().checkThisVariant(timestamp, singleWithAttribute, global);
break;
case TYPE_SET_OF:
((SetOf_Type) this).getOfType().checkThisVariant(timestamp, singleWithAttribute, global);
break;
default:
break;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute in project titan.EclipsePlug-ins by eclipse.
the class PortTypeBody method checkAttributes.
/**
* Does the semantic checking of the attributes assigned to the port type having this body.
*
* @param timestamp the time stamp of the actual semantic check cycle.
* @param withAttributesPath the withAttributesPath assigned to the port type.
*/
public void checkAttributes(final CompilationTimeStamp timestamp, final WithAttributesPath withAttributesPath) {
if (lastTimeAttributesChecked != null && !lastTimeAttributesChecked.isLess(timestamp)) {
return;
}
lastTimeAttributesChecked = lastTimeChecked;
final List<SingleWithAttribute> realAttributes = withAttributesPath.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>();
}
final AttributeSpecification specification = attribute.getAttributeSpecification();
if (specification.getSpecification() != null) {
// there is nothing to parse if specification string is null,
// anyway it would cause NPE in ExtensionAttributeAnalyzer.parse()
specifications.add(specification);
}
}
}
}
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);
}
}
if (attributes.isEmpty()) {
return;
}
// clear the old attributes
testportType = TestPortAPI_type.TP_REGULAR;
portType = PortType_type.PT_REGULAR;
// check the new attributes
for (int i = 0; i < attributes.size(); i++) {
final ExtensionAttribute extensionAttribute = attributes.get(i);
if (ExtensionAttribute_type.PORTTYPE.equals(extensionAttribute.getAttributeType())) {
final PortTypeAttribute portAttribute = (PortTypeAttribute) extensionAttribute;
switch(portAttribute.getPortTypeType()) {
case INTERNAL:
switch(testportType) {
case TP_REGULAR:
break;
case TP_INTERNAL:
extensionAttribute.getLocation().reportSemanticWarning("Duplicate attribute `internal'");
break;
case TP_ADDRESS:
extensionAttribute.getLocation().reportSemanticError("Attributes `address' and `internal' cannot be used at the same time");
break;
default:
break;
}
testportType = TestPortAPI_type.TP_INTERNAL;
break;
case ADDRESS:
switch(testportType) {
case TP_REGULAR:
break;
case TP_INTERNAL:
extensionAttribute.getLocation().reportSemanticError("Attributes `address' and `internal' cannot be used at the same time");
break;
case TP_ADDRESS:
extensionAttribute.getLocation().reportSemanticWarning("Duplicate attribute `address'");
break;
default:
break;
}
testportType = TestPortAPI_type.TP_ADDRESS;
break;
case PROVIDER:
switch(portType) {
case PT_REGULAR:
break;
case PT_PROVIDER:
extensionAttribute.getLocation().reportSemanticWarning("Duplicate attribute `provider'");
break;
case PT_USER:
extensionAttribute.getLocation().reportSemanticError("Attributes `user' and `provider' cannot be used at the same time");
break;
default:
break;
}
addProviderAttribute();
break;
case USER:
switch(portType) {
case PT_REGULAR:
break;
case PT_PROVIDER:
extensionAttribute.getLocation().reportSemanticError("Attributes `provider' and `user' cannot be used at the same time");
break;
case PT_USER:
extensionAttribute.getLocation().reportSemanticError("Duplicate attribute `user'");
break;
default:
break;
}
final UserPortTypeAttribute user = (UserPortTypeAttribute) portAttribute;
addUserAttribute(user.getReference(), user.getInMappings(), user.getOutMappings());
break;
default:
break;
}
}
}
if (PortType_type.PT_USER.equals(portType)) {
checkUserAttribute(timestamp);
} else if (TestPortAPI_type.TP_ADDRESS.equals(testportType)) {
final TTCN3Module module = (TTCN3Module) myType.getMyScope().getModuleScope();
if (module.getAddressType(timestamp) == null) {
location.reportSemanticError(MessageFormat.format("Type `address'' is not defined in module `{0}''", module.getIdentifier().getDisplayName()));
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute in project titan.EclipsePlug-ins by eclipse.
the class ComponentTypeBody method collectExtensionAttributes.
/**
* Collects the extends extension attributes, from the with attributes assigned to the component type.
*
* @param timestamp the timestamp of the actual semantic check cycle
*/
private void collectExtensionAttributes(final CompilationTimeStamp timestamp) {
if (withAttributesPath == null) {
return;
}
final List<SingleWithAttribute> realAttributes = withAttributesPath.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);
}
}
if (attributes.isEmpty()) {
return;
}
attrExtendsReferences = new ComponentTypeReferenceList();
for (int i = 0, size = attributes.size(); i < size; i++) {
final ExtensionAttribute tempAttribute = attributes.get(i);
if (ExtensionAttribute_type.EXTENDS.equals(tempAttribute.getAttributeType())) {
final ExtensionsAttribute extensionsAttribute = (ExtensionsAttribute) tempAttribute;
for (int j = 0, size2 = extensionsAttribute.getNofTypes(); j < size2; j++) {
final IType tempType = extensionsAttribute.getType(j);
if (Type_type.TYPE_REFERENCED.equals(tempType.getTypetype())) {
attrExtendsReferences.addReference(((Referenced_Type) tempType).getReference());
}
}
}
}
attrExtendsReferences.setFullNameParent(new BridgingNamedNode(this, ".<extends attribute>"));
attrExtendsReferences.setMyScope(parentScope);
}
Aggregations