EclipseJDT Source Viewer

Home|eclipse_jdt/src/org/eclipse/jdt/core/dom/NodeEventHandler.java
1/*******************************************************************************
2 * Copyright (c) 2004, 2009 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 *     IBM Corporation - initial API and implementation
13 *******************************************************************************/
14package org.eclipse.jdt.core.dom;
15
16/**
17 * A node event handler is an internal mechanism for receiving
18 * notification of changes to nodes in an AST.
19 * <p>
20 * The default implementation serves as the default event handler
21 * that does nothing. Internal subclasses do all the real work.
22 * </p>
23 *
24 * @see AST#getEventHandler()
25 */
26class NodeEventHandler {
27
28    /**
29     * Creates a node event handler.
30     */
31    NodeEventHandler() {
32        // default implementation: do nothing
33    }
34
35    /**
36     * Reports that the given node is about to lose a child.
37     * The first half of an event pair. The default implementation does nothing.
38     *
39     * @param node the node about to be modified
40     * @param child the node about to be removed
41     * @param property the child or child list property descriptor
42     * @see #postRemoveChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
43     * @since 3.0
44     */
45    void preRemoveChildEvent(ASTNode nodeASTNode childStructuralPropertyDescriptor property) {
46        // do nothing
47        // System.out.println("DEL1 " + property);
48    }
49
50    /**
51     * Reports that the given node has just lose a child.
52     * The second half of an event pair. The default implementation does nothing.
53     *
54     * @param node the node that was modified
55     * @param child the child that was removed; note that this node is unparented
56     * @param property the child or child list property descriptor
57     * @see #preRemoveChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
58     * @since 3.0
59     */
60    void postRemoveChildEvent(ASTNode nodeASTNode childStructuralPropertyDescriptor property) {
61        // do nothing
62        // System.out.println("DEL2 " + property);
63    }
64
65    /**
66     * Reports that the given node is about to have a child replaced.
67     * The first half of an event pair.
68     * The default implementation does nothing.
69     *
70     * @param node the node about to be modified
71     * @param child the node about to be replaced
72     * @param newChild the replacement child; note that this node is unparented
73     * @param property the child or child list property descriptor
74     * @see #preReplaceChildEvent(ASTNode, ASTNode, ASTNode, StructuralPropertyDescriptor)
75     * @since 3.0
76     */
77    void preReplaceChildEvent(ASTNode nodeASTNode childASTNode newChildStructuralPropertyDescriptor property) {
78        // do nothing
79        // System.out.println("REP1 " + property);
80    }
81
82    /**
83     * Reports that the given node has had its child replaced. The second half
84     * of an event pair. The default implementation does nothing.
85     *
86     * @param node the node that was modified
87     * @param child the node that was replaced; note that this node is unparented
88     * @param newChild the replacement child
89     * @param property the child or child list property descriptor
90     * @see #postReplaceChildEvent(ASTNode, ASTNode, ASTNode, StructuralPropertyDescriptor)
91     * @since 3.0
92     */
93    void postReplaceChildEvent(ASTNode nodeASTNode childASTNode newChildStructuralPropertyDescriptor property) {
94        // do nothing
95        // System.out.println("REP2 " + property);
96    }
97
98    /**
99     * Reports that the given node is about to gain a child.
100     * The first half of an event pair. The default implementation does nothing.
101     *
102     * @param node the node that to be modified
103     * @param child the node that is to be added as a child; note that this
104     * node is unparented; in the case of a child list property, the exact
105     * location of insertion is not supplied (but is known on the
106     * corresponding <code>postAddChildEvent</code> to
107     * follow)
108     * @param property the child or child list property descriptor
109     * @see #postAddChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
110     * @since 3.0
111     */
112    void preAddChildEvent(ASTNode nodeASTNode childStructuralPropertyDescriptor property) {
113        // do nothing
114        // System.out.println("ADD1 " + property);
115    }
116
117    /**
118     * Reports that the given node has just gained a child.
119     * The second half of an event pair. The default implementation does nothing.
120     *
121     * @param node the node that was modified
122     * @param child the node that was added as a child
123     * @param property the child or child list property descriptor
124     * @see #preAddChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
125     * @since 3.0
126     */
127    void postAddChildEvent(ASTNode nodeASTNode childStructuralPropertyDescriptor property) {
128        // do nothing
129        // System.out.println("ADD2 " + property);
130    }
131
132    /**
133     * Reports that the given node is about to change the value of a
134     * non-child property. The first half of an event pair.
135     * The default implementation does nothing.
136     *
137     * @param node the node to be modified
138     * @param property the property descriptor
139     * @see #postValueChangeEvent(ASTNode, SimplePropertyDescriptor)
140     * @since 3.0
141     */
142    void preValueChangeEvent(ASTNode nodeSimplePropertyDescriptor property) {
143        // do nothing
144        // System.out.println("MOD1 " + property);
145    }
146
147    /**
148     * Reports that the given node has just changed the value of a
149     * non-child property. The second half of an event pair.
150     * The default implementation does nothing.
151     *
152     * @param node the node that was modified
153     * @param property the property descriptor
154     * @see #preValueChangeEvent(ASTNode, SimplePropertyDescriptor)
155     * @since 3.0
156     */
157    void postValueChangeEvent(ASTNode nodeSimplePropertyDescriptor property) {
158        // do nothing
159        // System.out.println("MOD2 " + property);
160    }
161
162    /**
163     * Reports that the given node is about to be cloned.
164     * The first half of an event pair.
165     * The default implementation does nothing.
166     *
167     * @param node the node to be modified
168     * @see #postCloneNodeEvent(ASTNode, ASTNode)
169     * @since 3.0
170     */
171    void preCloneNodeEvent(ASTNode node) {
172        // do nothing
173        // System.out.println("CLONE1");
174    }
175
176    /**
177     * Reports that the given node has just been cloned.
178     * The second half of an event pair.
179     * The default implementation does nothing.
180     *
181     * @param node the node that was modified
182     * @param clone the clone of <code>node</code>
183     * @see #preCloneNodeEvent(ASTNode)
184     * @since 3.0
185     */
186    void postCloneNodeEvent(ASTNode nodeASTNode clone) {
187        // do nothing
188        // System.out.println("CLONE2");
189    }
190
191}
192
MembersX
NodeEventHandler:postReplaceChildEvent
NodeEventHandler:postRemoveChildEvent
NodeEventHandler:postAddChildEvent
NodeEventHandler:preRemoveChildEvent
NodeEventHandler:postCloneNodeEvent
NodeEventHandler:postValueChangeEvent
NodeEventHandler:preAddChildEvent
NodeEventHandler:preValueChangeEvent
NodeEventHandler:preCloneNodeEvent
NodeEventHandler:NodeEventHandler
NodeEventHandler:preReplaceChildEvent
Members
X