Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +6 −6 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ LanguageSpec: LANGUAGEKEYWORD txt+=FREE_TEXT (COMMA txt+=FREE_TEXT)*; ModuleParDef: MODULEPARKEYWORD (ModulePar | LBRACKET MultitypedModuleParList RBRACKET); MODULEPARKEYWORD (param=ModulePar | LBRACKET multitypeParam=MultitypedModuleParList RBRACKET); ModulePar: type=Type list=ModuleParList; Loading @@ -37,7 +37,7 @@ ModuleParameter: name=IDENTIFIER (ASSIGNMENTCHAR constExpr=ConstantExpression)?; MultitypedModuleParList: {MultitypedModuleParList} (par+=ModulePar SEMICOLON?)*; {MultitypedModuleParList} (params+=ModulePar SEMICOLON?)*; ModuleDefinitionsList: (definitions+=ModuleDefinition SEMICOLON?)+; Loading Loading @@ -693,7 +693,7 @@ MixedList: Direction ProcOrTypeList; ProcOrTypeList: {ProcOrTypeList} ALLKEYWORD | type+=ProcOrType (COMMA type+=ProcOrType); {ProcOrTypeList} ALLKEYWORD | type+=ProcOrType (COMMA type+=ProcOrType)*; ProcOrType: {ProcOrType} Signature | Type; Loading Loading @@ -746,7 +746,7 @@ SignatureList: EnumDef: ENUMKEYWORD ADDRESSKEYWORD LBRACKET list=EnumerationList RBRACKET | EnumDefNamed; EnumDefNamed returns EnumDef: EnumDefNamed: ENUMKEYWORD name=IDENTIFIER LBRACKET list=EnumerationList RBRACKET; NestedTypeDef: Loading Loading @@ -785,7 +785,7 @@ Direction: UnionDef: UNIONKEYWORD ADDRESSKEYWORD body=UnionDefBody | UnionDefNamed; UnionDefNamed returns UnionDef: UnionDefNamed: UNIONKEYWORD name=IDENTIFIER body=UnionDefBody; UnionDefBody: Loading @@ -803,7 +803,7 @@ UnionFieldDef: SetDef: SETKEYWORD ADDRESSKEYWORD body=StructDefBody | SetDefNamed; SetDefNamed returns SetDef: SetDefNamed: SETKEYWORD name=IDENTIFIER body=StructDefBody; SubTypeSpec: Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ScopeHelper.xtend +39 −5 Original line number Diff line number Diff line Loading @@ -23,6 +23,12 @@ import de.ugoe.cs.swe.tTCN3.TemplateOrValueFormalParList import de.ugoe.cs.swe.tTCN3.VarList import java.util.ArrayList import org.eclipse.emf.ecore.EObject import de.ugoe.cs.swe.tTCN3.TypeDef import de.ugoe.cs.swe.tTCN3.ModuleParDef import de.ugoe.cs.swe.tTCN3.ModuleParameter import de.ugoe.cs.swe.tTCN3.ModulePar import de.ugoe.cs.swe.tTCN3.RecordOfDefNamed import de.ugoe.cs.swe.tTCN3.SetOfDefNamed class TTCN3ScopeHelper { Loading @@ -38,15 +44,43 @@ class TTCN3ScopeHelper { def static void scopeModuleVariable(RefValue variable, ArrayList<EObject> list) { val container = variable.findDesiredParent(typeof(ModuleDefinitionsList)) as ModuleDefinitionsList // TODO: || it.def instanceof ModuleParDef val defs = container.definitions.filter[it.def instanceof ConstDef] for (EObject v : defs) { val constDefList = ((v as ModuleDefinition).def as ConstDef).defs as ConstList var defs = container.definitions.filter[it.def instanceof ConstDef] for (ModuleDefinition v : defs) { val constDefList = (v.def as ConstDef).defs as ConstList for (EObject d : constDefList.list) { if(d != variable) list.add(d) } } defs = container.definitions.filter[it.def instanceof TypeDef] for (ModuleDefinition v : defs) { val body = (v.def as TypeDef).body if (body.structured != null && body.structured.recordOf != null && body.structured.recordOf != variable && body.structured.recordOf instanceof RecordOfDefNamed) { list.add(body.structured.recordOf) } if (body.structured != null && body.structured.setOf != null && body.structured.setOf != variable && body.structured.setOf instanceof SetOfDefNamed) { list.add(body.structured.setOf) } } defs = container.definitions.filter[it.def instanceof ModuleParDef] for (ModuleDefinition v : defs) { if ((v.def as ModuleParDef).param != null) { for (ModuleParameter p : (v.def as ModuleParDef).param.list.params) { if (p != variable) list.add(p) } } else if ((v as ModuleParDef).multitypeParam != null) { for (ModulePar p : (v.def as ModuleParDef).multitypeParam.params) { for (ModuleParameter pa : p.list.params) { if (pa != variable) list.add(pa) } } } } } def static void scopeStatementBlock(RefValue variable, StatementBlock block, ArrayList<EObject> list) { Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/TTCN3Validator.xtend +95 −31 Original line number Diff line number Diff line Loading @@ -37,31 +37,29 @@ import org.eclipse.xtext.validation.Check import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.* import de.ugoe.cs.swe.tTCN3.GroupDef import de.ugoe.cs.swe.tTCN3.TypeDef import de.ugoe.cs.swe.tTCN3.ModuleParDef import de.ugoe.cs.swe.tTCN3.ModuleParameter import de.ugoe.cs.swe.tTCN3.ModulePar import de.ugoe.cs.swe.tTCN3.RecordOfDefNamed import de.ugoe.cs.swe.tTCN3.SetOfDefNamed import de.ugoe.cs.swe.tTCN3.RecordDefNamed import de.ugoe.cs.swe.tTCN3.PortDef import de.ugoe.cs.swe.tTCN3.UnionDefNamed import de.ugoe.cs.swe.tTCN3.SetDefNamed import de.ugoe.cs.swe.tTCN3.EnumDefNamed import de.ugoe.cs.swe.tTCN3.SubTypeDefNamed class TTCN3Validator extends AbstractTTCN3Validator { @Check def checkUniqueNameNestedVariable(SingleConstDef variable) { variable.isNameClashInHierarchy } @Check def checkUniqueNameNestedVariable(SingleVarInstance variable) { variable.isNameClashInHierarchy } @Check def checkUniqueNameNestedVariable(FormalValuePar variable) { variable.isNameClashInHierarchy } @Check def checkUniqueNameNestedVariable(FormalTemplatePar variable) { def checkUniqueNameNestedVariable(RefValue variable) { variable.isNameClashInHierarchy } @Check def checkUniqueNameStructFieldDef(StructFieldDef field) { // find name clashes with module variables val container = field.findDesiredParent(typeof(ModuleDefinitionsList)) as ModuleDefinitionsList val defs = container.definitions.filter[it.def instanceof ConstDef] // TODO: || it.def instanceof ModuleParDef Loading Loading @@ -190,15 +188,81 @@ class TTCN3Validator extends AbstractTTCN3Validator { } def private boolean checkNameClashModuleDefinitionsList(ModuleDefinitionsList list, RefValue variable) { val defs = list.definitions.filter[it.def instanceof ConstDef] for (EObject v : defs) { val constDefList = ((v as ModuleDefinition).def as ConstDef).defs as ConstList for (ModuleDefinition v : list.definitions) { if (v.def instanceof ConstDef) { val constDefList = (v.def as ConstDef).defs as ConstList for (SingleConstDef d : constDefList.list) { if (d != variable && d.name == variable.name) { return true; } } return true } } } if (v.def instanceof TypeDef) { val body = (v.def as TypeDef).body if (body.structured != null) { if (body.structured.recordOf != null && body.structured.recordOf != variable && body.structured.recordOf instanceof RecordOfDefNamed && (body.structured.recordOf as RecordOfDefNamed).name == variable.name) return true if (body.structured.setOf != null && body.structured.setOf != variable && body.structured.setOf instanceof SetOfDefNamed && (body.structured.setOf as SetOfDefNamed).name == variable.name) return true if (body.structured.record != null && body.structured.record != variable && body.structured.record instanceof RecordDefNamed && (body.structured.record as RecordDefNamed).name == variable.name) return true if (body.structured.union != null && body.structured.union != variable && body.structured.union instanceof UnionDefNamed && (body.structured.union as UnionDefNamed).name == variable.name) return true if (body.structured.set != null && body.structured.set != variable && body.structured.set instanceof SetDefNamed && (body.structured.set as SetDefNamed).name == variable.name) return true if (body.structured.enumDef != null && body.structured.enumDef != variable && body.structured.enumDef instanceof EnumDefNamed && (body.structured.enumDef as EnumDefNamed).name == variable.name) return true if (body.structured.port != null && body.structured.port != variable && body.structured.port instanceof PortDef && (body.structured.port as PortDef).name == variable.name) return true if (body.structured.component != null && body.structured.component != variable && body.structured.component instanceof ComponentDef && (body.structured.component as ComponentDef).name == variable.name) return true } else if (body.sub != null) { if (body.sub != variable && body.sub instanceof SubTypeDefNamed && (body.sub as SubTypeDefNamed).name == variable.name) return true } } if (v.def instanceof ModuleParDef) { if ((v.def as ModuleParDef).param != null) { for (ModuleParameter p : (v.def as ModuleParDef).param.list.params) { if (p != variable && p.name == variable.name) return true } } else if ((v.def as ModuleParDef).multitypeParam != null) { for (ModulePar p : (v.def as ModuleParDef).multitypeParam.params) { for (ModuleParameter pa : p.list.params) { if (pa != variable && pa.name == variable.name) return true } } } } if (v.def instanceof FunctionDef) { if (v.def != variable && (v.def as FunctionDef).name == variable.name) return true } // TODO: more defs } return false; } Loading Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +6 −6 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ LanguageSpec: LANGUAGEKEYWORD txt+=FREE_TEXT (COMMA txt+=FREE_TEXT)*; ModuleParDef: MODULEPARKEYWORD (ModulePar | LBRACKET MultitypedModuleParList RBRACKET); MODULEPARKEYWORD (param=ModulePar | LBRACKET multitypeParam=MultitypedModuleParList RBRACKET); ModulePar: type=Type list=ModuleParList; Loading @@ -37,7 +37,7 @@ ModuleParameter: name=IDENTIFIER (ASSIGNMENTCHAR constExpr=ConstantExpression)?; MultitypedModuleParList: {MultitypedModuleParList} (par+=ModulePar SEMICOLON?)*; {MultitypedModuleParList} (params+=ModulePar SEMICOLON?)*; ModuleDefinitionsList: (definitions+=ModuleDefinition SEMICOLON?)+; Loading Loading @@ -693,7 +693,7 @@ MixedList: Direction ProcOrTypeList; ProcOrTypeList: {ProcOrTypeList} ALLKEYWORD | type+=ProcOrType (COMMA type+=ProcOrType); {ProcOrTypeList} ALLKEYWORD | type+=ProcOrType (COMMA type+=ProcOrType)*; ProcOrType: {ProcOrType} Signature | Type; Loading Loading @@ -746,7 +746,7 @@ SignatureList: EnumDef: ENUMKEYWORD ADDRESSKEYWORD LBRACKET list=EnumerationList RBRACKET | EnumDefNamed; EnumDefNamed returns EnumDef: EnumDefNamed: ENUMKEYWORD name=IDENTIFIER LBRACKET list=EnumerationList RBRACKET; NestedTypeDef: Loading Loading @@ -785,7 +785,7 @@ Direction: UnionDef: UNIONKEYWORD ADDRESSKEYWORD body=UnionDefBody | UnionDefNamed; UnionDefNamed returns UnionDef: UnionDefNamed: UNIONKEYWORD name=IDENTIFIER body=UnionDefBody; UnionDefBody: Loading @@ -803,7 +803,7 @@ UnionFieldDef: SetDef: SETKEYWORD ADDRESSKEYWORD body=StructDefBody | SetDefNamed; SetDefNamed returns SetDef: SetDefNamed: SETKEYWORD name=IDENTIFIER body=StructDefBody; SubTypeSpec: Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ScopeHelper.xtend +39 −5 Original line number Diff line number Diff line Loading @@ -23,6 +23,12 @@ import de.ugoe.cs.swe.tTCN3.TemplateOrValueFormalParList import de.ugoe.cs.swe.tTCN3.VarList import java.util.ArrayList import org.eclipse.emf.ecore.EObject import de.ugoe.cs.swe.tTCN3.TypeDef import de.ugoe.cs.swe.tTCN3.ModuleParDef import de.ugoe.cs.swe.tTCN3.ModuleParameter import de.ugoe.cs.swe.tTCN3.ModulePar import de.ugoe.cs.swe.tTCN3.RecordOfDefNamed import de.ugoe.cs.swe.tTCN3.SetOfDefNamed class TTCN3ScopeHelper { Loading @@ -38,15 +44,43 @@ class TTCN3ScopeHelper { def static void scopeModuleVariable(RefValue variable, ArrayList<EObject> list) { val container = variable.findDesiredParent(typeof(ModuleDefinitionsList)) as ModuleDefinitionsList // TODO: || it.def instanceof ModuleParDef val defs = container.definitions.filter[it.def instanceof ConstDef] for (EObject v : defs) { val constDefList = ((v as ModuleDefinition).def as ConstDef).defs as ConstList var defs = container.definitions.filter[it.def instanceof ConstDef] for (ModuleDefinition v : defs) { val constDefList = (v.def as ConstDef).defs as ConstList for (EObject d : constDefList.list) { if(d != variable) list.add(d) } } defs = container.definitions.filter[it.def instanceof TypeDef] for (ModuleDefinition v : defs) { val body = (v.def as TypeDef).body if (body.structured != null && body.structured.recordOf != null && body.structured.recordOf != variable && body.structured.recordOf instanceof RecordOfDefNamed) { list.add(body.structured.recordOf) } if (body.structured != null && body.structured.setOf != null && body.structured.setOf != variable && body.structured.setOf instanceof SetOfDefNamed) { list.add(body.structured.setOf) } } defs = container.definitions.filter[it.def instanceof ModuleParDef] for (ModuleDefinition v : defs) { if ((v.def as ModuleParDef).param != null) { for (ModuleParameter p : (v.def as ModuleParDef).param.list.params) { if (p != variable) list.add(p) } } else if ((v as ModuleParDef).multitypeParam != null) { for (ModulePar p : (v.def as ModuleParDef).multitypeParam.params) { for (ModuleParameter pa : p.list.params) { if (pa != variable) list.add(pa) } } } } } def static void scopeStatementBlock(RefValue variable, StatementBlock block, ArrayList<EObject> list) { Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/TTCN3Validator.xtend +95 −31 Original line number Diff line number Diff line Loading @@ -37,31 +37,29 @@ import org.eclipse.xtext.validation.Check import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.* import de.ugoe.cs.swe.tTCN3.GroupDef import de.ugoe.cs.swe.tTCN3.TypeDef import de.ugoe.cs.swe.tTCN3.ModuleParDef import de.ugoe.cs.swe.tTCN3.ModuleParameter import de.ugoe.cs.swe.tTCN3.ModulePar import de.ugoe.cs.swe.tTCN3.RecordOfDefNamed import de.ugoe.cs.swe.tTCN3.SetOfDefNamed import de.ugoe.cs.swe.tTCN3.RecordDefNamed import de.ugoe.cs.swe.tTCN3.PortDef import de.ugoe.cs.swe.tTCN3.UnionDefNamed import de.ugoe.cs.swe.tTCN3.SetDefNamed import de.ugoe.cs.swe.tTCN3.EnumDefNamed import de.ugoe.cs.swe.tTCN3.SubTypeDefNamed class TTCN3Validator extends AbstractTTCN3Validator { @Check def checkUniqueNameNestedVariable(SingleConstDef variable) { variable.isNameClashInHierarchy } @Check def checkUniqueNameNestedVariable(SingleVarInstance variable) { variable.isNameClashInHierarchy } @Check def checkUniqueNameNestedVariable(FormalValuePar variable) { variable.isNameClashInHierarchy } @Check def checkUniqueNameNestedVariable(FormalTemplatePar variable) { def checkUniqueNameNestedVariable(RefValue variable) { variable.isNameClashInHierarchy } @Check def checkUniqueNameStructFieldDef(StructFieldDef field) { // find name clashes with module variables val container = field.findDesiredParent(typeof(ModuleDefinitionsList)) as ModuleDefinitionsList val defs = container.definitions.filter[it.def instanceof ConstDef] // TODO: || it.def instanceof ModuleParDef Loading Loading @@ -190,15 +188,81 @@ class TTCN3Validator extends AbstractTTCN3Validator { } def private boolean checkNameClashModuleDefinitionsList(ModuleDefinitionsList list, RefValue variable) { val defs = list.definitions.filter[it.def instanceof ConstDef] for (EObject v : defs) { val constDefList = ((v as ModuleDefinition).def as ConstDef).defs as ConstList for (ModuleDefinition v : list.definitions) { if (v.def instanceof ConstDef) { val constDefList = (v.def as ConstDef).defs as ConstList for (SingleConstDef d : constDefList.list) { if (d != variable && d.name == variable.name) { return true; } } return true } } } if (v.def instanceof TypeDef) { val body = (v.def as TypeDef).body if (body.structured != null) { if (body.structured.recordOf != null && body.structured.recordOf != variable && body.structured.recordOf instanceof RecordOfDefNamed && (body.structured.recordOf as RecordOfDefNamed).name == variable.name) return true if (body.structured.setOf != null && body.structured.setOf != variable && body.structured.setOf instanceof SetOfDefNamed && (body.structured.setOf as SetOfDefNamed).name == variable.name) return true if (body.structured.record != null && body.structured.record != variable && body.structured.record instanceof RecordDefNamed && (body.structured.record as RecordDefNamed).name == variable.name) return true if (body.structured.union != null && body.structured.union != variable && body.structured.union instanceof UnionDefNamed && (body.structured.union as UnionDefNamed).name == variable.name) return true if (body.structured.set != null && body.structured.set != variable && body.structured.set instanceof SetDefNamed && (body.structured.set as SetDefNamed).name == variable.name) return true if (body.structured.enumDef != null && body.structured.enumDef != variable && body.structured.enumDef instanceof EnumDefNamed && (body.structured.enumDef as EnumDefNamed).name == variable.name) return true if (body.structured.port != null && body.structured.port != variable && body.structured.port instanceof PortDef && (body.structured.port as PortDef).name == variable.name) return true if (body.structured.component != null && body.structured.component != variable && body.structured.component instanceof ComponentDef && (body.structured.component as ComponentDef).name == variable.name) return true } else if (body.sub != null) { if (body.sub != variable && body.sub instanceof SubTypeDefNamed && (body.sub as SubTypeDefNamed).name == variable.name) return true } } if (v.def instanceof ModuleParDef) { if ((v.def as ModuleParDef).param != null) { for (ModuleParameter p : (v.def as ModuleParDef).param.list.params) { if (p != variable && p.name == variable.name) return true } } else if ((v.def as ModuleParDef).multitypeParam != null) { for (ModulePar p : (v.def as ModuleParDef).multitypeParam.params) { for (ModuleParameter pa : p.list.params) { if (pa != variable && pa.name == variable.name) return true } } } } if (v.def instanceof FunctionDef) { if (v.def != variable && (v.def as FunctionDef).name == variable.name) return true } // TODO: more defs } return false; } Loading