use of org.eclipse.titan.designer.AST.TTCN3.attributes.WithAttributesPath in project titan.EclipsePlug-ins by eclipse.
the class Type method checkVariants.
/**
* Checks the type's variant attributes (when using the new codec handling).
*/
public void checkVariants(final CompilationTimeStamp timestamp) {
if (isAsn() || ownerType != TypeOwner_type.OT_TYPE_DEF) {
return;
}
WithAttributesPath globalAttributesPath;
final Def_Type def = (Def_Type) owner;
final Group nearest_group = def.getParentGroup();
if (nearest_group == null) {
// no group, use the module
Module myModule = myScope.getModuleScope();
globalAttributesPath = ((TTCN3Module) myModule).getAttributePath();
} else {
globalAttributesPath = nearest_group.getAttributePath();
}
if (globalAttributesPath != null) {
// process all global variants, not just the closest group
final List<SingleWithAttribute> realAttributes = globalAttributesPath.getRealAttributes(timestamp);
for (int i = 0; i < realAttributes.size(); i++) {
final SingleWithAttribute singleWithAttribute = realAttributes.get(i);
if (singleWithAttribute.getAttributeType() == Attribute_Type.Variant_Attribute) {
checkThisVariant(timestamp, singleWithAttribute, true);
}
}
}
// check local variant attributes second, so they overwrite global ones if they
// conflict with each other
final WithAttributesPath attributePath = getAttributePath();
if (attributePath != null) {
final MultipleWithAttributes multipleWithAttributes = attributePath.getAttributes();
if (multipleWithAttributes != null) {
for (int i = 0; i < multipleWithAttributes.getNofElements(); i++) {
final SingleWithAttribute singleWithAttribute = multipleWithAttributes.getAttribute(i);
if (singleWithAttribute.getAttributeType() == Attribute_Type.Variant_Attribute) {
final Qualifiers qualifiers = singleWithAttribute.getQualifiers();
if (qualifiers != null && qualifiers.getNofQualifiers() > 0) {
for (int j = 0; j < qualifiers.getNofQualifiers(); j++) {
final Qualifier qualifier = qualifiers.getQualifierByIndex(j);
final List<ISubReference> fieldsOrArrays = new ArrayList<ISubReference>();
for (int k = 0; k < qualifier.getNofSubReferences(); k++) {
fieldsOrArrays.add(qualifier.getSubReferenceByIndex(k));
}
final Reference reference = new Reference(null, fieldsOrArrays);
final IType type = getFieldType(timestamp, reference, 0, Expected_Value_type.EXPECTED_CONSTANT, false);
if (type != null) {
if (type.getMyScope() != myScope) {
qualifier.getLocation().reportSemanticWarning("Variant attribute is ignored, because it refers to a type from a different type definition");
} else {
type.checkThisVariant(timestamp, singleWithAttribute, false);
}
}
}
} else {
checkThisVariant(timestamp, singleWithAttribute, false);
}
}
}
}
}
// check the coding attributes set by the variants
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
checkCodingAttributes(timestamp, chain);
chain.release();
}
use of org.eclipse.titan.designer.AST.TTCN3.attributes.WithAttributesPath in project titan.EclipsePlug-ins by eclipse.
the class Type method hasVariantAttributes.
@Override
public final /**
* {@inheritDoc}
*/
boolean hasVariantAttributes(final CompilationTimeStamp timestamp) {
if (withAttributesPath == null) {
return false;
}
final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
for (int i = 0; i < realAttributes.size(); i++) {
if (SingleWithAttribute.Attribute_Type.Variant_Attribute.equals(realAttributes.get(i).getAttributeType())) {
return true;
}
}
final MultipleWithAttributes localAttributes = withAttributesPath.getAttributes();
if (localAttributes == null) {
return false;
}
for (int i = 0; i < localAttributes.getNofElements(); i++) {
final SingleWithAttribute tempSingle = localAttributes.getAttribute(i);
if (Attribute_Type.Variant_Attribute.equals(tempSingle.getAttributeType())) {
return true;
}
}
return false;
}
use of org.eclipse.titan.designer.AST.TTCN3.attributes.WithAttributesPath in project titan.EclipsePlug-ins by eclipse.
the class Def_ModulePar method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
T3Doc.check(this.getCommentLocation(), KIND);
isUsed = false;
NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_MODULEPAR, identifier, this);
NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
if (withAttributesPath != null) {
withAttributesPath.checkGlobalAttributes(timestamp, false);
withAttributesPath.checkAttributes(timestamp);
}
if (type == null) {
return;
}
type.setGenName("_T_", getGenName());
type.check(timestamp);
final IType lastType = type.getTypeRefdLast(timestamp);
switch(lastType.getTypetype()) {
case TYPE_PORT:
location.reportSemanticError(MessageFormat.format(PORTNOTALLOWED, lastType.getFullName()));
break;
case TYPE_SIGNATURE:
location.reportSemanticError(MessageFormat.format(SIGNATURENOTALLOWED, lastType.getFullName()));
break;
case TYPE_FUNCTION:
case TYPE_ALTSTEP:
case TYPE_TESTCASE:
if (((Function_Type) lastType).isRunsOnSelf()) {
location.reportSemanticError(MessageFormat.format(RUNSONSELF_NOT_ALLOWED, lastType.getFullName()));
}
break;
default:
break;
}
if (defaultValue != null) {
defaultValue.setMyGovernor(type);
final IValue temporalValue = type.checkThisValueRef(timestamp, defaultValue);
type.checkThisValue(timestamp, temporalValue, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_CONSTANT, true, false, true, hasImplicitOmitAttribute(timestamp), false));
defaultValue.setCodeSection(CodeSectionType.CS_PRE_INIT);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.attributes.WithAttributesPath in project titan.EclipsePlug-ins by eclipse.
the class Def_ModulePar_Template method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
T3Doc.check(this.getCommentLocation(), KIND);
isUsed = false;
NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_MODULEPAR, identifier, this);
NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
if (withAttributesPath != null) {
withAttributesPath.checkGlobalAttributes(timestamp, false);
withAttributesPath.checkAttributes(timestamp);
}
if (type == null) {
return;
}
type.setGenName("_T_", getGenName());
type.check(timestamp);
final IType lastType = type.getTypeRefdLast(timestamp);
switch(lastType.getTypetype()) {
case TYPE_PORT:
location.reportSemanticError(MessageFormat.format(Def_ModulePar.PORTNOTALLOWED, lastType.getFullName()));
break;
case TYPE_SIGNATURE:
location.reportSemanticError(MessageFormat.format(Def_ModulePar.SIGNATURENOTALLOWED, lastType.getFullName()));
break;
case TYPE_FUNCTION:
case TYPE_ALTSTEP:
case TYPE_TESTCASE:
if (((Function_Type) lastType).isRunsOnSelf()) {
location.reportSemanticError(MessageFormat.format(Def_ModulePar.RUNSONSELF_NOT_ALLOWED, lastType.getFullName()));
}
break;
default:
break;
}
if (defaultTemplate != null) {
realTemplate = defaultTemplate;
// Needed in case of universal charstring templates
if (defaultTemplate.getTemplatetype() == Template_type.CSTR_PATTERN && lastType.getTypetype() == Type.Type_type.TYPE_UCHARSTRING) {
realTemplate = defaultTemplate.setTemplatetype(timestamp, Template_type.USTR_PATTERN);
// FIXME implement setting the pattern type,
// once universal charstring pattern are
// supported.
}
final ITTCN3Template temporalTemplate = type.checkThisTemplateRef(timestamp, realTemplate);
temporalTemplate.checkThisTemplateGeneric(timestamp, type, false, true, true, true, false, null);
final IReferenceChain tempReferenceChain = ReferenceChain.getInstance(Def_Template.CIRCULAREMBEDDEDRECURSION, true);
tempReferenceChain.add(this);
temporalTemplate.checkRecursions(timestamp, tempReferenceChain);
tempReferenceChain.release();
// defaultTemplate.setGenNamePrefix("modulepar_");//currently does not need the prefix
defaultTemplate.setGenNameRecursive(getGenName());
defaultTemplate.setCodeSection(CodeSectionType.CS_PRE_INIT);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.attributes.WithAttributesPath in project titan.EclipsePlug-ins by eclipse.
the class Def_Type method setWithAttributes.
@Override
public /**
* {@inheritDoc}
*/
void setWithAttributes(final MultipleWithAttributes attributes) {
if (type == null) {
return;
}
if (withAttributesPath == null) {
withAttributesPath = new WithAttributesPath();
type.setAttributeParentPath(withAttributesPath);
}
type.setWithAttributes(attributes);
}
Aggregations