| pre { |
| var inports = new Map; |
| for (i in Inport.all){ |
| var parent = i.parent; |
| if (parent <> null){ |
| var entry = inports.get(parent.handle); |
| if (entry <> null) { |
| entry.add(i); |
| } else { |
| inports.put( parent.handle, i.asSequence()); |
| } |
| } |
| } |
| } |
| context Block { |
| critique PropertyCheck_BlockNameIsLowerCase { |
| check : self.Name == self.Name.toLowerCase() |
| fix { |
| title : "Name (" + self.Name + ") in lower case" |
| do { |
| self.Name = self.Name.toLowerCase(); |
| } |
| } |
| } |
| } |
| context Inport { |
| critique PropertyCheck_PortDimensionsHasAssignedValue { |
| check : self.PortDimensions <> "-1" |
| fix { |
| title : "set port dimension to 1" |
| do { |
| self.PortDimensions = "1"; |
| } |
| } |
| } |
| } |
| context Goto { |
| critique PropertyCheck_TagVisibility { |
| check: self.TagVisibility == "local" |
| } |
| } |
| context From { |
| critique NavigationAndFilter_ThereExistsAGotoBlockWithTheFromGotoTagAndInScope { |
| check : Goto.all.exists(g | g.GotoTag == self.GotoTag and ( |
| (g.TagVisibility == "global") or |
| ( (g.TagVisibility == "local") and (g.parent == self.parent) ) or |
| ( (g.TagVisibility == "scoped") and (self.closure(f|f.getParent()).existsOne(p|p == g.parent))))) |
| } |
| } |
| context Outport { |
| critique PropertyCheck_HasDescription { |
| check : self.Description <> null and self.Description <> "" |
| fix { |
| title : "set description value as Name" |
| do { |
| self.Description = "Outport " + self.Name; |
| } |
| } |
| } |
| } |
| context SubSystem { |
| critique NavigationAndFilter_InportsAreGreen { |
| guard: self.parent <> null and inports.get(self.parent.handle) <> null |
| check : inports.get(self.parent.handle).forAll(i|i.ForegroundColor == "green") |
| fix { |
| title : "Setting inport as green" |
| do { |
| for (i in inports.get(self.parent.handle).select(i|i.ForegroundColor <> "green")){ |
| i.ForegroundColor == "green"; |
| } |
| } |
| } |
| } |
| critique TransitiveClosure_NoMoreThanThreeLevelsDeep { |
| check : self.closure(p|p.getParent()).flatten().size() < 3 |
| } |
| critique VertexConnectivity_AllOutportsConnected { |
| check { |
| var connections = self.getOutports().collect(o|o.getLines()).flatten(); |
| return (not connections.isEmpty()) and connections.forAll(l|l <> null and l.getDestination() <> null); |
| } |
| } |
| critique LoopAbsence { |
| check { |
| var connections = self.getOutports().collect(o|o.getLines()).flatten().select(l|l <> null); |
| return connections.isEmpty() or (not connections.exists(l|l.getDestination() == self)); |
| } |
| } |
| } |
| operation Block getParent() : Sequence { |
| if (self.parent == null) { |
| return new Sequence(); |
| } else { |
| return Sequence {self.parent}; |
| } |
| } |