1 /*******************************************************************************
2 * Copyright (c) 2004, 2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.core.dom;
14 * A node event handler is an internal mechanism for receiving
15 * notification of changes to nodes in an AST.
17 * The default implementation serves as the default event handler
18 * that does nothing. Internal subclasses do all the real work.
21 * @see AST#getEventHandler()
23 class NodeEventHandler {
26 * Creates a node event handler.
29 // default implementation: do nothing
33 * Reports that the given node is about to lose a child.
34 * The first half of an event pair. The default implementation does nothing.
36 * @param node the node about to be modified
37 * @param child the node about to be removed
38 * @param property the child or child list property descriptor
39 * @see #postRemoveChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
42 void preRemoveChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
44 // System.out.println("DEL1 " + property);
48 * Reports that the given node has just lose a child.
49 * The second half of an event pair. The default implementation does nothing.
51 * @param node the node that was modified
52 * @param child the child that was removed; note that this node is unparented
53 * @param property the child or child list property descriptor
54 * @see #preRemoveChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
57 void postRemoveChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
59 // System.out.println("DEL2 " + property);
63 * Reports that the given node is about to have a child replaced.
64 * The first half of an event pair.
65 * The default implementation does nothing.
67 * @param node the node about to be modified
68 * @param child the node about to be replaced
69 * @param newChild the replacement child; note that this node is unparented
70 * @param property the child or child list property descriptor
71 * @see #preReplaceChildEvent(ASTNode, ASTNode, ASTNode, StructuralPropertyDescriptor)
74 void preReplaceChildEvent(ASTNode node, ASTNode child, ASTNode newChild, StructuralPropertyDescriptor property) {
76 // System.out.println("REP1 " + property);
80 * Reports that the given node has had its child replaced. The second half
81 * of an event pair. The default implementation does nothing.
83 * @param node the node that was modified
84 * @param child the node that was replaced; note that this node is unparented
85 * @param newChild the replacement child
86 * @param property the child or child list property descriptor
87 * @see #postReplaceChildEvent(ASTNode, ASTNode, ASTNode, StructuralPropertyDescriptor)
90 void postReplaceChildEvent(ASTNode node, ASTNode child, ASTNode newChild, StructuralPropertyDescriptor property) {
92 // System.out.println("REP2 " + property);
96 * Reports that the given node is about to gain a child.
97 * The first half of an event pair. The default implementation does nothing.
99 * @param node the node that to be modified
100 * @param child the node that is to be added as a child; note that this
101 * node is unparented; in the case of a child list property, the exact
102 * location of insertion is not supplied (but is known on the
103 * corresponding <code>postAddChildEvent</code> to
105 * @param property the child or child list property descriptor
106 * @see #postAddChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
109 void preAddChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
111 // System.out.println("ADD1 " + property);
115 * Reports that the given node has just gained a child.
116 * The second half of an event pair. The default implementation does nothing.
118 * @param node the node that was modified
119 * @param child the node that was added as a child
120 * @param property the child or child list property descriptor
121 * @see #preAddChildEvent(ASTNode, ASTNode, StructuralPropertyDescriptor)
124 void postAddChildEvent(ASTNode node, ASTNode child, StructuralPropertyDescriptor property) {
126 // System.out.println("ADD2 " + property);
130 * Reports that the given node is about to change the value of a
131 * non-child property. The first half of an event pair.
132 * The default implementation does nothing.
134 * @param node the node to be modified
135 * @param property the property descriptor
136 * @see #postValueChangeEvent(ASTNode, SimplePropertyDescriptor)
139 void preValueChangeEvent(ASTNode node, SimplePropertyDescriptor property) {
141 // System.out.println("MOD1 " + property);
145 * Reports that the given node has just changed the value of a
146 * non-child property. The second half of an event pair.
147 * The default implementation does nothing.
149 * @param node the node that was modified
150 * @param property the property descriptor
151 * @see #preValueChangeEvent(ASTNode, SimplePropertyDescriptor)
154 void postValueChangeEvent(ASTNode node, SimplePropertyDescriptor property) {
156 // System.out.println("MOD2 " + property);
160 * Reports that the given node is about to be cloned.
161 * The first half of an event pair.
162 * The default implementation does nothing.
164 * @param node the node to be modified
165 * @see #postCloneNodeEvent(ASTNode, ASTNode)
168 void preCloneNodeEvent(ASTNode node) {
170 // System.out.println("CLONE1");
174 * Reports that the given node has just been cloned.
175 * The second half of an event pair.
176 * The default implementation does nothing.
178 * @param node the node that was modified
179 * @param clone the clone of <code>node</code>
180 * @see #preCloneNodeEvent(ASTNode)
183 void postCloneNodeEvent(ASTNode node, ASTNode clone) {
185 // System.out.println("CLONE2");