diff --git a/de.darmstadt.tu.crossing.CrySL/src/de/darmstadt/tu/crossing/validation/CrySLValidator.java b/de.darmstadt.tu.crossing.CrySL/src/de/darmstadt/tu/crossing/validation/CrySLValidator.java index 73162472..fb686160 100644 --- a/de.darmstadt.tu.crossing.CrySL/src/de/darmstadt/tu/crossing/validation/CrySLValidator.java +++ b/de.darmstadt.tu.crossing.CrySL/src/de/darmstadt/tu/crossing/validation/CrySLValidator.java @@ -6,7 +6,11 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.xtext.validation.Check; +import de.darmstadt.tu.crossing.crySL.Event; import de.darmstadt.tu.crossing.crySL.ForbMethod; +import de.darmstadt.tu.crossing.crySL.RequiredBlock; +import de.darmstadt.tu.crossing.crySL.SuperType; +import de.darmstadt.tu.crossing.crySL.impl.ObjectImpl; /** * This class contains custom validation rules. @@ -19,8 +23,32 @@ public class CrySLValidator extends AbstractCrySLValidator { @Check public void checkGreetingStartsWithCapital(ForbMethod greeting) { - + } - -} + /** + * Add error markers for duplicate event labels. + * + * @param s of type supertype being checked for duplicity + */ + @Check + public void checkDuplicateEventLabel(SuperType s) { + + if(!(s instanceof ObjectImpl)) { + for(Event e : ((RequiredBlock) s.eContainer()).getReq_event()) { + for(Event ev : ((RequiredBlock) s.eContainer()).getReq_event()) { + if(e instanceof SuperType && ev instanceof SuperType) { + SuperType es = (SuperType) e; + SuperType evs = (SuperType) ev; + if(es != evs && es.getName().equals(evs.getName())) { + if(s.getName().contentEquals(es.getName()) + && s.getName().contentEquals(evs.getName())) { + error("Duplicate label", INVALID_NAME); + } + } + } + } + } + } + } +} \ No newline at end of file