Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +4 −4 Original line number Diff line number Diff line Loading @@ -45,8 +45,8 @@ ModuleDefinitionsList: //why not predefined keyword for public or private? => enum Visibility ModuleDefinition: ((visibility=Visibility? def=(ConstDef | FunctionDef | TemplateDef | ModuleParDef | TypeDef | SignatureDef | TestcaseDef | AltstepDef | ImportDef | ExtFunctionDef | ExtConstDef)) | ('public'? def=GroupDef) | 'private'? def=FriendModuleDef) statement=WithStatement?; TestcaseDef | AltstepDef | ImportDef | ExtFunctionDef | ExtConstDef)) | (publicGroup='public'? def=GroupDef) | privateFriend='private'? def=FriendModuleDef) statement=WithStatement?; FriendModuleDef: //why are these not defined keywords? => enum Visibility Loading Loading @@ -800,7 +800,7 @@ EnumerationList: enums+=Enumeration (COMMA enums+=Enumeration)*; Enumeration: IDENTIFIER (LPAREN MINUS? NUMBER RPAREN)?; name=IDENTIFIER (LPAREN MINUS? NUMBER RPAREN)?; UnionFieldDef: (type=Type | NestedTypeDef) name=IDENTIFIER array=ArrayDef? subType=SubTypeSpec?; Loading Loading @@ -1053,7 +1053,7 @@ ReferencedValue: RefValue: SingleConstDef | ModuleParameter | SingleVarInstance | FieldReference | FormalTemplatePar | SingleTempVarInstance | BaseTemplate; BaseTemplate | Enumeration; // IDENTIFIER omitted PredefinedValue: Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/TTCN3Validator.xtend +52 −31 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ package de.ugoe.cs.swe.validation import de.ugoe.cs.swe.tTCN3.AltstepDef import de.ugoe.cs.swe.tTCN3.AltstepLocalDef import de.ugoe.cs.swe.tTCN3.AltstepLocalDefList import de.ugoe.cs.swe.tTCN3.BaseTemplate import de.ugoe.cs.swe.tTCN3.ComponentDef import de.ugoe.cs.swe.tTCN3.ComponentDefList import de.ugoe.cs.swe.tTCN3.ConstDef Loading Loading @@ -32,6 +31,7 @@ import de.ugoe.cs.swe.tTCN3.SetDefNamed import de.ugoe.cs.swe.tTCN3.SetOfDefNamed import de.ugoe.cs.swe.tTCN3.SignatureDef import de.ugoe.cs.swe.tTCN3.SingleConstDef import de.ugoe.cs.swe.tTCN3.SingleTempVarInstance import de.ugoe.cs.swe.tTCN3.SingleVarInstance import de.ugoe.cs.swe.tTCN3.StatementBlock import de.ugoe.cs.swe.tTCN3.StructDefBody Loading @@ -46,14 +46,15 @@ import de.ugoe.cs.swe.tTCN3.TestcaseDef import de.ugoe.cs.swe.tTCN3.TypeDef import de.ugoe.cs.swe.tTCN3.TypeDefBody import de.ugoe.cs.swe.tTCN3.UnionDefNamed import de.ugoe.cs.swe.tTCN3.VarList import de.ugoe.cs.swe.tTCN3.VarInstance import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.EStructuralFeature import org.eclipse.xtext.validation.Check import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.* import de.ugoe.cs.swe.tTCN3.VarInstance import de.ugoe.cs.swe.tTCN3.SingleTempVarInstance import de.ugoe.cs.swe.tTCN3.EnumerationList import de.ugoe.cs.swe.tTCN3.EnumDef import de.ugoe.cs.swe.tTCN3.Enumeration class TTCN3Validator extends AbstractTTCN3Validator { Loading Loading @@ -114,7 +115,7 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(ReferencedType type) { val module = type.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(type, type.name)) { if (module.checkNameClashesModuleDefs(type, type.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.referencedType_Name); return; Loading @@ -125,7 +126,7 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(TestcaseDef tc) { val module = tc.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(tc, tc.name)) { if (module.checkNameClashesModuleDefs(tc, tc.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.testcaseDef_Name); return; Loading @@ -136,29 +137,18 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(FunctionDef function) { val module = function.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(function, function.name)) { if (module.checkNameClashesModuleDefs(function, function.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.functionRef_Name); return; } } // not required since BaseTemplate is a RefValue // @Check // def checkTypeNames(BaseTemplate template) { // val module = template.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module // // if (module.defs.checkNameClashModuleDefinitionsList(template, template.name)) { // error('Name clash with another variable definition in this scope!', // TTCN3Package.eINSTANCE.baseTemplate_Name); // return; // } // } @Check def checkTypeNames(SignatureDef sig) { val module = sig.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(sig, sig.name)) { if (module.checkNameClashesModuleDefs(sig, sig.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.referencedType_Name); return; Loading @@ -169,7 +159,7 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(AltstepDef alt) { val module = alt.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(alt, alt.name)) { if (module.checkNameClashesModuleDefs(alt, alt.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.altstepDef_Name); return; Loading @@ -180,9 +170,9 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(GroupDef group) { val module = group.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(group, group.name)) { if (module.checkNameClashesModuleDefs(group, group.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.altstepDef_Name); TTCN3Package.eINSTANCE.groupDef_Name); return; } } Loading @@ -194,7 +184,7 @@ class TTCN3Validator extends AbstractTTCN3Validator { while (parent != null) { if (parent instanceof TTCN3Module) { if (parent.defs != null && parent.defs.checkNameClashModuleDefinitionsList(variable, variable.name)) { if (parent.checkNameClashesModuleDefs(variable, variable.name)) { error('Name clash with another variable definition in this scope!', feature); return; } Loading @@ -208,8 +198,8 @@ class TTCN3Validator extends AbstractTTCN3Validator { error('Name clash with another variable definition in this scope!', feature); return; } val defList = parent.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (defList.defs != null && defList.defs.checkNameClashModuleDefinitionsList(variable, variable.name)) { val module = parent.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.checkNameClashesModuleDefs(variable, variable.name)) { error('Name clash with another variable definition in this scope!', feature); return; } Loading Loading @@ -365,10 +355,20 @@ class TTCN3Validator extends AbstractTTCN3Validator { body.structured.set instanceof SetDefNamed && (body.structured.set as SetDefNamed).name == variableName) return true if (body.structured.enumDef != null && body.structured.enumDef != variable && body.structured.enumDef instanceof EnumDefNamed && (body.structured.enumDef as EnumDefNamed).name == variableName) if (body.structured.enumDef != null && body.structured.enumDef instanceof EnumDefNamed) { if (body.structured.enumDef != variable && (body.structured.enumDef as EnumDefNamed).name == variableName) { return true } if ((body.structured.enumDef as EnumDefNamed).list.checkEnumNameClash(variable, variableName)) { return true } } if (body.structured.enumDef != null && body.structured.enumDef instanceof EnumDef) { if ((body.structured.enumDef as EnumDef).list.checkEnumNameClash(variable, variableName)) { return true } } if (body.structured.port != null && body.structured.port != variable && body.structured.port instanceof PortDef && (body.structured.port as PortDef).name == variableName) return true Loading @@ -384,6 +384,15 @@ class TTCN3Validator extends AbstractTTCN3Validator { return false } def private boolean checkEnumNameClash(EnumerationList list, EObject variable, String variableName) { for (Enumeration e : list.enums) { if (variable != e && variableName == e.name) { return true; } } return false; } def private boolean checkNameClasStatementBlock(StatementBlock block, RefValue variable) { for (FunctionDefList l : block.def.filter[it != null]) { Loading Loading @@ -501,7 +510,6 @@ class TTCN3Validator extends AbstractTTCN3Validator { def private boolean checkNameClashAltstepLocalDefList(AltstepLocalDefList list, RefValue variable) { for (AltstepLocalDef a : list.defs.filter[it != null]) { if (a.const != null) { val constDefList = a.const.defs as ConstList for (SingleConstDef d : constDefList.list) { Loading @@ -510,12 +518,25 @@ class TTCN3Validator extends AbstractTTCN3Validator { } } } if (a.variable != null) { if (a.variable.checkNameClashVarInstance(variable)) return true; } } return false; } def private boolean checkNameClashesModuleDefs(TTCN3Module module, EObject variable, String variableName) { if (module.defs != null) { if (module.defs.checkNameClashModuleDefinitionsList(variable, variableName)) { return true; } for (ModuleDefinition g : module.defs.definitions.filter[it.def instanceof GroupDef]) { val GroupDef group = g.def as GroupDef if (group.list.checkNameClashModuleDefinitionsList(variable, variableName)) { return true; } } } return false; } Loading Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +4 −4 Original line number Diff line number Diff line Loading @@ -45,8 +45,8 @@ ModuleDefinitionsList: //why not predefined keyword for public or private? => enum Visibility ModuleDefinition: ((visibility=Visibility? def=(ConstDef | FunctionDef | TemplateDef | ModuleParDef | TypeDef | SignatureDef | TestcaseDef | AltstepDef | ImportDef | ExtFunctionDef | ExtConstDef)) | ('public'? def=GroupDef) | 'private'? def=FriendModuleDef) statement=WithStatement?; TestcaseDef | AltstepDef | ImportDef | ExtFunctionDef | ExtConstDef)) | (publicGroup='public'? def=GroupDef) | privateFriend='private'? def=FriendModuleDef) statement=WithStatement?; FriendModuleDef: //why are these not defined keywords? => enum Visibility Loading Loading @@ -800,7 +800,7 @@ EnumerationList: enums+=Enumeration (COMMA enums+=Enumeration)*; Enumeration: IDENTIFIER (LPAREN MINUS? NUMBER RPAREN)?; name=IDENTIFIER (LPAREN MINUS? NUMBER RPAREN)?; UnionFieldDef: (type=Type | NestedTypeDef) name=IDENTIFIER array=ArrayDef? subType=SubTypeSpec?; Loading Loading @@ -1053,7 +1053,7 @@ ReferencedValue: RefValue: SingleConstDef | ModuleParameter | SingleVarInstance | FieldReference | FormalTemplatePar | SingleTempVarInstance | BaseTemplate; BaseTemplate | Enumeration; // IDENTIFIER omitted PredefinedValue: Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/TTCN3Validator.xtend +52 −31 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ package de.ugoe.cs.swe.validation import de.ugoe.cs.swe.tTCN3.AltstepDef import de.ugoe.cs.swe.tTCN3.AltstepLocalDef import de.ugoe.cs.swe.tTCN3.AltstepLocalDefList import de.ugoe.cs.swe.tTCN3.BaseTemplate import de.ugoe.cs.swe.tTCN3.ComponentDef import de.ugoe.cs.swe.tTCN3.ComponentDefList import de.ugoe.cs.swe.tTCN3.ConstDef Loading Loading @@ -32,6 +31,7 @@ import de.ugoe.cs.swe.tTCN3.SetDefNamed import de.ugoe.cs.swe.tTCN3.SetOfDefNamed import de.ugoe.cs.swe.tTCN3.SignatureDef import de.ugoe.cs.swe.tTCN3.SingleConstDef import de.ugoe.cs.swe.tTCN3.SingleTempVarInstance import de.ugoe.cs.swe.tTCN3.SingleVarInstance import de.ugoe.cs.swe.tTCN3.StatementBlock import de.ugoe.cs.swe.tTCN3.StructDefBody Loading @@ -46,14 +46,15 @@ import de.ugoe.cs.swe.tTCN3.TestcaseDef import de.ugoe.cs.swe.tTCN3.TypeDef import de.ugoe.cs.swe.tTCN3.TypeDefBody import de.ugoe.cs.swe.tTCN3.UnionDefNamed import de.ugoe.cs.swe.tTCN3.VarList import de.ugoe.cs.swe.tTCN3.VarInstance import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.EStructuralFeature import org.eclipse.xtext.validation.Check import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.* import de.ugoe.cs.swe.tTCN3.VarInstance import de.ugoe.cs.swe.tTCN3.SingleTempVarInstance import de.ugoe.cs.swe.tTCN3.EnumerationList import de.ugoe.cs.swe.tTCN3.EnumDef import de.ugoe.cs.swe.tTCN3.Enumeration class TTCN3Validator extends AbstractTTCN3Validator { Loading Loading @@ -114,7 +115,7 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(ReferencedType type) { val module = type.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(type, type.name)) { if (module.checkNameClashesModuleDefs(type, type.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.referencedType_Name); return; Loading @@ -125,7 +126,7 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(TestcaseDef tc) { val module = tc.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(tc, tc.name)) { if (module.checkNameClashesModuleDefs(tc, tc.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.testcaseDef_Name); return; Loading @@ -136,29 +137,18 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(FunctionDef function) { val module = function.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(function, function.name)) { if (module.checkNameClashesModuleDefs(function, function.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.functionRef_Name); return; } } // not required since BaseTemplate is a RefValue // @Check // def checkTypeNames(BaseTemplate template) { // val module = template.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module // // if (module.defs.checkNameClashModuleDefinitionsList(template, template.name)) { // error('Name clash with another variable definition in this scope!', // TTCN3Package.eINSTANCE.baseTemplate_Name); // return; // } // } @Check def checkTypeNames(SignatureDef sig) { val module = sig.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(sig, sig.name)) { if (module.checkNameClashesModuleDefs(sig, sig.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.referencedType_Name); return; Loading @@ -169,7 +159,7 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(AltstepDef alt) { val module = alt.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(alt, alt.name)) { if (module.checkNameClashesModuleDefs(alt, alt.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.altstepDef_Name); return; Loading @@ -180,9 +170,9 @@ class TTCN3Validator extends AbstractTTCN3Validator { def checkTypeNames(GroupDef group) { val module = group.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.defs.checkNameClashModuleDefinitionsList(group, group.name)) { if (module.checkNameClashesModuleDefs(group, group.name)) { error('Name clash with another variable definition in this scope!', TTCN3Package.eINSTANCE.altstepDef_Name); TTCN3Package.eINSTANCE.groupDef_Name); return; } } Loading @@ -194,7 +184,7 @@ class TTCN3Validator extends AbstractTTCN3Validator { while (parent != null) { if (parent instanceof TTCN3Module) { if (parent.defs != null && parent.defs.checkNameClashModuleDefinitionsList(variable, variable.name)) { if (parent.checkNameClashesModuleDefs(variable, variable.name)) { error('Name clash with another variable definition in this scope!', feature); return; } Loading @@ -208,8 +198,8 @@ class TTCN3Validator extends AbstractTTCN3Validator { error('Name clash with another variable definition in this scope!', feature); return; } val defList = parent.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (defList.defs != null && defList.defs.checkNameClashModuleDefinitionsList(variable, variable.name)) { val module = parent.findDesiredParent(typeof(TTCN3Module)) as TTCN3Module if (module.checkNameClashesModuleDefs(variable, variable.name)) { error('Name clash with another variable definition in this scope!', feature); return; } Loading Loading @@ -365,10 +355,20 @@ class TTCN3Validator extends AbstractTTCN3Validator { body.structured.set instanceof SetDefNamed && (body.structured.set as SetDefNamed).name == variableName) return true if (body.structured.enumDef != null && body.structured.enumDef != variable && body.structured.enumDef instanceof EnumDefNamed && (body.structured.enumDef as EnumDefNamed).name == variableName) if (body.structured.enumDef != null && body.structured.enumDef instanceof EnumDefNamed) { if (body.structured.enumDef != variable && (body.structured.enumDef as EnumDefNamed).name == variableName) { return true } if ((body.structured.enumDef as EnumDefNamed).list.checkEnumNameClash(variable, variableName)) { return true } } if (body.structured.enumDef != null && body.structured.enumDef instanceof EnumDef) { if ((body.structured.enumDef as EnumDef).list.checkEnumNameClash(variable, variableName)) { return true } } if (body.structured.port != null && body.structured.port != variable && body.structured.port instanceof PortDef && (body.structured.port as PortDef).name == variableName) return true Loading @@ -384,6 +384,15 @@ class TTCN3Validator extends AbstractTTCN3Validator { return false } def private boolean checkEnumNameClash(EnumerationList list, EObject variable, String variableName) { for (Enumeration e : list.enums) { if (variable != e && variableName == e.name) { return true; } } return false; } def private boolean checkNameClasStatementBlock(StatementBlock block, RefValue variable) { for (FunctionDefList l : block.def.filter[it != null]) { Loading Loading @@ -501,7 +510,6 @@ class TTCN3Validator extends AbstractTTCN3Validator { def private boolean checkNameClashAltstepLocalDefList(AltstepLocalDefList list, RefValue variable) { for (AltstepLocalDef a : list.defs.filter[it != null]) { if (a.const != null) { val constDefList = a.const.defs as ConstList for (SingleConstDef d : constDefList.list) { Loading @@ -510,12 +518,25 @@ class TTCN3Validator extends AbstractTTCN3Validator { } } } if (a.variable != null) { if (a.variable.checkNameClashVarInstance(variable)) return true; } } return false; } def private boolean checkNameClashesModuleDefs(TTCN3Module module, EObject variable, String variableName) { if (module.defs != null) { if (module.defs.checkNameClashModuleDefinitionsList(variable, variableName)) { return true; } for (ModuleDefinition g : module.defs.definitions.filter[it.def instanceof GroupDef]) { val GroupDef group = g.def as GroupDef if (group.list.checkNameClashModuleDefinitionsList(variable, variableName)) { return true; } } } return false; } Loading