diff options
Diffstat (limited to 'subprojects/viatra-runtime-base/src/main/java/tools/refinery/viatra/runtime/base/comprehension/EMFVisitor.java')
-rw-r--r-- | subprojects/viatra-runtime-base/src/main/java/tools/refinery/viatra/runtime/base/comprehension/EMFVisitor.java | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-base/src/main/java/tools/refinery/viatra/runtime/base/comprehension/EMFVisitor.java b/subprojects/viatra-runtime-base/src/main/java/tools/refinery/viatra/runtime/base/comprehension/EMFVisitor.java new file mode 100644 index 00000000..6029bb02 --- /dev/null +++ b/subprojects/viatra-runtime-base/src/main/java/tools/refinery/viatra/runtime/base/comprehension/EMFVisitor.java | |||
@@ -0,0 +1,145 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2004-2010 Gabor Bergmann and Daniel Varro | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | |||
10 | package tools.refinery.viatra.runtime.base.comprehension; | ||
11 | |||
12 | import org.eclipse.emf.ecore.EAttribute; | ||
13 | import org.eclipse.emf.ecore.EObject; | ||
14 | import org.eclipse.emf.ecore.EReference; | ||
15 | import org.eclipse.emf.ecore.EStructuralFeature; | ||
16 | import org.eclipse.emf.ecore.resource.Resource; | ||
17 | |||
18 | /** | ||
19 | * Use EMFModelComprehension to visit an EMF model. | ||
20 | * | ||
21 | * @author Bergmann Gábor | ||
22 | * | ||
23 | */ | ||
24 | // FIXME: | ||
25 | // - handle boundary of active emfRoot subtree | ||
26 | // - more efficient traversal | ||
27 | public class EMFVisitor { | ||
28 | |||
29 | boolean preOrder; | ||
30 | |||
31 | public EMFVisitor(boolean preOrder) { | ||
32 | super(); | ||
33 | this.preOrder = preOrder; | ||
34 | } | ||
35 | |||
36 | /** | ||
37 | * @param resource | ||
38 | * @param element | ||
39 | */ | ||
40 | public void visitTopElementInResource(Resource resource, EObject element) { | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * @param resource | ||
45 | */ | ||
46 | public void visitResource(Resource resource) { | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @param source | ||
51 | */ | ||
52 | public void visitElement(EObject source) { | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @param source | ||
57 | * @param feature | ||
58 | * @param target | ||
59 | */ | ||
60 | public void visitNonContainmentReference(EObject source, EReference feature, EObject target) { | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * @param source | ||
65 | * @param feature | ||
66 | * @param target | ||
67 | */ | ||
68 | public void visitInternalContainment(EObject source, EReference feature, EObject target) { | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * @param source | ||
73 | * @param feature | ||
74 | * @param target | ||
75 | */ | ||
76 | public void visitAttribute(EObject source, EAttribute feature, Object target) { | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * Returns true if the given feature should not be traversed (interesting esp. if multi-valued) | ||
81 | */ | ||
82 | public boolean pruneFeature(EStructuralFeature feature) { | ||
83 | return false; | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * Returns true if the contents of an object should be pruned (and not explored by the visitor) | ||
88 | */ | ||
89 | public boolean pruneSubtrees(EObject source) { | ||
90 | return false; | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * Returns true if the contents of a resource should be pruned (and not explored by the visitor) | ||
95 | */ | ||
96 | public boolean pruneSubtrees(Resource source) { | ||
97 | return false; | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * An opportunity for the visitor to indicate that the containment link is considered in a transient state, and the | ||
102 | * model comprehension should avoid following it. | ||
103 | * | ||
104 | * A containment is in a transient state from the point of view of the visitor if it connects a subtree that is | ||
105 | * being inserted <em>during</em> a full-model traversal, and a separate notification handler will deal with it | ||
106 | * later. | ||
107 | */ | ||
108 | public boolean avoidTransientContainmentLink(EObject source, EReference reference, EObject targetObject) { | ||
109 | return false; | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * @return if objects should be visited before their outgoing edges | ||
114 | */ | ||
115 | public boolean preOrder() { | ||
116 | return preOrder; | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * Called after visiting the reference, if the target is a proxy. | ||
121 | * | ||
122 | * @param position | ||
123 | * optional: known position in multivalued collection (for more efficient proxy resolution) | ||
124 | */ | ||
125 | public void visitProxyReference(EObject source, EReference reference, EObject targetObject, Integer position) { | ||
126 | } | ||
127 | |||
128 | /** | ||
129 | * Whether the given reference of the given object should be resolved when it is a proxy | ||
130 | */ | ||
131 | public boolean attemptProxyResolutions(EObject source, EReference feature) { | ||
132 | return true; | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * @return true if traversing visitors shall descend along cross-resource containments | ||
137 | * (this only makes sense for traversing visitors on an object scope) | ||
138 | * | ||
139 | * @since 1.7 | ||
140 | */ | ||
141 | public boolean descendAlongCrossResourceContainments() { | ||
142 | return false; | ||
143 | } | ||
144 | |||
145 | } \ No newline at end of file | ||