use of org.eclipse.titan.designer.AST.TTCN3.attributes.ErroneousAttributes in project titan.EclipsePlug-ins by eclipse.
the class Definition method checkErroneousAttributes.
protected void checkErroneousAttributes(final CompilationTimeStamp timestamp) {
erroneousAttributes = null;
if (withAttributesPath != null) {
final MultipleWithAttributes attribs = withAttributesPath.getAttributes();
if (attribs == null) {
return;
}
for (int i = 0; i < attribs.getNofElements(); i++) {
final SingleWithAttribute actualAttribute = attribs.getAttribute(i);
if (actualAttribute.getAttributeType() == Attribute_Type.Erroneous_Attribute) {
final int nofQualifiers = (actualAttribute.getQualifiers() == null) ? 0 : actualAttribute.getQualifiers().getNofQualifiers();
final List<IType> referencedTypeArray = new ArrayList<IType>(nofQualifiers);
final List<ArrayList<Integer>> subrefsArrayArray = new ArrayList<ArrayList<Integer>>(nofQualifiers);
final List<ArrayList<IType>> typeArrayArray = new ArrayList<ArrayList<IType>>(nofQualifiers);
if (nofQualifiers == 0) {
actualAttribute.getLocation().reportSemanticError("At least one qualifier must be specified for the `erroneous' attribute");
} else {
// existing fields
for (int qi = 0; qi < nofQualifiers; qi++) {
final Qualifier actualQualifier = actualAttribute.getQualifiers().getQualifierByIndex(qi);
final IType definitionType = getType(timestamp);
// construct a reference
final Reference reference = new Reference(null);
reference.addSubReference(new FieldSubReference(identifier));
for (int ri = 0; ri < actualQualifier.getNofSubReferences(); ri++) {
reference.addSubReference(actualQualifier.getSubReferenceByIndex(ri));
}
reference.setLocation(actualQualifier.getLocation());
reference.setMyScope(getMyScope());
IType fieldType = definitionType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_CONSTANT, false);
ArrayList<Integer> subrefsArray = null;
ArrayList<IType> typeArray = null;
if (fieldType != null) {
subrefsArray = new ArrayList<Integer>();
typeArray = new ArrayList<IType>();
final boolean validIndexes = definitionType.getSubrefsAsArray(timestamp, reference, 1, subrefsArray, typeArray);
if (!validIndexes) {
fieldType = null;
subrefsArray = null;
typeArray = null;
}
if (reference.refersToStringElement()) {
actualQualifier.getLocation().reportSemanticError("Reference to a string element cannot be used in this context");
fieldType = null;
subrefsArray = null;
typeArray = null;
}
}
referencedTypeArray.add(fieldType);
subrefsArrayArray.add(subrefsArray);
typeArrayArray.add(typeArray);
}
}
// parse the attr. spec.
final ErroneousAttributeSpecification errAttributeSpecification = parseErrAttrSpecString(actualAttribute.getAttributeSpecification());
if (errAttributeSpecification != null) {
if (erroneousAttributes == null) {
erroneousAttributes = new ErroneousAttributes(getType(timestamp));
}
erroneousAttributes.addSpecification(errAttributeSpecification);
errAttributeSpecification.check(timestamp, getMyScope());
// err.attr.spec. pairs
for (int qi = 0; qi < nofQualifiers; qi++) {
if (referencedTypeArray.get(qi) != null && errAttributeSpecification.getIndicator() != Indicator_Type.Invalid_Indicator) {
final Qualifier actualQualifier = actualAttribute.getQualifiers().getQualifierByIndex(qi);
erroneousAttributes.addFieldErr(actualQualifier, errAttributeSpecification, subrefsArrayArray.get(qi), typeArrayArray.get(qi));
}
}
}
}
}
if (erroneousAttributes != null) {
erroneousAttributes.check(timestamp);
}
}
}
Aggregations