| package org.eclipse.viatra.examples.uml.queries |
| |
| import "http://www.eclipse.org/uml2/4.0.0/UML" |
| |
| @Edge(source = sup, target = sub, label = "direct") |
| @ContainsItem(container = sup, item = sub) |
| @Format(color = "#7f004b", lineWidth = 2, lineStyle = "dashed") |
| pattern superClass(sub : Class, sup : Class) { |
| Generalization.specific(Gen, sub); |
| Generalization(Gen); |
| Generalization.general(Gen, sup); |
| } |
| |
| @Edge(source = sup, target = sub) |
| pattern transitiveSuperClass(sub : Class, sup : Class) { |
| find superClass+(sub, sup); |
| } |
| |
| pattern superOrEqualClass(sub : Class, sup : Class) { |
| sub == sup; |
| } or { |
| find superClass+(sub, sup); |
| } |
| |
| pattern ownsOperation(cl : Class, op : Operation) { |
| Class.ownedOperation(cl, op); |
| } |
| |
| pattern ownsProperty(cl : Class, pr : Property) { |
| StructuredClassifier.ownedAttribute(cl, pr); |
| } |
| |
| pattern hasOperation(cl : Class, op : Operation) { |
| find superOrEqualClass(cl, owner); |
| find ownsOperation(owner, op); |
| } |
| |
| pattern hasProperty(cl : Class, pr : Property) { |
| find superOrEqualClass(cl, owner); |
| find ownsProperty(owner, pr); |
| } |
| |
| @ObservableValue(name = "abstract", expression = "cl.isAbstract") |
| @ObservableValue(name = "leaf", expression = "cl.isLeaf") |
| @ObservableValue(name = "label", labelExpression = "Label: $cl.name$") |
| @Constraint(severity = "error", key = {"cl"}, message="The class $cl$ is empty", |
| targetEditorId = "org.eclipse.papyrus.infra.core.papyrusEditor" |
| ) |
| @Item(item = cl, label="Empty class $cl$") |
| @Format(color="#3770d7", textColor = "#ffffff") |
| pattern emptyClass(cl : Class) { |
| neg find hasOperation(cl, _op); |
| neg find hasProperty(cl, _prop); |
| } |
| |
| @Item(item = cl, label = "Class $cl$") |
| pattern nonEmptyClass(cl : Class) { |
| neg find emptyClass(cl); |
| } |
| |
| // flattener test queries |
| pattern hasPropertyOrOperation(cl : Class) { |
| find hasOperation(cl,_); |
| } or { |
| find hasProperty(cl,_); |
| } |