use of org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate in project titan.EclipsePlug-ins by eclipse.
the class NamedTemplateListParser method process.
@Override
public Scope process(IVisitableNode node) {
if (node instanceof NamedTemplate) {
NamedTemplate nt = (NamedTemplate) node;
name = nt.getName().toString();
}
if (node instanceof TTCN3Template) {
ValueHolder holder = list.getHolder(name);
String type = list.getType(name);
return TemplateValueParser.getScope(this, holder, type, node);
}
return this;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate in project titan.EclipsePlug-ins by eclipse.
the class UnionValueParser method process.
@Override
public Scope process(IVisitableNode node) {
if (node instanceof NamedTemplate) {
NamedTemplate nt = (NamedTemplate) node;
String name = nt.getName().toString();
subtype = map.get(name);
}
if (node instanceof TTCN3Template) {
return TemplateValueParser.getScope(this, union, subtype, node);
}
return this;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Sequence_Type method checkThisNamedTemplateList.
private boolean checkThisNamedTemplateList(final CompilationTimeStamp timestamp, final Named_Template_List templateList, final boolean isModified, final boolean implicitOmit, final Assignment lhs) {
templateList.removeGeneratedValues();
boolean selfReference = false;
final Map<String, NamedTemplate> componentMap = new HashMap<String, NamedTemplate>();
final int nofTypeComponents = getNofComponents(timestamp);
final int nofTemplateComponents = templateList.getNofTemplates();
boolean inSync = true;
CompField lastComponentField = null;
int nextIndex = 0;
for (int i = 0; i < nofTemplateComponents; i++) {
final NamedTemplate namedTemplate = templateList.getTemplateByIndex(i);
final Identifier identifier = namedTemplate.getName();
final String templateName = identifier.getName();
if (hasComponentWithName(identifier)) {
if (componentMap.containsKey(templateName)) {
namedTemplate.getLocation().reportSemanticError(MessageFormat.format(DUPLICATETEMPLATEFIELDFIRST, identifier.getDisplayName()));
final Location tempLocation = componentMap.get(templateName).getLocation();
tempLocation.reportSemanticError(MessageFormat.format(DUPLICATETEMPLATEFIELDAGAIN, identifier.getDisplayName()));
inSync = false;
} else {
componentMap.put(templateName, namedTemplate);
}
final CompField componentField = getComponentByName(identifier);
if (inSync) {
if (isModified) {
boolean found = false;
for (int j = nextIndex; j < nofTypeComponents && !found; j++) {
final CompField componentField2 = getComponentByIndex(j);
if (templateName.equals(componentField2.getIdentifier().getName())) {
lastComponentField = componentField2;
nextIndex = j + 1;
found = true;
}
}
if (!found && lastComponentField != null) {
namedTemplate.getLocation().reportSemanticError(MessageFormat.format(INCORRECTTEMPLATEFIELDORDER, identifier.getDisplayName(), lastComponentField.getIdentifier().getDisplayName(), getFullName()));
inSync = false;
}
} else if (strictConstantCheckingSeverity) {
final CompField componentField2 = getComponentByIndex(i);
if (componentField2 != componentField) {
if (!componentField2.isOptional() || (componentField2.isOptional() && !implicitOmit)) {
namedTemplate.getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDTEMPLATEFIELD, identifier.getDisplayName(), componentField2.getIdentifier().getDisplayName()));
inSync = false;
}
}
}
}
final Type type = componentField.getType();
if (type != null && !type.getIsErroneous(timestamp)) {
ITTCN3Template componentTemplate = namedTemplate.getTemplate();
componentTemplate.setMyGovernor(type);
componentTemplate = type.checkThisTemplateRef(timestamp, componentTemplate);
boolean isOptional = componentField.isOptional();
if (!isOptional && componentField.hasDefault() && defaultAsOptional) {
isOptional = true;
}
selfReference |= componentTemplate.checkThisTemplateGeneric(timestamp, type, isModified, isOptional, isOptional, true, implicitOmit, lhs);
}
} else {
namedTemplate.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTTEMPLATEFIELDREFERENCE, identifier.getDisplayName(), getTypename()));
inSync = false;
}
}
if (!isModified && strictConstantCheckingSeverity) {
// check missing fields
for (int i = 0; i < nofTypeComponents; i++) {
final Identifier identifier = getComponentIdentifierByIndex(i);
if (!componentMap.containsKey(identifier.getName())) {
if (getComponentByIndex(i).isOptional() && implicitOmit) {
templateList.addNamedValue(new NamedTemplate(new Identifier(Identifier_type.ID_TTCN, identifier.getDisplayName()), new OmitValue_Template(), false));
} else {
templateList.getLocation().reportSemanticError(MessageFormat.format(MISSINGTEMPLATEFIELD, identifier.getDisplayName(), getTypename()));
}
}
}
}
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate 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;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate 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;
}
Aggregations