Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +3 −3 Original line number Diff line number Diff line Loading @@ -206,13 +206,13 @@ ModuleControlPart: CONTROLKEYWORD LBRACKET body=ModuleControlBody RBRACKET ws=WithStatement? sc=SEMICOLON?; ModuleControlBody: {ModuleControlBody} list=ControlStatementOrDefList?; {ModuleControlBody} list+=ControlStatementOrDefList*; ControlStatementOrDefList: (def+=ControlStatementOrDef sc+=SEMICOLON?)+; def=ControlStatementOrDef sc=SEMICOLON?; ControlStatementOrDef: (FunctionLocalDef | FunctionLocalInst) WithStatement? | ControlStatement; (localDef=FunctionLocalDef | localInst=FunctionLocalInst) WithStatement? | ControlStatement; ControlStatement: TimerStatements | BasicStatements | BehaviourStatements | SUTStatements | {ControlStatement} STOPKEYWORD; Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/TTCN3Validator.xtend +42 −12 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import de.ugoe.cs.swe.tTCN3.VarList import org.eclipse.emf.ecore.EObject import org.eclipse.xtext.validation.Check import de.ugoe.cs.swe.tTCN3.FormalValuePar import de.ugoe.cs.swe.tTCN3.ModuleControlPart import de.ugoe.cs.swe.tTCN3.ControlStatementOrDefList class TTCN3Validator extends AbstractTTCN3Validator { Loading @@ -42,8 +44,9 @@ class TTCN3Validator extends AbstractTTCN3Validator { var parent = variable.eContainer while (parent != null) { if (parent instanceof ModuleDefinitionsList) { if (parent.checkNameClashModuleDefinitionsList(variable)) { if (parent instanceof TTCN3Module) { if (parent.defs != null && parent.defs.checkNameClashModuleDefinitionsList(variable)) { // TODO: TTCN3Package$Literals::SINGLE_CONST_DEF__NAME error('Name clash with another variable definition in this scope!', null, -1); return; Loading Loading @@ -73,6 +76,11 @@ class TTCN3Validator extends AbstractTTCN3Validator { error('Name clash with another variable definition in this scope!', null, -1); return; } } else if (parent instanceof ModuleControlPart) { if (parent.checkNameClashModuleControlPart(variable)) { error('Name clash with another variable definition in this scope!', null, -1); return; } } // TODO: other references in scope Loading Loading @@ -139,6 +147,28 @@ class TTCN3Validator extends AbstractTTCN3Validator { return false; } def private boolean checkNameClashModuleControlPart(ModuleControlPart control, RefValue variable) { for (ControlStatementOrDefList o : control.body.list) { if (o.def.localDef != null && o.def.localDef.constDef != null) { val constDefList = o.def.localDef.constDef.defs as ConstList for (SingleConstDef d : constDefList.list) { if (d != variable && d.name == variable.name) { return true; } } } if (o.def.localInst != null && o.def.localInst.variable != null) { val varList = o.def.localInst.variable.list as VarList for (SingleVarInstance d : varList.variables) { if (d != variable && d.name == variable.name) { return true; } } } } return false; } @Check def checkModuleStartsWithM(TTCN3Module module) { val char pattern = 'M'; Loading Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +3 −3 Original line number Diff line number Diff line Loading @@ -206,13 +206,13 @@ ModuleControlPart: CONTROLKEYWORD LBRACKET body=ModuleControlBody RBRACKET ws=WithStatement? sc=SEMICOLON?; ModuleControlBody: {ModuleControlBody} list=ControlStatementOrDefList?; {ModuleControlBody} list+=ControlStatementOrDefList*; ControlStatementOrDefList: (def+=ControlStatementOrDef sc+=SEMICOLON?)+; def=ControlStatementOrDef sc=SEMICOLON?; ControlStatementOrDef: (FunctionLocalDef | FunctionLocalInst) WithStatement? | ControlStatement; (localDef=FunctionLocalDef | localInst=FunctionLocalInst) WithStatement? | ControlStatement; ControlStatement: TimerStatements | BasicStatements | BehaviourStatements | SUTStatements | {ControlStatement} STOPKEYWORD; Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/TTCN3Validator.xtend +42 −12 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import de.ugoe.cs.swe.tTCN3.VarList import org.eclipse.emf.ecore.EObject import org.eclipse.xtext.validation.Check import de.ugoe.cs.swe.tTCN3.FormalValuePar import de.ugoe.cs.swe.tTCN3.ModuleControlPart import de.ugoe.cs.swe.tTCN3.ControlStatementOrDefList class TTCN3Validator extends AbstractTTCN3Validator { Loading @@ -42,8 +44,9 @@ class TTCN3Validator extends AbstractTTCN3Validator { var parent = variable.eContainer while (parent != null) { if (parent instanceof ModuleDefinitionsList) { if (parent.checkNameClashModuleDefinitionsList(variable)) { if (parent instanceof TTCN3Module) { if (parent.defs != null && parent.defs.checkNameClashModuleDefinitionsList(variable)) { // TODO: TTCN3Package$Literals::SINGLE_CONST_DEF__NAME error('Name clash with another variable definition in this scope!', null, -1); return; Loading Loading @@ -73,6 +76,11 @@ class TTCN3Validator extends AbstractTTCN3Validator { error('Name clash with another variable definition in this scope!', null, -1); return; } } else if (parent instanceof ModuleControlPart) { if (parent.checkNameClashModuleControlPart(variable)) { error('Name clash with another variable definition in this scope!', null, -1); return; } } // TODO: other references in scope Loading Loading @@ -139,6 +147,28 @@ class TTCN3Validator extends AbstractTTCN3Validator { return false; } def private boolean checkNameClashModuleControlPart(ModuleControlPart control, RefValue variable) { for (ControlStatementOrDefList o : control.body.list) { if (o.def.localDef != null && o.def.localDef.constDef != null) { val constDefList = o.def.localDef.constDef.defs as ConstList for (SingleConstDef d : constDefList.list) { if (d != variable && d.name == variable.name) { return true; } } } if (o.def.localInst != null && o.def.localInst.variable != null) { val varList = o.def.localInst.variable.list as VarList for (SingleVarInstance d : varList.variables) { if (d != variable && d.name == variable.name) { return true; } } } } return false; } @Check def checkModuleStartsWithM(TTCN3Module module) { val char pattern = 'M'; Loading