1 /*
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
135 /**
136 * Processes an element by calling {@code e.accept(this, p)};
137 * this method may be overridden by subclasses.
138 * @return the result of visiting {@code e}.
139 */
140 public R scan(Element e, P p) {
141 return e.accept(this, p);
142 }
143
144 /**
145 * Convenience method equivalent to {@code v.scan(e, null)}.
146 * @return the result of scanning {@code e}.
147 */
148 public final R scan(Element e) {
149 return scan(e, null);
150 }
151
152 /**
153 * {@inheritDoc} This implementation scans the enclosed elements.
154 *
155 * @param e the element to visit
156 * @param p a visitor-specified parameter
157 * @return the result of scanning
158 */
159 public R visitPackage(PackageElement e, P p) {
160 return scan(e.getEnclosedElements(), p);
161 }
162
163 /**
164 * {@inheritDoc} This implementation scans the enclosed elements.
165 *
166 * @param e the element to visit
167 * @param p a visitor-specified parameter
168 * @return the result of scanning
169 */
170 public R visitType(TypeElement e, P p) {
171 return scan(e.getEnclosedElements(), p);
172 }
173
174 /**
175 * {@inheritDoc} This implementation scans the enclosed elements.
176 *
177 * @param e the element to visit
178 * @param p a visitor-specified parameter
179 * @return the result of scanning
180 */
181 public R visitVariable(VariableElement e, P p) {
182 return scan(e.getEnclosedElements(), p);
183 }
184
185 /**
186 * {@inheritDoc} This implementation scans the parameters.
187 *
188 * @param e the element to visit
189 * @param p a visitor-specified parameter
190 * @return the result of scanning
191 */
192 public R visitExecutable(ExecutableElement e, P p) {
193 return scan(e.getParameters(), p);
194 }
195
196 /**
197 * {@inheritDoc} This implementation scans the enclosed elements.
198 *
199 * @param e the element to visit
200 * @param p a visitor-specified parameter
201 * @return the result of scanning
202 */
203 public R visitTypeParameter(TypeParameterElement e, P p) {
204 return scan(e.getEnclosedElements(), p);
205 }
206 }
|
1 /*
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
135 /**
136 * Processes an element by calling {@code e.accept(this, p)};
137 * this method may be overridden by subclasses.
138 * @return the result of visiting {@code e}.
139 */
140 public R scan(Element e, P p) {
141 return e.accept(this, p);
142 }
143
144 /**
145 * Convenience method equivalent to {@code v.scan(e, null)}.
146 * @return the result of scanning {@code e}.
147 */
148 public final R scan(Element e) {
149 return scan(e, null);
150 }
151
152 /**
153 * {@inheritDoc} This implementation scans the enclosed elements.
154 *
155 * @param e {@inheritDoc}
156 * @param p {@inheritDoc}
157 * @return the result of scanning
158 */
159 public R visitPackage(PackageElement e, P p) {
160 return scan(e.getEnclosedElements(), p);
161 }
162
163 /**
164 * {@inheritDoc} This implementation scans the enclosed elements.
165 *
166 * @param e {@inheritDoc}
167 * @param p {@inheritDoc}
168 * @return the result of scanning
169 */
170 public R visitType(TypeElement e, P p) {
171 return scan(e.getEnclosedElements(), p);
172 }
173
174 /**
175 * {@inheritDoc}
176 *
177 * This implementation scans the enclosed elements, unless the
178 * element is a {@code RESOURCE_VARIABLE} in which case {@code
179 * visitUnknown} is called.
180 *
181 * @param e {@inheritDoc}
182 * @param p {@inheritDoc}
183 * @return the result of scanning
184 */
185 public R visitVariable(VariableElement e, P p) {
186 if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
187 return scan(e.getEnclosedElements(), p);
188 else
189 return visitUnknown(e, p);
190 }
191
192 /**
193 * {@inheritDoc} This implementation scans the parameters.
194 *
195 * @param e {@inheritDoc}
196 * @param p {@inheritDoc}
197 * @return the result of scanning
198 */
199 public R visitExecutable(ExecutableElement e, P p) {
200 return scan(e.getParameters(), p);
201 }
202
203 /**
204 * {@inheritDoc} This implementation scans the enclosed elements.
205 *
206 * @param e {@inheritDoc}
207 * @param p {@inheritDoc}
208 * @return the result of scanning
209 */
210 public R visitTypeParameter(TypeParameterElement e, P p) {
211 return scan(e.getEnclosedElements(), p);
212 }
213 }
|