01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: package de.uka.ilkd.key.java.visitor;
09:
10: import java.util.HashSet;
11:
12: import de.uka.ilkd.key.java.Label;
13: import de.uka.ilkd.key.java.ProgramElement;
14: import de.uka.ilkd.key.java.SourceElement;
15:
16: /**
17: * Collects all labels found in a given program.
18: */
19: public class LabelCollector extends JavaASTVisitor {
20:
21: private HashSet labels;
22:
23: public LabelCollector(ProgramElement root, HashSet labels) {
24: super (root);
25: this .labels = labels;
26: }
27:
28: public boolean contains(Label l) {
29: return labels.contains(l);
30: }
31:
32: protected void doDefaultAction(SourceElement node) {
33: if (node instanceof Label) {
34: labels.add(node);
35: }
36: }
37:
38: protected void doAction(ProgramElement node) {
39: if (node instanceof Label) {
40: labels.add(node);
41: }
42: }
43:
44: }
|