|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.bo.visitor; |
|
19 |
| |
|
20 |
| import org.qedeq.kernel.base.list.Atom; |
|
21 |
| import org.qedeq.kernel.base.list.Element; |
|
22 |
| import org.qedeq.kernel.base.list.ElementList; |
|
23 |
| import org.qedeq.kernel.base.module.Author; |
|
24 |
| import org.qedeq.kernel.base.module.AuthorList; |
|
25 |
| import org.qedeq.kernel.base.module.Axiom; |
|
26 |
| import org.qedeq.kernel.base.module.Chapter; |
|
27 |
| import org.qedeq.kernel.base.module.ChapterList; |
|
28 |
| import org.qedeq.kernel.base.module.Formula; |
|
29 |
| import org.qedeq.kernel.base.module.FunctionDefinition; |
|
30 |
| import org.qedeq.kernel.base.module.Header; |
|
31 |
| import org.qedeq.kernel.base.module.Import; |
|
32 |
| import org.qedeq.kernel.base.module.ImportList; |
|
33 |
| import org.qedeq.kernel.base.module.Latex; |
|
34 |
| import org.qedeq.kernel.base.module.LatexList; |
|
35 |
| import org.qedeq.kernel.base.module.LinkList; |
|
36 |
| import org.qedeq.kernel.base.module.LiteratureItem; |
|
37 |
| import org.qedeq.kernel.base.module.LiteratureItemList; |
|
38 |
| import org.qedeq.kernel.base.module.Location; |
|
39 |
| import org.qedeq.kernel.base.module.LocationList; |
|
40 |
| import org.qedeq.kernel.base.module.Node; |
|
41 |
| import org.qedeq.kernel.base.module.PredicateDefinition; |
|
42 |
| import org.qedeq.kernel.base.module.Proof; |
|
43 |
| import org.qedeq.kernel.base.module.ProofList; |
|
44 |
| import org.qedeq.kernel.base.module.Proposition; |
|
45 |
| import org.qedeq.kernel.base.module.Qedeq; |
|
46 |
| import org.qedeq.kernel.base.module.Rule; |
|
47 |
| import org.qedeq.kernel.base.module.Section; |
|
48 |
| import org.qedeq.kernel.base.module.SectionList; |
|
49 |
| import org.qedeq.kernel.base.module.Specification; |
|
50 |
| import org.qedeq.kernel.base.module.Subsection; |
|
51 |
| import org.qedeq.kernel.base.module.SubsectionList; |
|
52 |
| import org.qedeq.kernel.base.module.Term; |
|
53 |
| import org.qedeq.kernel.base.module.UsedByList; |
|
54 |
| import org.qedeq.kernel.base.module.VariableList; |
|
55 |
| import org.qedeq.kernel.bo.module.ModuleDataException; |
|
56 |
| import org.qedeq.kernel.context.ModuleContext; |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| public class QedeqNotNullTransverser implements QedeqTransverser { |
|
67 |
| |
|
68 |
| |
|
69 |
| private ModuleContext currentContext; |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| private QedeqVisitor visitor; |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
10
| public QedeqNotNullTransverser(final String globalContext, final QedeqVisitor visitor) {
|
|
84 |
10
| currentContext = new ModuleContext(globalContext);
|
|
85 |
10
| this.visitor = visitor;
|
|
86 |
| } |
|
87 |
| |
|
88 |
| |
|
89 |
10
| public void accept(final Qedeq qedeq) throws ModuleDataException {
|
|
90 |
10
| getCurrentContext().setLocationWithinModule("");
|
|
91 |
10
| if (qedeq == null) {
|
|
92 |
0
| return;
|
|
93 |
| } |
|
94 |
10
| visitor.visitEnter(qedeq);
|
|
95 |
10
| final String context = getCurrentContext().getLocationWithinModule();
|
|
96 |
10
| if (qedeq.getHeader() != null) {
|
|
97 |
10
| getCurrentContext().setLocationWithinModule(context + "getHeader()");
|
|
98 |
10
| accept(qedeq.getHeader());
|
|
99 |
| } |
|
100 |
10
| if (qedeq.getChapterList() != null) {
|
|
101 |
10
| getCurrentContext().setLocationWithinModule(context + "getChapterList()");
|
|
102 |
10
| accept(qedeq.getChapterList());
|
|
103 |
| } |
|
104 |
10
| if (qedeq.getLiteratureItemList() != null) {
|
|
105 |
4
| getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
|
|
106 |
4
| accept(qedeq.getLiteratureItemList());
|
|
107 |
| } |
|
108 |
10
| setLocationWithinModule(context);
|
|
109 |
10
| visitor.visitLeave(qedeq);
|
|
110 |
| } |
|
111 |
| |
|
112 |
10
| public void accept(final Header header) throws ModuleDataException {
|
|
113 |
10
| if (header == null) {
|
|
114 |
0
| return;
|
|
115 |
| } |
|
116 |
10
| visitor.visitEnter(header);
|
|
117 |
10
| final String context = getCurrentContext().getLocationWithinModule();
|
|
118 |
10
| if (header.getSpecification() != null) {
|
|
119 |
10
| setLocationWithinModule(context + ".getSpecification()");
|
|
120 |
10
| accept(header.getSpecification());
|
|
121 |
| } |
|
122 |
10
| if (header.getTitle() != null) {
|
|
123 |
10
| setLocationWithinModule(context + ".getTitle()");
|
|
124 |
10
| accept(header.getTitle());
|
|
125 |
| } |
|
126 |
10
| if (header.getSummary() != null) {
|
|
127 |
10
| setLocationWithinModule(context + ".getSummary()");
|
|
128 |
10
| accept(header.getSummary());
|
|
129 |
| } |
|
130 |
10
| if (header.getAuthorList() != null) {
|
|
131 |
10
| setLocationWithinModule(context + ".getAuthorList()");
|
|
132 |
10
| accept(header.getAuthorList());
|
|
133 |
| } |
|
134 |
10
| if (header.getImportList() != null) {
|
|
135 |
4
| setLocationWithinModule(context + ".getImportList()");
|
|
136 |
4
| accept(header.getImportList());
|
|
137 |
| } |
|
138 |
10
| if (header.getUsedByList() != null) {
|
|
139 |
2
| setLocationWithinModule(context + ".getUsedByList()");
|
|
140 |
2
| accept(header.getUsedByList());
|
|
141 |
| } |
|
142 |
10
| setLocationWithinModule(context);
|
|
143 |
10
| visitor.visitLeave(header);
|
|
144 |
| } |
|
145 |
| |
|
146 |
2
| public void accept(final UsedByList usedByList) throws ModuleDataException {
|
|
147 |
2
| if (usedByList == null) {
|
|
148 |
0
| return;
|
|
149 |
| } |
|
150 |
2
| visitor.visitEnter(usedByList);
|
|
151 |
2
| final String context = getCurrentContext().getLocationWithinModule();
|
|
152 |
2
| for (int i = 0; i < usedByList.size(); i++) {
|
|
153 |
2
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
154 |
2
| accept(usedByList.get(i));
|
|
155 |
| } |
|
156 |
2
| setLocationWithinModule(context);
|
|
157 |
2
| visitor.visitLeave(usedByList);
|
|
158 |
| } |
|
159 |
| |
|
160 |
4
| public void accept(final ImportList importList) throws ModuleDataException {
|
|
161 |
4
| if (importList == null) {
|
|
162 |
0
| return;
|
|
163 |
| } |
|
164 |
4
| visitor.visitEnter(importList);
|
|
165 |
4
| final String context = getCurrentContext().getLocationWithinModule();
|
|
166 |
4
| for (int i = 0; i < importList.size(); i++) {
|
|
167 |
6
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
168 |
6
| accept(importList.get(i));
|
|
169 |
| } |
|
170 |
4
| setLocationWithinModule(context);
|
|
171 |
4
| visitor.visitLeave(importList);
|
|
172 |
| } |
|
173 |
| |
|
174 |
6
| public void accept(final Import imp) throws ModuleDataException {
|
|
175 |
6
| if (imp == null) {
|
|
176 |
0
| return;
|
|
177 |
| } |
|
178 |
6
| visitor.visitEnter(imp);
|
|
179 |
6
| final String context = getCurrentContext().getLocationWithinModule();
|
|
180 |
6
| if (imp.getSpecification() != null) {
|
|
181 |
6
| setLocationWithinModule(context + ".getSpecification()");
|
|
182 |
6
| accept(imp.getSpecification());
|
|
183 |
| } |
|
184 |
6
| setLocationWithinModule(context);
|
|
185 |
6
| visitor.visitLeave(imp);
|
|
186 |
| } |
|
187 |
| |
|
188 |
18
| public void accept(final Specification specification) throws ModuleDataException {
|
|
189 |
18
| if (specification == null) {
|
|
190 |
0
| return;
|
|
191 |
| } |
|
192 |
18
| visitor.visitEnter(specification);
|
|
193 |
18
| final String context = getCurrentContext().getLocationWithinModule();
|
|
194 |
18
| if (specification.getLocationList() != null) {
|
|
195 |
18
| setLocationWithinModule(context + ".getLocationList()");
|
|
196 |
18
| accept(specification.getLocationList());
|
|
197 |
| } |
|
198 |
18
| setLocationWithinModule(context);
|
|
199 |
18
| visitor.visitLeave(specification);
|
|
200 |
| } |
|
201 |
| |
|
202 |
18
| public void accept(final LocationList locationList) throws ModuleDataException {
|
|
203 |
18
| if (locationList == null) {
|
|
204 |
0
| return;
|
|
205 |
| } |
|
206 |
18
| visitor.visitEnter(locationList);
|
|
207 |
18
| final String context = getCurrentContext().getLocationWithinModule();
|
|
208 |
18
| for (int i = 0; i < locationList.size(); i++) {
|
|
209 |
18
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
210 |
18
| accept(locationList.get(i));
|
|
211 |
| } |
|
212 |
18
| setLocationWithinModule(context);
|
|
213 |
18
| visitor.visitLeave(locationList);
|
|
214 |
| } |
|
215 |
| |
|
216 |
18
| public void accept(final Location location) throws ModuleDataException {
|
|
217 |
18
| if (location == null) {
|
|
218 |
0
| return;
|
|
219 |
| } |
|
220 |
18
| visitor.visitEnter(location);
|
|
221 |
18
| visitor.visitLeave(location);
|
|
222 |
| } |
|
223 |
| |
|
224 |
10
| public void accept(final AuthorList authorList) throws ModuleDataException {
|
|
225 |
10
| if (authorList == null) {
|
|
226 |
0
| return;
|
|
227 |
| } |
|
228 |
10
| visitor.visitEnter(authorList);
|
|
229 |
10
| final String context = getCurrentContext().getLocationWithinModule();
|
|
230 |
10
| for (int i = 0; i < authorList.size(); i++) {
|
|
231 |
10
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
232 |
10
| accept(authorList.get(i));
|
|
233 |
| } |
|
234 |
10
| setLocationWithinModule(context);
|
|
235 |
10
| visitor.visitLeave(authorList);
|
|
236 |
| } |
|
237 |
| |
|
238 |
10
| public void accept(final Author author) throws ModuleDataException {
|
|
239 |
10
| if (author == null) {
|
|
240 |
0
| return;
|
|
241 |
| } |
|
242 |
10
| visitor.visitEnter(author);
|
|
243 |
10
| final String context = getCurrentContext().getLocationWithinModule();
|
|
244 |
10
| if (author.getName() != null) {
|
|
245 |
10
| setLocationWithinModule(context + ".getName()");
|
|
246 |
10
| accept(author.getName());
|
|
247 |
| } |
|
248 |
10
| setLocationWithinModule(context);
|
|
249 |
10
| visitor.visitLeave(author);
|
|
250 |
| } |
|
251 |
| |
|
252 |
10
| public void accept(final ChapterList chapterList) throws ModuleDataException {
|
|
253 |
10
| if (chapterList == null) {
|
|
254 |
0
| return;
|
|
255 |
| } |
|
256 |
10
| visitor.visitEnter(chapterList);
|
|
257 |
10
| final String context = getCurrentContext().getLocationWithinModule();
|
|
258 |
10
| for (int i = 0; i < chapterList.size(); i++) {
|
|
259 |
50
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
260 |
50
| accept(chapterList.get(i));
|
|
261 |
| } |
|
262 |
10
| setLocationWithinModule(context);
|
|
263 |
10
| visitor.visitLeave(chapterList);
|
|
264 |
| } |
|
265 |
| |
|
266 |
50
| public void accept(final Chapter chapter) throws ModuleDataException {
|
|
267 |
50
| if (chapter == null) {
|
|
268 |
0
| return;
|
|
269 |
| } |
|
270 |
50
| visitor.visitEnter(chapter);
|
|
271 |
50
| final String context = getCurrentContext().getLocationWithinModule();
|
|
272 |
50
| if (chapter.getTitle() != null) {
|
|
273 |
50
| setLocationWithinModule(context + ".getTitle()");
|
|
274 |
50
| accept(chapter.getTitle());
|
|
275 |
| } |
|
276 |
50
| if (chapter.getIntroduction() != null) {
|
|
277 |
50
| setLocationWithinModule(context + ".getIntroduction()");
|
|
278 |
50
| accept(chapter.getIntroduction());
|
|
279 |
| } |
|
280 |
50
| if (chapter.getSectionList() != null) {
|
|
281 |
28
| setLocationWithinModule(context + ".getSectionList()");
|
|
282 |
28
| accept(chapter.getSectionList());
|
|
283 |
| } |
|
284 |
50
| setLocationWithinModule(context);
|
|
285 |
50
| visitor.visitLeave(chapter);
|
|
286 |
| } |
|
287 |
| |
|
288 |
4
| public void accept(final LiteratureItemList literatureItemList)
|
|
289 |
| throws ModuleDataException { |
|
290 |
4
| if (literatureItemList == null) {
|
|
291 |
0
| return;
|
|
292 |
| } |
|
293 |
4
| visitor.visitEnter(literatureItemList);
|
|
294 |
4
| final String context = getCurrentContext().getLocationWithinModule();
|
|
295 |
4
| for (int i = 0; i < literatureItemList.size(); i++) {
|
|
296 |
18
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
297 |
18
| accept(literatureItemList.get(i));
|
|
298 |
| } |
|
299 |
4
| setLocationWithinModule(context);
|
|
300 |
4
| visitor.visitLeave(literatureItemList);
|
|
301 |
| } |
|
302 |
| |
|
303 |
18
| public void accept(final LiteratureItem item) throws ModuleDataException {
|
|
304 |
18
| if (item == null) {
|
|
305 |
0
| return;
|
|
306 |
| } |
|
307 |
18
| visitor.visitEnter(item);
|
|
308 |
18
| final String context = getCurrentContext().getLocationWithinModule();
|
|
309 |
18
| if (item.getItem() != null) {
|
|
310 |
18
| setLocationWithinModule(context + ".getItem()");
|
|
311 |
18
| accept(item.getItem());
|
|
312 |
| } |
|
313 |
18
| setLocationWithinModule(context);
|
|
314 |
18
| visitor.visitLeave(item);
|
|
315 |
| } |
|
316 |
| |
|
317 |
28
| public void accept(final SectionList sectionList) throws ModuleDataException {
|
|
318 |
28
| if (sectionList == null) {
|
|
319 |
0
| return;
|
|
320 |
| } |
|
321 |
28
| visitor.visitEnter(sectionList);
|
|
322 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
|
323 |
28
| for (int i = 0; i < sectionList.size(); i++) {
|
|
324 |
84
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
325 |
84
| accept(sectionList.get(i));
|
|
326 |
| } |
|
327 |
28
| setLocationWithinModule(context);
|
|
328 |
28
| visitor.visitLeave(sectionList);
|
|
329 |
| } |
|
330 |
| |
|
331 |
84
| public void accept(final Section section) throws ModuleDataException {
|
|
332 |
84
| if (section == null) {
|
|
333 |
0
| return;
|
|
334 |
| } |
|
335 |
84
| visitor.visitEnter(section);
|
|
336 |
84
| final String context = getCurrentContext().getLocationWithinModule();
|
|
337 |
84
| if (section.getTitle() != null) {
|
|
338 |
84
| setLocationWithinModule(context + ".getTitle()");
|
|
339 |
84
| accept(section.getTitle());
|
|
340 |
| } |
|
341 |
84
| if (section.getIntroduction() != null) {
|
|
342 |
84
| setLocationWithinModule(context + ".getIntroduction()");
|
|
343 |
84
| accept(section.getIntroduction());
|
|
344 |
| } |
|
345 |
84
| if (section.getSubsectionList() != null) {
|
|
346 |
40
| setLocationWithinModule(context + ".getSubsectionList()");
|
|
347 |
40
| accept(section.getSubsectionList());
|
|
348 |
| } |
|
349 |
84
| setLocationWithinModule(context);
|
|
350 |
84
| visitor.visitLeave(section);
|
|
351 |
| } |
|
352 |
| |
|
353 |
40
| public void accept(final SubsectionList subsectionList) throws ModuleDataException {
|
|
354 |
40
| if (subsectionList == null) {
|
|
355 |
0
| return;
|
|
356 |
| } |
|
357 |
40
| visitor.visitEnter(subsectionList);
|
|
358 |
40
| final String context = getCurrentContext().getLocationWithinModule();
|
|
359 |
40
| for (int i = 0; i < subsectionList.size(); i++) {
|
|
360 |
248
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
361 |
| |
|
362 |
248
| if (subsectionList.get(i) instanceof Subsection) {
|
|
363 |
48
| accept((Subsection) subsectionList.get(i));
|
|
364 |
200
| } else if (subsectionList.get(i) instanceof Node) {
|
|
365 |
200
| accept((Node) subsectionList.get(i));
|
|
366 |
0
| } else if (subsectionList.get(i) == null) {
|
|
367 |
| |
|
368 |
| } else { |
|
369 |
0
| throw new IllegalArgumentException("unexpected subsection type: "
|
|
370 |
| + subsectionList.get(i).getClass()); |
|
371 |
| } |
|
372 |
| } |
|
373 |
40
| setLocationWithinModule(context);
|
|
374 |
40
| visitor.visitLeave(subsectionList);
|
|
375 |
| } |
|
376 |
| |
|
377 |
48
| public void accept(final Subsection subsection) throws ModuleDataException {
|
|
378 |
48
| if (subsection == null) {
|
|
379 |
0
| return;
|
|
380 |
| } |
|
381 |
48
| visitor.visitEnter(subsection);
|
|
382 |
48
| final String context = getCurrentContext().getLocationWithinModule();
|
|
383 |
48
| if (subsection.getTitle() != null) {
|
|
384 |
42
| setLocationWithinModule(context + ".getTitle()");
|
|
385 |
42
| accept(subsection.getTitle());
|
|
386 |
| } |
|
387 |
48
| if (subsection.getLatex() != null) {
|
|
388 |
48
| setLocationWithinModule(context + ".getLatex()");
|
|
389 |
48
| accept(subsection.getLatex());
|
|
390 |
| } |
|
391 |
48
| setLocationWithinModule(context);
|
|
392 |
48
| visitor.visitLeave(subsection);
|
|
393 |
| } |
|
394 |
| |
|
395 |
200
| public void accept(final Node node) throws ModuleDataException {
|
|
396 |
200
| if (node == null) {
|
|
397 |
0
| return;
|
|
398 |
| } |
|
399 |
200
| visitor.visitEnter(node);
|
|
400 |
200
| final String context = getCurrentContext().getLocationWithinModule();
|
|
401 |
200
| if (node.getName() != null) {
|
|
402 |
92
| setLocationWithinModule(context + ".getName()");
|
|
403 |
92
| accept(node.getName());
|
|
404 |
| } |
|
405 |
200
| if (node.getTitle() != null) {
|
|
406 |
92
| setLocationWithinModule(context + ".getTitle()");
|
|
407 |
92
| accept(node.getTitle());
|
|
408 |
| } |
|
409 |
200
| if (node.getPrecedingText() != null) {
|
|
410 |
200
| setLocationWithinModule(context + ".getPrecedingText()");
|
|
411 |
200
| accept(node.getPrecedingText());
|
|
412 |
| } |
|
413 |
200
| if (node.getNodeType() != null) {
|
|
414 |
200
| setLocationWithinModule(context + ".getNodeType()");
|
|
415 |
200
| if (node.getNodeType() instanceof Axiom) {
|
|
416 |
32
| setLocationWithinModule(context + ".getNodeType().getAxiom()");
|
|
417 |
32
| accept((Axiom) node.getNodeType());
|
|
418 |
168
| } else if (node.getNodeType() instanceof PredicateDefinition) {
|
|
419 |
24
| |