Search in sources :

Example 1 with Completeness_type

use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Choice_Type method checkThisTemplate.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisTemplate(final CompilationTimeStamp timestamp, final ITTCN3Template template, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
    registerUsage(template);
    template.setMyGovernor(this);
    if (getIsErroneous(timestamp)) {
        return false;
    }
    boolean selfReference = false;
    if (Template_type.NAMED_TEMPLATE_LIST.equals(template.getTemplatetype())) {
        final Named_Template_List namedTemplateList = (Named_Template_List) template;
        final int nofTemplates = namedTemplateList.getNofTemplates();
        if (nofTemplates != 1) {
            template.getLocation().reportSemanticError(ONEFIELDEXPECTED);
            template.setIsErroneous(true);
        }
        for (int i = 0; i < nofTemplates; i++) {
            final NamedTemplate namedTemplate = namedTemplateList.getTemplateByIndex(i);
            final Identifier name = namedTemplate.getName();
            final CompField field = components.getCompByName(name);
            if (field == null) {
                namedTemplate.getLocation().reportSemanticError(MessageFormat.format(REFERENCETONONEXISTENTFIELD, name.getDisplayName(), getFullName()));
            } else {
                final Type fieldType = field.getType();
                if (fieldType != null && !fieldType.getIsErroneous(timestamp)) {
                    ITTCN3Template namedTemplateTemplate = namedTemplate.getTemplate();
                    namedTemplateTemplate.setMyGovernor(fieldType);
                    namedTemplateTemplate = fieldType.checkThisTemplateRef(timestamp, namedTemplateTemplate);
                    final Completeness_type completeness = namedTemplateList.getCompletenessConditionChoice(timestamp, isModified, name);
                    selfReference |= namedTemplateTemplate.checkThisTemplateGeneric(timestamp, fieldType, Completeness_type.MAY_INCOMPLETE.equals(completeness), false, false, true, implicitOmit, lhs);
                }
            }
        }
    } else {
        template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName(), getTypename()));
        template.setIsErroneous(true);
    }
    if (template.getLengthRestriction() != null) {
        template.getLocation().reportSemanticError(MessageFormat.format(LENGTHRESTRICTIONNOTALLOWED, getTypename()));
        template.setIsErroneous(true);
    }
    return selfReference;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Completeness_type(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type) IASN1Type(org.eclipse.titan.designer.AST.ASN1.IASN1Type) TTCN3_Choice_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) NamedTemplate(org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Named_Template_List(org.eclipse.titan.designer.AST.TTCN3.templates.Named_Template_List)

Example 2 with Completeness_type

use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type in project titan.EclipsePlug-ins by eclipse.

the class Open_Type method checkThisTemplate.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisTemplate(final CompilationTimeStamp timestamp, final ITTCN3Template template, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
    registerUsage(template);
    template.setMyGovernor(this);
    if (getIsErroneous(timestamp)) {
        return false;
    }
    boolean selfReference = false;
    if (Template_type.NAMED_TEMPLATE_LIST.equals(template.getTemplatetype())) {
        final Named_Template_List namedTemplateList = (Named_Template_List) template;
        final int nofTemplates = namedTemplateList.getNofTemplates();
        if (nofTemplates != 1) {
            template.getLocation().reportSemanticError(ONEFIELDEXPECTED);
        }
        for (int i = 0; i < nofTemplates; i++) {
            final NamedTemplate namedTemplate = namedTemplateList.getTemplateByIndex(i);
            final Identifier name = namedTemplate.getName();
            final CompField field = getComponentByName(name);
            if (field == null) {
                namedTemplate.getLocation().reportSemanticError(MessageFormat.format(REFERENCETONONEXISTENTFIELD, name.getDisplayName(), getFullName()));
            } else {
                final Type fieldType = field.getType();
                if (fieldType != null && !fieldType.getIsErroneous(timestamp)) {
                    ITTCN3Template namedTemplateTemplate = namedTemplate.getTemplate();
                    namedTemplateTemplate.setMyGovernor(fieldType);
                    namedTemplateTemplate = fieldType.checkThisTemplateRef(timestamp, namedTemplateTemplate);
                    final Completeness_type completeness = namedTemplateList.getCompletenessConditionChoice(timestamp, isModified, name);
                    selfReference |= namedTemplateTemplate.checkThisTemplateGeneric(timestamp, fieldType, Completeness_type.MAY_INCOMPLETE.equals(completeness), false, false, true, implicitOmit, lhs);
                }
            }
        }
    } else {
        template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName(), getTypename()));
    }
    if (template.getLengthRestriction() != null) {
        template.getLocation().reportSemanticError(MessageFormat.format(LENGTHRESTRICTIONNOTALLOWED, getTypename()));
    }
    return selfReference;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Completeness_type(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type) IASN1Type(org.eclipse.titan.designer.AST.ASN1.IASN1Type) Type(org.eclipse.titan.designer.AST.Type) ASN1Type(org.eclipse.titan.designer.AST.ASN1.ASN1Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) NamedTemplate(org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Named_Template_List(org.eclipse.titan.designer.AST.TTCN3.templates.Named_Template_List) TableConstraint(org.eclipse.titan.designer.AST.ASN1.TableConstraint)

Example 3 with Completeness_type

use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type in project titan.EclipsePlug-ins by eclipse.

the class Anytype_Type method checkThisTemplate.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisTemplate(final CompilationTimeStamp timestamp, final ITTCN3Template template, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
    registerUsage(template);
    template.setMyGovernor(this);
    if (getIsErroneous(timestamp)) {
        return false;
    }
    boolean selfReference = false;
    if (Template_type.NAMED_TEMPLATE_LIST.equals(template.getTemplatetype())) {
        final Named_Template_List namedTemplateList = (Named_Template_List) template;
        final int nofTemplates = namedTemplateList.getNofTemplates();
        if (nofTemplates != 1) {
            template.getLocation().reportSemanticError(ONEFIELDEXPECTED);
        }
        for (int i = 0; i < nofTemplates; i++) {
            final NamedTemplate namedTemplate = namedTemplateList.getTemplateByIndex(i);
            final Identifier name = namedTemplate.getName();
            final CompField field = compFieldMap.getCompWithName(name);
            if (field != null) {
                final Type fieldType = field.getType();
                ITTCN3Template namedTemplateTemplate = namedTemplate.getTemplate();
                namedTemplateTemplate.setMyGovernor(fieldType);
                namedTemplateTemplate = fieldType.checkThisTemplateRef(timestamp, namedTemplateTemplate);
                final Completeness_type completeness = namedTemplateList.getCompletenessConditionChoice(timestamp, isModified, name);
                selfReference |= namedTemplateTemplate.checkThisTemplateGeneric(timestamp, fieldType, Completeness_type.MAY_INCOMPLETE.equals(completeness), false, false, true, implicitOmit, lhs);
            }
        }
    } else {
        template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName(), getTypename()));
    }
    if (template.getLengthRestriction() != null) {
        template.getLocation().reportSemanticError(MessageFormat.format(LENGTHRESTRICTIONNOTALLOWED, getTypename()));
    }
    return selfReference;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Completeness_type(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type) 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) NamedTemplate(org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate) Named_Template_List(org.eclipse.titan.designer.AST.TTCN3.templates.Named_Template_List)

Example 4 with Completeness_type

use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type in project titan.EclipsePlug-ins by eclipse.

the class TTCN3_Choice_Type method checkThisTemplate.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisTemplate(final CompilationTimeStamp timestamp, final ITTCN3Template template, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
    registerUsage(template);
    template.setMyGovernor(this);
    if (getIsErroneous(timestamp)) {
        return false;
    }
    boolean selfReference = false;
    if (Template_type.NAMED_TEMPLATE_LIST.equals(template.getTemplatetype())) {
        final Named_Template_List namedTemplateList = (Named_Template_List) template;
        final int nofTemplates = namedTemplateList.getNofTemplates();
        if (nofTemplates != 1) {
            template.getLocation().reportSemanticError(ONEFIELDEXPECTED);
        }
        for (int i = 0; i < nofTemplates; i++) {
            final NamedTemplate namedTemplate = namedTemplateList.getTemplateByIndex(i);
            final Identifier name = namedTemplate.getName();
            final CompField field = compFieldMap.getCompWithName(name);
            if (field == null) {
                namedTemplate.getLocation().reportSemanticError(MessageFormat.format(REFERENCETONONEXISTENTFIELD, name.getDisplayName(), getFullName()));
            } else {
                final Type fieldType = field.getType();
                ITTCN3Template namedTemplateTemplate = namedTemplate.getTemplate();
                namedTemplateTemplate.setMyGovernor(fieldType);
                namedTemplateTemplate = fieldType.checkThisTemplateRef(timestamp, namedTemplateTemplate);
                final Completeness_type completeness = namedTemplateList.getCompletenessConditionChoice(timestamp, isModified, name);
                selfReference |= namedTemplateTemplate.checkThisTemplateGeneric(timestamp, fieldType, Completeness_type.MAY_INCOMPLETE.equals(completeness), false, false, true, implicitOmit, lhs);
            }
        }
    } else {
        template.getLocation().reportSemanticError(MessageFormat.format(TEMPLATENOTALLOWED, template.getTemplateTypeName(), getTypename()));
    }
    if (template.getLengthRestriction() != null) {
        template.getLocation().reportSemanticError(MessageFormat.format(LENGTHRESTRICTIONNOTALLOWED, getTypename()));
    }
    return selfReference;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Completeness_type(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type) Type(org.eclipse.titan.designer.AST.Type) SubType(org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType) ASN1_Choice_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) NamedTemplate(org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate) Named_Template_List(org.eclipse.titan.designer.AST.TTCN3.templates.Named_Template_List)

Aggregations

IType (org.eclipse.titan.designer.AST.IType)4 Identifier (org.eclipse.titan.designer.AST.Identifier)4 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)4 Completeness_type (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type)4 NamedTemplate (org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate)4 Named_Template_List (org.eclipse.titan.designer.AST.TTCN3.templates.Named_Template_List)4 Type (org.eclipse.titan.designer.AST.Type)4 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)2 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)2 ASN1Type (org.eclipse.titan.designer.AST.ASN1.ASN1Type)1 TableConstraint (org.eclipse.titan.designer.AST.ASN1.TableConstraint)1 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)1 Attribute_Type (org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute.Attribute_Type)1 TTCN3_Choice_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type)1 SubType (org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType)1