summaryrefslogtreecommitdiffstats
blob: bb74b51f7856aa400860b8cdb7ac92a2ce882f32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package org.eclipse.incquery.examples.uml.evm.queries

import "http://www.eclipse.org/uml2/4.0.0/UML"

/*
 * Precondition for add generalization rule
 */
pattern possibleSuperClass(cl : Class, sup : Class) {
	neg find superClass(cl, _otherSup);
	neg find superClass(_cl2, sup);
}

/*
 * Precondition for create owned operation
 */
pattern onlyInheritedOperations(cl : Class) {
	find hasOperation(cl, _op);
	neg find ownsOperation(cl, _ownOp);
}

/*
 * Helper patterns
 */

pattern superClass(sub : Class, sup : Class) {
	Generalization.specific(Gen, sub);
	Generalization(Gen);
	Generalization.general(Gen, sup);
}

pattern transitiveSuperClass(sub : Class, sup : Class) {
	find superClass+(sub, sup);
}

pattern superOrEqualClass(sub : Class, sup) {
	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, pr) {
	find superOrEqualClass(cl, owner);
	find ownsProperty(owner, pr);
}

pattern emptyClass(cl : Class) {
	neg find hasOperation(cl, _op);
	neg find hasProperty(cl, _prop);
}

pattern nonEmptyClass(cl : Class) {
	neg find emptyClass(cl);
}