Lines 32-43
Link Here
|
32 |
/** |
32 |
/** |
33 |
* Umbrella owner and abstract syntax tree node factory. |
33 |
* Umbrella owner and abstract syntax tree node factory. |
34 |
* An <code>AST</code> instance serves as the common owner of any number of |
34 |
* An <code>AST</code> instance serves as the common owner of any number of |
35 |
* AST nodes, and as the factory for creating new AST nodes owned by that |
35 |
* AST nodes, and as the factory for creating new AST nodes owned by that |
36 |
* instance. |
36 |
* instance. |
37 |
* <p> |
37 |
* <p> |
38 |
* Abstract syntax trees may be hand constructed by clients, using the |
38 |
* Abstract syntax trees may be hand constructed by clients, using the |
39 |
* <code>new<i>TYPE</i></code> factory methods to create new nodes, and the |
39 |
* <code>new<i>TYPE</i></code> factory methods to create new nodes, and the |
40 |
* various <code>set<i>CHILD</i></code> methods |
40 |
* various <code>set<i>CHILD</i></code> methods |
41 |
* (see {@link org.eclipse.jdt.core.dom.ASTNode ASTNode} and its subclasses) |
41 |
* (see {@link org.eclipse.jdt.core.dom.ASTNode ASTNode} and its subclasses) |
42 |
* to connect them together. |
42 |
* to connect them together. |
43 |
* </p> |
43 |
* </p> |
Lines 84-98
Link Here
|
84 |
* read-only AST. |
84 |
* read-only AST. |
85 |
* </p> |
85 |
* </p> |
86 |
* <p> |
86 |
* <p> |
87 |
* Clients may create instances of this class using {@link #newAST(int)}, |
87 |
* Clients may create instances of this class using {@link #newAST(int)}, |
88 |
* but this class is not intended to be subclassed. |
88 |
* but this class is not intended to be subclassed. |
89 |
* </p> |
89 |
* </p> |
90 |
* |
90 |
* |
91 |
* @see ASTParser |
91 |
* @see ASTParser |
92 |
* @see ASTNode |
92 |
* @see ASTNode |
93 |
* @since 2.0 |
93 |
* @since 2.0 |
94 |
*/ |
94 |
*/ |
95 |
public final class AST { |
95 |
public final class AST { |
|
|
96 |
|
97 |
static final int RESOLVED_BINDINGS = 0x01; |
98 |
static final int STATEMENT_RECOVERY = 0x02; |
96 |
/** |
99 |
/** |
97 |
* Constant for indicating the AST API that handles JLS2. |
100 |
* Constant for indicating the AST API that handles JLS2. |
98 |
* This API is capable of handling all constructs |
101 |
* This API is capable of handling all constructs |
Lines 107-113
Link Here
|
107 |
* @deprecated Clients should use the {@link #JLS3} AST API instead. |
110 |
* @deprecated Clients should use the {@link #JLS3} AST API instead. |
108 |
*/ |
111 |
*/ |
109 |
public static final int JLS2 = 2; |
112 |
public static final int JLS2 = 2; |
110 |
|
113 |
|
111 |
/** |
114 |
/** |
112 |
* Internal synonym for {@link #JLS2}. Use to alleviate |
115 |
* Internal synonym for {@link #JLS2}. Use to alleviate |
113 |
* deprecation warnings. |
116 |
* deprecation warnings. |
Lines 123-159
Link Here
|
123 |
* JLS3 is a superset of all earlier versions of the |
126 |
* JLS3 is a superset of all earlier versions of the |
124 |
* Java language, and the JLS3 API can be used to manipulate |
127 |
* Java language, and the JLS3 API can be used to manipulate |
125 |
* programs written in all versions of the Java language |
128 |
* programs written in all versions of the Java language |
126 |
* up to and including J2SE 5 (aka JDK 1.5). |
129 |
* up to and including J2SE 5 (aka JDK 1.5). |
127 |
* |
130 |
* |
128 |
* @since 3.1 |
131 |
* @since 3.1 |
129 |
*/ |
132 |
*/ |
130 |
public static final int JLS3 = 3; |
133 |
public static final int JLS3 = 3; |
131 |
|
134 |
|
132 |
/** |
135 |
/** |
133 |
* The binding resolver for this AST. Initially a binding resolver that |
136 |
* The binding resolver for this AST. Initially a binding resolver that |
134 |
* does not resolve names at all. |
137 |
* does not resolve names at all. |
135 |
*/ |
138 |
*/ |
136 |
private BindingResolver resolver = new BindingResolver(); |
139 |
private BindingResolver resolver = new BindingResolver(); |
137 |
|
140 |
|
138 |
/** |
141 |
/** |
139 |
* The event handler for this AST. |
142 |
* The event handler for this AST. |
140 |
* Initially an event handler that does not nothing. |
143 |
* Initially an event handler that does not nothing. |
141 |
* @since 3.0 |
144 |
* @since 3.0 |
142 |
*/ |
145 |
*/ |
143 |
private NodeEventHandler eventHandler = new NodeEventHandler(); |
146 |
private NodeEventHandler eventHandler = new NodeEventHandler(); |
144 |
|
147 |
|
145 |
/** |
148 |
/** |
146 |
* Level of AST API supported by this AST. |
149 |
* Level of AST API supported by this AST. |
147 |
* @since 3.0 |
150 |
* @since 3.0 |
148 |
*/ |
151 |
*/ |
149 |
int apiLevel; |
152 |
int apiLevel; |
150 |
|
153 |
|
151 |
/** |
154 |
/** |
152 |
* Internal modification count; initially 0; increases monotonically |
155 |
* Internal modification count; initially 0; increases monotonically |
153 |
* <b>by one or more</b> as the AST is successively modified. |
156 |
* <b>by one or more</b> as the AST is successively modified. |
154 |
*/ |
157 |
*/ |
155 |
private long modificationCount = 0; |
158 |
private long modificationCount = 0; |
156 |
|
159 |
|
157 |
/** |
160 |
/** |
158 |
* Internal original modification count; value is equals to <code> |
161 |
* Internal original modification count; value is equals to <code> |
159 |
* modificationCount</code> at the end of the parse (<code>ASTParser |
162 |
* modificationCount</code> at the end of the parse (<code>ASTParser |
Lines 173-179
Link Here
|
173 |
* @since 3.0 |
176 |
* @since 3.0 |
174 |
*/ |
177 |
*/ |
175 |
private int disableEvents = 0; |
178 |
private int disableEvents = 0; |
176 |
|
179 |
|
177 |
/** |
180 |
/** |
178 |
* Internal object unique to the AST instance. Readers must synchronize on |
181 |
* Internal object unique to the AST instance. Readers must synchronize on |
179 |
* this object when the modifying instance fields. |
182 |
* this object when the modifying instance fields. |
Lines 186-206
Link Here
|
186 |
* like CharacterLiteral, NumberLiteral, StringLiteral or SimpleName. |
189 |
* like CharacterLiteral, NumberLiteral, StringLiteral or SimpleName. |
187 |
*/ |
190 |
*/ |
188 |
Scanner scanner; |
191 |
Scanner scanner; |
189 |
|
192 |
|
190 |
/** |
193 |
/** |
191 |
* Internal ast rewriter used to record ast modification when record mode is enabled. |
194 |
* Internal ast rewriter used to record ast modification when record mode is enabled. |
192 |
*/ |
195 |
*/ |
193 |
InternalASTRewrite rewriter; |
196 |
InternalASTRewrite rewriter; |
194 |
|
197 |
|
195 |
/** |
198 |
/** |
196 |
* Default value of <code>flag<code> when a new node is created. |
199 |
* Default value of <code>flag<code> when a new node is created. |
197 |
*/ |
200 |
*/ |
198 |
private int defaultNodeFlag = 0; |
201 |
private int defaultNodeFlag = 0; |
199 |
|
202 |
|
|
|
203 |
/** |
204 |
* Tag bit value. This represents internal state of the tree. |
205 |
*/ |
206 |
private int bits; |
207 |
|
200 |
/** |
208 |
/** |
201 |
* Creates a new Java abstract syntax tree |
209 |
* Creates a new Java abstract syntax tree |
202 |
* (AST) following the specified set of API rules. |
210 |
* (AST) following the specified set of API rules. |
203 |
* |
211 |
* |
204 |
* @param level the API level; one of the LEVEL constants |
212 |
* @param level the API level; one of the LEVEL constants |
205 |
* @since 3.0 |
213 |
* @since 3.0 |
206 |
*/ |
214 |
*/ |
Lines 212-230
Link Here
|
212 |
this.apiLevel = level; |
220 |
this.apiLevel = level; |
213 |
// initialize a scanner |
221 |
// initialize a scanner |
214 |
this.scanner = new Scanner( |
222 |
this.scanner = new Scanner( |
215 |
true /*comment*/, |
223 |
true /*comment*/, |
216 |
true /*whitespace*/, |
224 |
true /*whitespace*/, |
217 |
false /*nls*/, |
225 |
false /*nls*/, |
218 |
ClassFileConstants.JDK1_3 /*sourceLevel*/, |
226 |
ClassFileConstants.JDK1_3 /*sourceLevel*/, |
219 |
ClassFileConstants.JDK1_5 /*complianceLevel*/, |
227 |
ClassFileConstants.JDK1_5 /*complianceLevel*/, |
220 |
null/*taskTag*/, |
228 |
null/*taskTag*/, |
221 |
null/*taskPriorities*/, |
229 |
null/*taskPriorities*/, |
222 |
true/*taskCaseSensitive*/); |
230 |
true/*taskCaseSensitive*/); |
223 |
} |
231 |
} |
224 |
|
232 |
|
225 |
/** |
233 |
/** |
226 |
* Creates a new, empty abstract syntax tree using default options. |
234 |
* Creates a new, empty abstract syntax tree using default options. |
227 |
* |
235 |
* |
228 |
* @see JavaCore#getDefaultOptions() |
236 |
* @see JavaCore#getDefaultOptions() |
229 |
* @deprecated Clients should port their code to use the new JLS3 AST API and call |
237 |
* @deprecated Clients should port their code to use the new JLS3 AST API and call |
230 |
* {@link #newAST(int) AST.newAST(AST.JLS3)} instead of using this constructor. |
238 |
* {@link #newAST(int) AST.newAST(AST.JLS3)} instead of using this constructor. |
Lines 239-245
Link Here
|
239 |
* This method converts the given internal compiler AST for the given source string |
247 |
* This method converts the given internal compiler AST for the given source string |
240 |
* into a compilation unit. This method is not intended to be called by clients. |
248 |
* into a compilation unit. This method is not intended to be called by clients. |
241 |
* </p> |
249 |
* </p> |
242 |
* |
250 |
* |
243 |
* @param level the API level; one of the LEVEL constants |
251 |
* @param level the API level; one of the LEVEL constants |
244 |
* @param compilationUnitDeclaration an internal AST node for a compilation unit declaration |
252 |
* @param compilationUnitDeclaration an internal AST node for a compilation unit declaration |
245 |
* @param source the string of the Java compilation unit |
253 |
* @param source the string of the Java compilation unit |
Lines 257-272
Link Here
|
257 |
Map options, |
265 |
Map options, |
258 |
boolean isResolved, |
266 |
boolean isResolved, |
259 |
org.eclipse.jdt.internal.core.CompilationUnit workingCopy, |
267 |
org.eclipse.jdt.internal.core.CompilationUnit workingCopy, |
|
|
268 |
boolean statementRecovery, |
260 |
IProgressMonitor monitor) { |
269 |
IProgressMonitor monitor) { |
261 |
|
270 |
|
262 |
ASTConverter converter = new ASTConverter(options, isResolved, monitor); |
271 |
ASTConverter converter = new ASTConverter(options, isResolved, monitor); |
263 |
AST ast = AST.newAST(level); |
272 |
AST ast = AST.newAST(level); |
|
|
273 |
if (statementRecovery) { |
274 |
ast.setFlag(AST.STATEMENT_RECOVERY); |
275 |
} |
264 |
int savedDefaultNodeFlag = ast.getDefaultNodeFlag(); |
276 |
int savedDefaultNodeFlag = ast.getDefaultNodeFlag(); |
265 |
ast.setDefaultNodeFlag(ASTNode.ORIGINAL); |
277 |
ast.setDefaultNodeFlag(ASTNode.ORIGINAL); |
266 |
BindingResolver resolver = isResolved ? new DefaultBindingResolver(compilationUnitDeclaration.scope, workingCopy.owner, new DefaultBindingResolver.BindingTables()) : new BindingResolver(); |
278 |
BindingResolver resolver = null; |
|
|
279 |
if (isResolved) { |
280 |
ast.setFlag(AST.RESOLVED_BINDINGS); |
281 |
resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope, workingCopy.owner, new DefaultBindingResolver.BindingTables()); |
282 |
} else { |
283 |
resolver = new BindingResolver(); |
284 |
} |
267 |
ast.setBindingResolver(resolver); |
285 |
ast.setBindingResolver(resolver); |
268 |
converter.setAST(ast); |
286 |
converter.setAST(ast); |
269 |
|
287 |
|
270 |
CompilationUnit unit = converter.convert(compilationUnitDeclaration, source); |
288 |
CompilationUnit unit = converter.convert(compilationUnitDeclaration, source); |
271 |
unit.setLineEndTable(compilationUnitDeclaration.compilationResult.getLineSeparatorPositions()); |
289 |
unit.setLineEndTable(compilationUnitDeclaration.compilationResult.getLineSeparatorPositions()); |
272 |
unit.setTypeRoot(workingCopy); |
290 |
unit.setTypeRoot(workingCopy); |
Lines 279-285
Link Here
|
279 |
* <p> |
297 |
* <p> |
280 |
* Following option keys are significant: |
298 |
* Following option keys are significant: |
281 |
* <ul> |
299 |
* <ul> |
282 |
* <li><code>"org.eclipse.jdt.core.compiler.source"</code> - |
300 |
* <li><code>"org.eclipse.jdt.core.compiler.source"</code> - |
283 |
* indicates source compatibility mode (as per <code>JavaCore</code>); |
301 |
* indicates source compatibility mode (as per <code>JavaCore</code>); |
284 |
* <code>"1.3"</code> means the source code is as per JDK 1.3; |
302 |
* <code>"1.3"</code> means the source code is as per JDK 1.3; |
285 |
* <code>"1.4"</code> means the source code is as per JDK 1.4 |
303 |
* <code>"1.4"</code> means the source code is as per JDK 1.4 |
Lines 290-296
Link Here
|
290 |
* </ul> |
308 |
* </ul> |
291 |
* Options other than the above are ignored. |
309 |
* Options other than the above are ignored. |
292 |
* </p> |
310 |
* </p> |
293 |
* |
311 |
* |
294 |
* @param options the table of options (key type: <code>String</code>; |
312 |
* @param options the table of options (key type: <code>String</code>; |
295 |
* value type: <code>String</code>) |
313 |
* value type: <code>String</code>) |
296 |
* @see JavaCore#getDefaultOptions() |
314 |
* @see JavaCore#getDefaultOptions() |
Lines 315-338
Link Here
|
315 |
} |
333 |
} |
316 |
// override scanner if 1.4 or 1.5 asked for |
334 |
// override scanner if 1.4 or 1.5 asked for |
317 |
this.scanner = new Scanner( |
335 |
this.scanner = new Scanner( |
318 |
true /*comment*/, |
336 |
true /*comment*/, |
319 |
true /*whitespace*/, |
337 |
true /*whitespace*/, |
320 |
false /*nls*/, |
338 |
false /*nls*/, |
321 |
sourceLevel /*sourceLevel*/, |
339 |
sourceLevel /*sourceLevel*/, |
322 |
complianceLevel /*complianceLevel*/, |
340 |
complianceLevel /*complianceLevel*/, |
323 |
null/*taskTag*/, |
341 |
null/*taskTag*/, |
324 |
null/*taskPriorities*/, |
342 |
null/*taskPriorities*/, |
325 |
true/*taskCaseSensitive*/); |
343 |
true/*taskCaseSensitive*/); |
326 |
} |
344 |
} |
327 |
|
345 |
|
328 |
/** |
346 |
/** |
329 |
* Creates a new Java abstract syntax tree |
347 |
* Creates a new Java abstract syntax tree |
330 |
* (AST) following the specified set of API rules. |
348 |
* (AST) following the specified set of API rules. |
331 |
* <p> |
349 |
* <p> |
332 |
* Clients should use this method specifing {@link #JLS3} as the |
350 |
* Clients should use this method specifing {@link #JLS3} as the |
333 |
* AST level in all cases, even when dealing with JDK 1.3 or 1.4.. |
351 |
* AST level in all cases, even when dealing with JDK 1.3 or 1.4.. |
334 |
* </p> |
352 |
* </p> |
335 |
* |
353 |
* |
336 |
* @param level the API level; one of the LEVEL constants |
354 |
* @param level the API level; one of the LEVEL constants |
337 |
* @return new AST instance following the specified set of API rules. |
355 |
* @return new AST instance following the specified set of API rules. |
338 |
* @exception IllegalArgumentException if: |
356 |
* @exception IllegalArgumentException if: |
Lines 367-376
Link Here
|
367 |
* <p> |
385 |
* <p> |
368 |
* N.B. This method may be called several times in the course |
386 |
* N.B. This method may be called several times in the course |
369 |
* of a single client operation. The only promise is that the modification |
387 |
* of a single client operation. The only promise is that the modification |
370 |
* count increases monotonically as the AST or its nodes change; there is |
388 |
* count increases monotonically as the AST or its nodes change; there is |
371 |
* no promise that a modifying operation increases the count by exactly 1. |
389 |
* no promise that a modifying operation increases the count by exactly 1. |
372 |
* </p> |
390 |
* </p> |
373 |
* |
391 |
* |
374 |
* @return the current value (non-negative) of the modification counter of |
392 |
* @return the current value (non-negative) of the modification counter of |
375 |
* this AST |
393 |
* this AST |
376 |
*/ |
394 |
*/ |
Lines 380-392
Link Here
|
380 |
|
398 |
|
381 |
/** |
399 |
/** |
382 |
* Return the API level supported by this AST. |
400 |
* Return the API level supported by this AST. |
383 |
* |
401 |
* |
384 |
* @return level the API level; one of the <code>JLS*</code>LEVEL |
402 |
* @return level the API level; one of the <code>JLS*</code>LEVEL |
385 |
* declared on <code>AST</code>; assume this set is open-ended |
403 |
* declared on <code>AST</code>; assume this set is open-ended |
386 |
* @since 3.0 |
404 |
* @since 3.0 |
387 |
*/ |
405 |
*/ |
388 |
public int apiLevel() { |
406 |
public int apiLevel() { |
389 |
return this.apiLevel; |
407 |
return this.apiLevel; |
390 |
} |
408 |
} |
391 |
|
409 |
|
392 |
/** |
410 |
/** |
Lines 403-409
Link Here
|
403 |
* <p> |
421 |
* <p> |
404 |
* N.B. This method may be called several times in the course |
422 |
* N.B. This method may be called several times in the course |
405 |
* of a single client operation. |
423 |
* of a single client operation. |
406 |
* </p> |
424 |
* </p> |
407 |
*/ |
425 |
*/ |
408 |
void modifying() { |
426 |
void modifying() { |
409 |
// when this method is called during lazy init, events are disabled |
427 |
// when this method is called during lazy init, events are disabled |
Lines 418-424
Link Here
|
418 |
/** |
436 |
/** |
419 |
* Disable events. |
437 |
* Disable events. |
420 |
* This method is thread-safe for AST readers. |
438 |
* This method is thread-safe for AST readers. |
421 |
* |
439 |
* |
422 |
* @see #reenableEvents() |
440 |
* @see #reenableEvents() |
423 |
* @since 3.0 |
441 |
* @since 3.0 |
424 |
*/ |
442 |
*/ |
Lines 429-439
Link Here
|
429 |
} |
447 |
} |
430 |
// while disableEvents > 0 no events will be reported, and mod count will stay fixed |
448 |
// while disableEvents > 0 no events will be reported, and mod count will stay fixed |
431 |
} |
449 |
} |
432 |
|
450 |
|
433 |
/** |
451 |
/** |
434 |
* Reenable events. |
452 |
* Reenable events. |
435 |
* This method is thread-safe for AST readers. |
453 |
* This method is thread-safe for AST readers. |
436 |
* |
454 |
* |
437 |
* @see #disableEvents() |
455 |
* @see #disableEvents() |
438 |
* @since 3.0 |
456 |
* @since 3.0 |
439 |
*/ |
457 |
*/ |
Lines 443-452
Link Here
|
443 |
this.disableEvents--; |
461 |
this.disableEvents--; |
444 |
} |
462 |
} |
445 |
} |
463 |
} |
446 |
|
464 |
|
447 |
/** |
465 |
/** |
448 |
* Reports that the given node is about to lose a child. |
466 |
* Reports that the given node is about to lose a child. |
449 |
* |
467 |
* |
450 |
* @param node the node about to be modified |
468 |
* @param node the node about to be modified |
451 |
* @param child the node about to be removed |
469 |
* @param child the node about to be removed |
452 |
* @param property the child or child list property descriptor |
470 |
* @param property the child or child list property descriptor |
Lines 472-481
Link Here
|
472 |
reenableEvents(); |
490 |
reenableEvents(); |
473 |
} |
491 |
} |
474 |
} |
492 |
} |
475 |
|
493 |
|
476 |
/** |
494 |
/** |
477 |
* Reports that the given node jsut lost a child. |
495 |
* Reports that the given node jsut lost a child. |
478 |
* |
496 |
* |
479 |
* @param node the node that was modified |
497 |
* @param node the node that was modified |
480 |
* @param child the child node that was removed |
498 |
* @param child the child node that was removed |
481 |
* @param property the child or child list property descriptor |
499 |
* @param property the child or child list property descriptor |
Lines 501-510
Link Here
|
501 |
reenableEvents(); |
519 |
reenableEvents(); |
502 |
} |
520 |
} |
503 |
} |
521 |
} |
504 |
|
522 |
|
505 |
/** |
523 |
/** |
506 |
* Reports that the given node is about have a child replaced. |
524 |
* Reports that the given node is about have a child replaced. |
507 |
* |
525 |
* |
508 |
* @param node the node about to be modified |
526 |
* @param node the node about to be modified |
509 |
* @param child the child node about to be removed |
527 |
* @param child the child node about to be removed |
510 |
* @param newChild the replacement child |
528 |
* @param newChild the replacement child |
Lines 531-540
Link Here
|
531 |
reenableEvents(); |
549 |
reenableEvents(); |
532 |
} |
550 |
} |
533 |
} |
551 |
} |
534 |
|
552 |
|
535 |
/** |
553 |
/** |
536 |
* Reports that the given node has just had a child replaced. |
554 |
* Reports that the given node has just had a child replaced. |
537 |
* |
555 |
* |
538 |
* @param node the node modified |
556 |
* @param node the node modified |
539 |
* @param child the child removed |
557 |
* @param child the child removed |
540 |
* @param newChild the replacement child |
558 |
* @param newChild the replacement child |
Lines 561-570
Link Here
|
561 |
reenableEvents(); |
579 |
reenableEvents(); |
562 |
} |
580 |
} |
563 |
} |
581 |
} |
564 |
|
582 |
|
565 |
/** |
583 |
/** |
566 |
* Reports that the given node is about to gain a child. |
584 |
* Reports that the given node is about to gain a child. |
567 |
* |
585 |
* |
568 |
* @param node the node that to be modified |
586 |
* @param node the node that to be modified |
569 |
* @param child the node that to be added as a child |
587 |
* @param child the node that to be added as a child |
570 |
* @param property the child or child list property descriptor |
588 |
* @param property the child or child list property descriptor |
Lines 590-599
Link Here
|
590 |
reenableEvents(); |
608 |
reenableEvents(); |
591 |
} |
609 |
} |
592 |
} |
610 |
} |
593 |
|
611 |
|
594 |
/** |
612 |
/** |
595 |
* Reports that the given node has just gained a child. |
613 |
* Reports that the given node has just gained a child. |
596 |
* |
614 |
* |
597 |
* @param node the node that was modified |
615 |
* @param node the node that was modified |
598 |
* @param child the node that was added as a child |
616 |
* @param child the node that was added as a child |
599 |
* @param property the child or child list property descriptor |
617 |
* @param property the child or child list property descriptor |
Lines 619-629
Link Here
|
619 |
reenableEvents(); |
637 |
reenableEvents(); |
620 |
} |
638 |
} |
621 |
} |
639 |
} |
622 |
|
640 |
|
623 |
/** |
641 |
/** |
624 |
* Reports that the given node is about to change the value of a |
642 |
* Reports that the given node is about to change the value of a |
625 |
* non-child property. |
643 |
* non-child property. |
626 |
* |
644 |
* |
627 |
* @param node the node to be modified |
645 |
* @param node the node to be modified |
628 |
* @param property the property descriptor |
646 |
* @param property the property descriptor |
629 |
* @since 3.0 |
647 |
* @since 3.0 |
Lines 648-658
Link Here
|
648 |
reenableEvents(); |
666 |
reenableEvents(); |
649 |
} |
667 |
} |
650 |
} |
668 |
} |
651 |
|
669 |
|
652 |
/** |
670 |
/** |
653 |
* Reports that the given node has just changed the value of a |
671 |
* Reports that the given node has just changed the value of a |
654 |
* non-child property. |
672 |
* non-child property. |
655 |
* |
673 |
* |
656 |
* @param node the node that was modified |
674 |
* @param node the node that was modified |
657 |
* @param property the property descriptor |
675 |
* @param property the property descriptor |
658 |
* @since 3.0 |
676 |
* @since 3.0 |
Lines 677-686
Link Here
|
677 |
reenableEvents(); |
695 |
reenableEvents(); |
678 |
} |
696 |
} |
679 |
} |
697 |
} |
680 |
|
698 |
|
681 |
/** |
699 |
/** |
682 |
* Reports that the given node is about to be cloned. |
700 |
* Reports that the given node is about to be cloned. |
683 |
* |
701 |
* |
684 |
* @param node the node to be cloned |
702 |
* @param node the node to be cloned |
685 |
* @since 3.0 |
703 |
* @since 3.0 |
686 |
*/ |
704 |
*/ |
Lines 703-712
Link Here
|
703 |
reenableEvents(); |
721 |
reenableEvents(); |
704 |
} |
722 |
} |
705 |
} |
723 |
} |
706 |
|
724 |
|
707 |
/** |
725 |
/** |
708 |
* Reports that the given node has just been cloned. |
726 |
* Reports that the given node has just been cloned. |
709 |
* |
727 |
* |
710 |
* @param node the node that was cloned |
728 |
* @param node the node that was cloned |
711 |
* @param clone the clone of <code>node</code> |
729 |
* @param clone the clone of <code>node</code> |
712 |
* @since 3.0 |
730 |
* @since 3.0 |
Lines 730-739
Link Here
|
730 |
reenableEvents(); |
748 |
reenableEvents(); |
731 |
} |
749 |
} |
732 |
} |
750 |
} |
733 |
|
751 |
|
734 |
/** |
752 |
/** |
735 |
* Parses the source string of the given Java model compilation unit element |
753 |
* Parses the source string of the given Java model compilation unit element |
736 |
* and creates and returns a corresponding abstract syntax tree. The source |
754 |
* and creates and returns a corresponding abstract syntax tree. The source |
737 |
* string is obtained from the Java model element using |
755 |
* string is obtained from the Java model element using |
738 |
* <code>ICompilationUnit.getSource()</code>. |
756 |
* <code>ICompilationUnit.getSource()</code>. |
739 |
* <p> |
757 |
* <p> |
Lines 741-747
Link Here
|
741 |
* Each node in the subtree carries source range(s) information relating back |
759 |
* Each node in the subtree carries source range(s) information relating back |
742 |
* to positions in the source string (the source string is not remembered |
760 |
* to positions in the source string (the source string is not remembered |
743 |
* with the AST). |
761 |
* with the AST). |
744 |
* The source range usually begins at the first character of the first token |
762 |
* The source range usually begins at the first character of the first token |
745 |
* corresponding to the node; leading whitespace and comments are <b>not</b> |
763 |
* corresponding to the node; leading whitespace and comments are <b>not</b> |
746 |
* included. The source range usually extends through the last character of |
764 |
* included. The source range usually extends through the last character of |
747 |
* the last token corresponding to the node; trailing whitespace and |
765 |
* the last token corresponding to the node; trailing whitespace and |
Lines 757-768
Link Here
|
757 |
* <p> |
775 |
* <p> |
758 |
* If <code>resolveBindings</code> is <code>true</code>, the various names |
776 |
* If <code>resolveBindings</code> is <code>true</code>, the various names |
759 |
* and types appearing in the compilation unit can be resolved to "bindings" |
777 |
* and types appearing in the compilation unit can be resolved to "bindings" |
760 |
* by calling the <code>resolveBinding</code> methods. These bindings |
778 |
* by calling the <code>resolveBinding</code> methods. These bindings |
761 |
* draw connections between the different parts of a program, and |
779 |
* draw connections between the different parts of a program, and |
762 |
* generally afford a more powerful vantage point for clients who wish to |
780 |
* generally afford a more powerful vantage point for clients who wish to |
763 |
* analyze a program's structure more deeply. These bindings come at a |
781 |
* analyze a program's structure more deeply. These bindings come at a |
764 |
* considerable cost in both time and space, however, and should not be |
782 |
* considerable cost in both time and space, however, and should not be |
765 |
* requested frivolously. The additional space is not reclaimed until the |
783 |
* requested frivolously. The additional space is not reclaimed until the |
766 |
* AST, all its nodes, and all its bindings become garbage. So it is very |
784 |
* AST, all its nodes, and all its bindings become garbage. So it is very |
767 |
* important to not retain any of these objects longer than absolutely |
785 |
* important to not retain any of these objects longer than absolutely |
768 |
* necessary. Bindings are resolved at the time the AST is created. Subsequent |
786 |
* necessary. Bindings are resolved at the time the AST is created. Subsequent |
Lines 770-786
Link Here
|
770 |
* <code>resolveBinding</code> methods in any way; these methods return the |
788 |
* <code>resolveBinding</code> methods in any way; these methods return the |
771 |
* same binding as before the AST was modified (including modifications |
789 |
* same binding as before the AST was modified (including modifications |
772 |
* that rearrange subtrees by reparenting nodes). |
790 |
* that rearrange subtrees by reparenting nodes). |
773 |
* If <code>resolveBindings</code> is <code>false</code>, the analysis |
791 |
* If <code>resolveBindings</code> is <code>false</code>, the analysis |
774 |
* does not go beyond parsing and building the tree, and all |
792 |
* does not go beyond parsing and building the tree, and all |
775 |
* <code>resolveBinding</code> methods return <code>null</code> from the |
793 |
* <code>resolveBinding</code> methods return <code>null</code> from the |
776 |
* outset. |
794 |
* outset. |
777 |
* </p> |
795 |
* </p> |
778 |
* |
796 |
* |
779 |
* @param unit the Java model compilation unit whose source code is to be parsed |
797 |
* @param unit the Java model compilation unit whose source code is to be parsed |
780 |
* @param resolveBindings <code>true</code> if bindings are wanted, |
798 |
* @param resolveBindings <code>true</code> if bindings are wanted, |
781 |
* and <code>false</code> if bindings are not of interest |
799 |
* and <code>false</code> if bindings are not of interest |
782 |
* @return the compilation unit node |
800 |
* @return the compilation unit node |
783 |
* @exception IllegalArgumentException if the given Java element does not |
801 |
* @exception IllegalArgumentException if the given Java element does not |
784 |
* exist or if its source string cannot be obtained |
802 |
* exist or if its source string cannot be obtained |
785 |
* @see ASTNode#getFlags() |
803 |
* @see ASTNode#getFlags() |
786 |
* @see ASTNode#MALFORMED |
804 |
* @see ASTNode#MALFORMED |
Lines 804-810
Link Here
|
804 |
throw new IllegalArgumentException(); |
822 |
throw new IllegalArgumentException(); |
805 |
} |
823 |
} |
806 |
} |
824 |
} |
807 |
|
825 |
|
808 |
/** |
826 |
/** |
809 |
* Parses the source string corresponding to the given Java class file |
827 |
* Parses the source string corresponding to the given Java class file |
810 |
* element and creates and returns a corresponding abstract syntax tree. |
828 |
* element and creates and returns a corresponding abstract syntax tree. |
Lines 816-822
Link Here
|
816 |
* Each node in the subtree carries source range(s) information relating back |
834 |
* Each node in the subtree carries source range(s) information relating back |
817 |
* to positions in the source string (the source string is not remembered |
835 |
* to positions in the source string (the source string is not remembered |
818 |
* with the AST). |
836 |
* with the AST). |
819 |
* The source range usually begins at the first character of the first token |
837 |
* The source range usually begins at the first character of the first token |
820 |
* corresponding to the node; leading whitespace and comments are <b>not</b> |
838 |
* corresponding to the node; leading whitespace and comments are <b>not</b> |
821 |
* included. The source range usually extends through the last character of |
839 |
* included. The source range usually extends through the last character of |
822 |
* the last token corresponding to the node; trailing whitespace and |
840 |
* the last token corresponding to the node; trailing whitespace and |
Lines 832-843
Link Here
|
832 |
* <p> |
850 |
* <p> |
833 |
* If <code>resolveBindings</code> is <code>true</code>, the various names |
851 |
* If <code>resolveBindings</code> is <code>true</code>, the various names |
834 |
* and types appearing in the compilation unit can be resolved to "bindings" |
852 |
* and types appearing in the compilation unit can be resolved to "bindings" |
835 |
* by calling the <code>resolveBinding</code> methods. These bindings |
853 |
* by calling the <code>resolveBinding</code> methods. These bindings |
836 |
* draw connections between the different parts of a program, and |
854 |
* draw connections between the different parts of a program, and |
837 |
* generally afford a more powerful vantage point for clients who wish to |
855 |
* generally afford a more powerful vantage point for clients who wish to |
838 |
* analyze a program's structure more deeply. These bindings come at a |
856 |
* analyze a program's structure more deeply. These bindings come at a |
839 |
* considerable cost in both time and space, however, and should not be |
857 |
* considerable cost in both time and space, however, and should not be |
840 |
* requested frivolously. The additional space is not reclaimed until the |
858 |
* requested frivolously. The additional space is not reclaimed until the |
841 |
* AST, all its nodes, and all its bindings become garbage. So it is very |
859 |
* AST, all its nodes, and all its bindings become garbage. So it is very |
842 |
* important to not retain any of these objects longer than absolutely |
860 |
* important to not retain any of these objects longer than absolutely |
843 |
* necessary. Bindings are resolved at the time the AST is created. Subsequent |
861 |
* necessary. Bindings are resolved at the time the AST is created. Subsequent |
Lines 845-861
Link Here
|
845 |
* <code>resolveBinding</code> methods in any way; these methods return the |
863 |
* <code>resolveBinding</code> methods in any way; these methods return the |
846 |
* same binding as before the AST was modified (including modifications |
864 |
* same binding as before the AST was modified (including modifications |
847 |
* that rearrange subtrees by reparenting nodes). |
865 |
* that rearrange subtrees by reparenting nodes). |
848 |
* If <code>resolveBindings</code> is <code>false</code>, the analysis |
866 |
* If <code>resolveBindings</code> is <code>false</code>, the analysis |
849 |
* does not go beyond parsing and building the tree, and all |
867 |
* does not go beyond parsing and building the tree, and all |
850 |
* <code>resolveBinding</code> methods return <code>null</code> from the |
868 |
* <code>resolveBinding</code> methods return <code>null</code> from the |
851 |
* outset. |
869 |
* outset. |
852 |
* </p> |
870 |
* </p> |
853 |
* |
871 |
* |
854 |
* @param classFile the Java model class file whose corresponding source code is to be parsed |
872 |
* @param classFile the Java model class file whose corresponding source code is to be parsed |
855 |
* @param resolveBindings <code>true</code> if bindings are wanted, |
873 |
* @param resolveBindings <code>true</code> if bindings are wanted, |
856 |
* and <code>false</code> if bindings are not of interest |
874 |
* and <code>false</code> if bindings are not of interest |
857 |
* @return the compilation unit node |
875 |
* @return the compilation unit node |
858 |
* @exception IllegalArgumentException if the given Java element does not |
876 |
* @exception IllegalArgumentException if the given Java element does not |
859 |
* exist or if its source string cannot be obtained |
877 |
* exist or if its source string cannot be obtained |
860 |
* @see ASTNode#getFlags() |
878 |
* @see ASTNode#getFlags() |
861 |
* @see ASTNode#MALFORMED |
879 |
* @see ASTNode#MALFORMED |
Lines 882-888
Link Here
|
882 |
throw new IllegalArgumentException(); |
900 |
throw new IllegalArgumentException(); |
883 |
} |
901 |
} |
884 |
} |
902 |
} |
885 |
|
903 |
|
886 |
/** |
904 |
/** |
887 |
* Parses the given string as the hypothetical contents of the named |
905 |
* Parses the given string as the hypothetical contents of the named |
888 |
* compilation unit and creates and returns a corresponding abstract syntax tree. |
906 |
* compilation unit and creates and returns a corresponding abstract syntax tree. |
Lines 891-897
Link Here
|
891 |
* Each node in the subtree carries source range(s) information relating back |
909 |
* Each node in the subtree carries source range(s) information relating back |
892 |
* to positions in the given source string (the given source string itself |
910 |
* to positions in the given source string (the given source string itself |
893 |
* is not remembered with the AST). |
911 |
* is not remembered with the AST). |
894 |
* The source range usually begins at the first character of the first token |
912 |
* The source range usually begins at the first character of the first token |
895 |
* corresponding to the node; leading whitespace and comments are <b>not</b> |
913 |
* corresponding to the node; leading whitespace and comments are <b>not</b> |
896 |
* included. The source range usually extends through the last character of |
914 |
* included. The source range usually extends through the last character of |
897 |
* the last token corresponding to the node; trailing whitespace and |
915 |
* the last token corresponding to the node; trailing whitespace and |
Lines 907-918
Link Here
|
907 |
* <p> |
925 |
* <p> |
908 |
* If the given project is not <code>null</code>, the various names |
926 |
* If the given project is not <code>null</code>, the various names |
909 |
* and types appearing in the compilation unit can be resolved to "bindings" |
927 |
* and types appearing in the compilation unit can be resolved to "bindings" |
910 |
* by calling the <code>resolveBinding</code> methods. These bindings |
928 |
* by calling the <code>resolveBinding</code> methods. These bindings |
911 |
* draw connections between the different parts of a program, and |
929 |
* draw connections between the different parts of a program, and |
912 |
* generally afford a more powerful vantage point for clients who wish to |
930 |
* generally afford a more powerful vantage point for clients who wish to |
913 |
* analyze a program's structure more deeply. These bindings come at a |
931 |
* analyze a program's structure more deeply. These bindings come at a |
914 |
* considerable cost in both time and space, however, and should not be |
932 |
* considerable cost in both time and space, however, and should not be |
915 |
* requested frivolously. The additional space is not reclaimed until the |
933 |
* requested frivolously. The additional space is not reclaimed until the |
916 |
* AST, all its nodes, and all its bindings become garbage. So it is very |
934 |
* AST, all its nodes, and all its bindings become garbage. So it is very |
917 |
* important to not retain any of these objects longer than absolutely |
935 |
* important to not retain any of these objects longer than absolutely |
918 |
* necessary. Bindings are resolved at the time the AST is created. Subsequent |
936 |
* necessary. Bindings are resolved at the time the AST is created. Subsequent |
Lines 920-934
Link Here
|
920 |
* <code>resolveBinding</code> methods in any way; these methods return the |
938 |
* <code>resolveBinding</code> methods in any way; these methods return the |
921 |
* same binding as before the AST was modified (including modifications |
939 |
* same binding as before the AST was modified (including modifications |
922 |
* that rearrange subtrees by reparenting nodes). |
940 |
* that rearrange subtrees by reparenting nodes). |
923 |
* If the given project is <code>null</code>, the analysis |
941 |
* If the given project is <code>null</code>, the analysis |
924 |
* does not go beyond parsing and building the tree, and all |
942 |
* does not go beyond parsing and building the tree, and all |
925 |
* <code>resolveBinding</code> methods return <code>null</code> from the |
943 |
* <code>resolveBinding</code> methods return <code>null</code> from the |
926 |
* outset. |
944 |
* outset. |
927 |
* </p> |
945 |
* </p> |
928 |
* <p> |
946 |
* <p> |
929 |
* The name of the compilation unit must be supplied for resolving bindings. |
947 |
* The name of the compilation unit must be supplied for resolving bindings. |
930 |
* This name should be suffixed by a dot ('.') followed by one of the |
948 |
* This name should be suffixed by a dot ('.') followed by one of the |
931 |
* {@link JavaCore#getJavaLikeExtensions() Java-like extensions} |
949 |
* {@link JavaCore#getJavaLikeExtensions() Java-like extensions} |
932 |
* and match the name of the main |
950 |
* and match the name of the main |
933 |
* (public) class or interface declared in the source. For example, if the source |
951 |
* (public) class or interface declared in the source. For example, if the source |
934 |
* declares a public class named "Foo", the name of the compilation can be |
952 |
* declares a public class named "Foo", the name of the compilation can be |
Lines 936-946
Link Here
|
936 |
* source string hide types by the same name available through the classpath |
954 |
* source string hide types by the same name available through the classpath |
937 |
* of the given project. |
955 |
* of the given project. |
938 |
* </p> |
956 |
* </p> |
939 |
* |
957 |
* |
940 |
* @param source the string to be parsed as a Java compilation unit |
958 |
* @param source the string to be parsed as a Java compilation unit |
941 |
* @param unitName the name of the compilation unit that would contain the source |
959 |
* @param unitName the name of the compilation unit that would contain the source |
942 |
* string, or <code>null</code> if <code>javaProject</code> is also <code>null</code> |
960 |
* string, or <code>null</code> if <code>javaProject</code> is also <code>null</code> |
943 |
* @param project the Java project used to resolve names, or |
961 |
* @param project the Java project used to resolve names, or |
944 |
* <code>null</code> if bindings are not resolved |
962 |
* <code>null</code> if bindings are not resolved |
945 |
* @return the compilation unit node |
963 |
* @return the compilation unit node |
946 |
* @see ASTNode#getFlags() |
964 |
* @see ASTNode#getFlags() |
Lines 966-981
Link Here
|
966 |
ASTNode result = astParser.createAST(null); |
984 |
ASTNode result = astParser.createAST(null); |
967 |
return (CompilationUnit) result; |
985 |
return (CompilationUnit) result; |
968 |
} |
986 |
} |
969 |
|
987 |
|
970 |
/** |
988 |
/** |
971 |
* Parses the given string as a Java compilation unit and creates and |
989 |
* Parses the given string as a Java compilation unit and creates and |
972 |
* returns a corresponding abstract syntax tree. |
990 |
* returns a corresponding abstract syntax tree. |
973 |
* <p> |
991 |
* <p> |
974 |
* The returned compilation unit node is the root node of a new AST. |
992 |
* The returned compilation unit node is the root node of a new AST. |
975 |
* Each node in the subtree carries source range(s) information relating back |
993 |
* Each node in the subtree carries source range(s) information relating back |
976 |
* to positions in the given source string (the given source string itself |
994 |
* to positions in the given source string (the given source string itself |
977 |
* is not remembered with the AST). |
995 |
* is not remembered with the AST). |
978 |
* The source range usually begins at the first character of the first token |
996 |
* The source range usually begins at the first character of the first token |
979 |
* corresponding to the node; leading whitespace and comments are <b>not</b> |
997 |
* corresponding to the node; leading whitespace and comments are <b>not</b> |
980 |
* included. The source range usually extends through the last character of |
998 |
* included. The source range usually extends through the last character of |
981 |
* the last token corresponding to the node; trailing whitespace and |
999 |
* the last token corresponding to the node; trailing whitespace and |
Lines 992-998
Link Here
|
992 |
* This method does not compute binding information; all <code>resolveBinding</code> |
1010 |
* This method does not compute binding information; all <code>resolveBinding</code> |
993 |
* methods applied to nodes of the resulting AST return <code>null</code>. |
1011 |
* methods applied to nodes of the resulting AST return <code>null</code>. |
994 |
* </p> |
1012 |
* </p> |
995 |
* |
1013 |
* |
996 |
* @param source the string to be parsed as a Java compilation unit |
1014 |
* @param source the string to be parsed as a Java compilation unit |
997 |
* @return the compilation unit node |
1015 |
* @return the compilation unit node |
998 |
* @see ASTNode#getFlags() |
1016 |
* @see ASTNode#getFlags() |
Lines 1014-1020
Link Here
|
1014 |
|
1032 |
|
1015 |
/** |
1033 |
/** |
1016 |
* Returns the binding resolver for this AST. |
1034 |
* Returns the binding resolver for this AST. |
1017 |
* |
1035 |
* |
1018 |
* @return the binding resolver for this AST |
1036 |
* @return the binding resolver for this AST |
1019 |
*/ |
1037 |
*/ |
1020 |
BindingResolver getBindingResolver() { |
1038 |
BindingResolver getBindingResolver() { |
Lines 1023-1029
Link Here
|
1023 |
|
1041 |
|
1024 |
/** |
1042 |
/** |
1025 |
* Returns the event handler for this AST. |
1043 |
* Returns the event handler for this AST. |
1026 |
* |
1044 |
* |
1027 |
* @return the event handler for this AST |
1045 |
* @return the event handler for this AST |
1028 |
* @since 3.0 |
1046 |
* @since 3.0 |
1029 |
*/ |
1047 |
*/ |
Lines 1033-1039
Link Here
|
1033 |
|
1051 |
|
1034 |
/** |
1052 |
/** |
1035 |
* Sets the event handler for this AST. |
1053 |
* Sets the event handler for this AST. |
1036 |
* |
1054 |
* |
1037 |
* @param eventHandler the event handler for this AST |
1055 |
* @param eventHandler the event handler for this AST |
1038 |
* @since 3.0 |
1056 |
* @since 3.0 |
1039 |
*/ |
1057 |
*/ |
Lines 1043-1079
Link Here
|
1043 |
} |
1061 |
} |
1044 |
this.eventHandler = eventHandler; |
1062 |
this.eventHandler = eventHandler; |
1045 |
} |
1063 |
} |
1046 |
|
1064 |
|
1047 |
/** |
1065 |
/** |
1048 |
* Returns default node flags of new nodes of this AST. |
1066 |
* Returns default node flags of new nodes of this AST. |
1049 |
* |
1067 |
* |
1050 |
* @return the default node flags of new nodes of this AST |
1068 |
* @return the default node flags of new nodes of this AST |
1051 |
* @since 3.0 |
1069 |
* @since 3.0 |
1052 |
*/ |
1070 |
*/ |
1053 |
int getDefaultNodeFlag() { |
1071 |
int getDefaultNodeFlag() { |
1054 |
return this.defaultNodeFlag; |
1072 |
return this.defaultNodeFlag; |
1055 |
} |
1073 |
} |
1056 |
|
1074 |
|
1057 |
/** |
1075 |
/** |
1058 |
* Sets default node flags of new nodes of this AST. |
1076 |
* Sets default node flags of new nodes of this AST. |
1059 |
* |
1077 |
* |
1060 |
* @param flag node flags of new nodes of this AST |
1078 |
* @param flag node flags of new nodes of this AST |
1061 |
* @since 3.0 |
1079 |
* @since 3.0 |
1062 |
*/ |
1080 |
*/ |
1063 |
void setDefaultNodeFlag(int flag) { |
1081 |
void setDefaultNodeFlag(int flag) { |
1064 |
this.defaultNodeFlag = flag; |
1082 |
this.defaultNodeFlag = flag; |
1065 |
} |
1083 |
} |
1066 |
|
1084 |
|
1067 |
/** |
1085 |
/** |
1068 |
* Set <code>originalModificationCount</code> to the current modification count |
1086 |
* Set <code>originalModificationCount</code> to the current modification count |
1069 |
* |
1087 |
* |
1070 |
* @since 3.0 |
1088 |
* @since 3.0 |
1071 |
*/ |
1089 |
*/ |
1072 |
void setOriginalModificationCount(long count) { |
1090 |
void setOriginalModificationCount(long count) { |
1073 |
this.originalModificationCount = count; |
1091 |
this.originalModificationCount = count; |
1074 |
} |
1092 |
} |
1075 |
|
1093 |
|
1076 |
/** |
1094 |
/** |
1077 |
* Returns the type binding for a "well known" type. |
1095 |
* Returns the type binding for a "well known" type. |
1078 |
* <p> |
1096 |
* <p> |
1079 |
* Note that bindings are generally unavailable unless requested when the |
1097 |
* Note that bindings are generally unavailable unless requested when the |
Lines 1112-1120
Link Here
|
1112 |
* <li><code>"java.io.Serializable"</code></li> |
1130 |
* <li><code>"java.io.Serializable"</code></li> |
1113 |
* </ul> |
1131 |
* </ul> |
1114 |
* </p> |
1132 |
* </p> |
1115 |
* |
1133 |
* |
1116 |
* @param name the name of a well known type |
1134 |
* @param name the name of a well known type |
1117 |
* @return the corresponding type binding, or <code>null</code> if the |
1135 |
* @return the corresponding type binding, or <code>null</code> if the |
1118 |
* named type is not considered well known or if no binding can be found |
1136 |
* named type is not considered well known or if no binding can be found |
1119 |
* for it |
1137 |
* for it |
1120 |
*/ |
1138 |
*/ |
Lines 1124-1133
Link Here
|
1124 |
} |
1142 |
} |
1125 |
return getBindingResolver().resolveWellKnownType(name); |
1143 |
return getBindingResolver().resolveWellKnownType(name); |
1126 |
} |
1144 |
} |
1127 |
|
1145 |
|
1128 |
/** |
1146 |
/** |
1129 |
* Sets the binding resolver for this AST. |
1147 |
* Sets the binding resolver for this AST. |
1130 |
* |
1148 |
* |
1131 |
* @param resolver the new binding resolver for this AST |
1149 |
* @param resolver the new binding resolver for this AST |
1132 |
*/ |
1150 |
*/ |
1133 |
void setBindingResolver(BindingResolver resolver) { |
1151 |
void setBindingResolver(BindingResolver resolver) { |
Lines 1174-1187
Link Here
|
1174 |
* @since 3.0 |
1192 |
* @since 3.0 |
1175 |
*/ |
1193 |
*/ |
1176 |
private final Object[] THIS_AST= new Object[] {this}; |
1194 |
private final Object[] THIS_AST= new Object[] {this}; |
1177 |
|
1195 |
|
1178 |
/** |
1196 |
/** |
1179 |
* Creates an unparented node of the given node class |
1197 |
* Creates an unparented node of the given node class |
1180 |
* (non-abstract subclass of {@link ASTNode}). |
1198 |
* (non-abstract subclass of {@link ASTNode}). |
1181 |
* |
1199 |
* |
1182 |
* @param nodeClass AST node class |
1200 |
* @param nodeClass AST node class |
1183 |
* @return a new unparented node owned by this AST |
1201 |
* @return a new unparented node owned by this AST |
1184 |
* @exception IllegalArgumentException if <code>nodeClass</code> is |
1202 |
* @exception IllegalArgumentException if <code>nodeClass</code> is |
1185 |
* <code>null</code> or is not a concrete node type class |
1203 |
* <code>null</code> or is not a concrete node type class |
1186 |
* @since 3.0 |
1204 |
* @since 3.0 |
1187 |
*/ |
1205 |
*/ |
Lines 1210-1216
Link Here
|
1210 |
// concrete AST node classes do not die in the constructor |
1228 |
// concrete AST node classes do not die in the constructor |
1211 |
// therefore nodeClass is not legit |
1229 |
// therefore nodeClass is not legit |
1212 |
throw new IllegalArgumentException(); |
1230 |
throw new IllegalArgumentException(); |
1213 |
} |
1231 |
} |
1214 |
} |
1232 |
} |
1215 |
|
1233 |
|
1216 |
/** |
1234 |
/** |
Lines 1219-1229
Link Here
|
1219 |
* <pre> |
1237 |
* <pre> |
1220 |
* createInstance(ASTNode.nodeClassForType(nodeType)) |
1238 |
* createInstance(ASTNode.nodeClassForType(nodeType)) |
1221 |
* </pre> |
1239 |
* </pre> |
1222 |
* |
1240 |
* |
1223 |
* @param nodeType AST node type, one of the node type |
1241 |
* @param nodeType AST node type, one of the node type |
1224 |
* constants declared on {@link ASTNode} |
1242 |
* constants declared on {@link ASTNode} |
1225 |
* @return a new unparented node owned by this AST |
1243 |
* @return a new unparented node owned by this AST |
1226 |
* @exception IllegalArgumentException if <code>nodeType</code> is |
1244 |
* @exception IllegalArgumentException if <code>nodeType</code> is |
1227 |
* not a legal AST node type |
1245 |
* not a legal AST node type |
1228 |
* @since 3.0 |
1246 |
* @since 3.0 |
1229 |
*/ |
1247 |
*/ |
Lines 1233-1244
Link Here
|
1233 |
return createInstance(nodeClass); |
1251 |
return createInstance(nodeClass); |
1234 |
} |
1252 |
} |
1235 |
|
1253 |
|
|
|
1254 |
/** |
1255 |
* Returns true if the ast tree was created with bindings, false otherwise |
1256 |
* |
1257 |
* @return true if the ast tree was created with bindings, false otherwise |
1258 |
*/ |
1259 |
public boolean hasResolvedBindings() { |
1260 |
return (this.bits & RESOLVED_BINDINGS) != 0; |
1261 |
} |
1262 |
|
1263 |
/** |
1264 |
* Returns true if the ast tree was created with statement recovery, false otherwise |
1265 |
* |
1266 |
* @return true if the ast tree was created with statement recovery, false otherwise |
1267 |
*/ |
1268 |
public boolean hasStatementRecovery() { |
1269 |
return (this.bits & STATEMENT_RECOVERY) != 0; |
1270 |
} |
1271 |
|
1236 |
//=============================== NAMES =========================== |
1272 |
//=============================== NAMES =========================== |
1237 |
/** |
1273 |
/** |
1238 |
* Creates and returns a new unparented simple name node for the given |
1274 |
* Creates and returns a new unparented simple name node for the given |
1239 |
* identifier. The identifier should be a legal Java identifier, but not |
1275 |
* identifier. The identifier should be a legal Java identifier, but not |
1240 |
* a keyword, boolean literal ("true", "false") or null literal ("null"). |
1276 |
* a keyword, boolean literal ("true", "false") or null literal ("null"). |
1241 |
* |
1277 |
* |
1242 |
* @param identifier the identifier |
1278 |
* @param identifier the identifier |
1243 |
* @return a new unparented simple name node |
1279 |
* @return a new unparented simple name node |
1244 |
* @exception IllegalArgumentException if the identifier is invalid |
1280 |
* @exception IllegalArgumentException if the identifier is invalid |
Lines 1253-1261
Link Here
|
1253 |
} |
1289 |
} |
1254 |
|
1290 |
|
1255 |
/** |
1291 |
/** |
1256 |
* Creates and returns a new unparented qualified name node for the given |
1292 |
* Creates and returns a new unparented qualified name node for the given |
1257 |
* qualifier and simple name child node. |
1293 |
* qualifier and simple name child node. |
1258 |
* |
1294 |
* |
1259 |
* @param qualifier the qualifier name node |
1295 |
* @param qualifier the qualifier name node |
1260 |
* @param name the simple name being qualified |
1296 |
* @param name the simple name being qualified |
1261 |
* @return a new unparented qualified name node |
1297 |
* @return a new unparented qualified name node |
Lines 1272-1287
Link Here
|
1272 |
result.setQualifier(qualifier); |
1308 |
result.setQualifier(qualifier); |
1273 |
result.setName(name); |
1309 |
result.setName(name); |
1274 |
return result; |
1310 |
return result; |
1275 |
|
1311 |
|
1276 |
} |
1312 |
} |
1277 |
|
1313 |
|
1278 |
/** |
1314 |
/** |
1279 |
* Creates and returns a new unparented name node for the given name |
1315 |
* Creates and returns a new unparented name node for the given name |
1280 |
* segments. Returns a simple name if there is only one name segment, and |
1316 |
* segments. Returns a simple name if there is only one name segment, and |
1281 |
* a qualified name if there are multiple name segments. Each of the name |
1317 |
* a qualified name if there are multiple name segments. Each of the name |
1282 |
* segments should be legal Java identifiers (this constraint may or may |
1318 |
* segments should be legal Java identifiers (this constraint may or may |
1283 |
* not be enforced), and there must be at least one name segment. |
1319 |
* not be enforced), and there must be at least one name segment. |
1284 |
* |
1320 |
* |
1285 |
* @param identifiers a list of 1 or more name segments, each of which |
1321 |
* @param identifiers a list of 1 or more name segments, each of which |
1286 |
* is a legal Java identifier |
1322 |
* is a legal Java identifier |
1287 |
* @return a new unparented name node |
1323 |
* @return a new unparented name node |
Lines 1304-1310
Link Here
|
1304 |
} |
1340 |
} |
1305 |
return result; |
1341 |
return result; |
1306 |
} |
1342 |
} |
1307 |
|
1343 |
|
1308 |
/* (omit javadoc for this method) |
1344 |
/* (omit javadoc for this method) |
1309 |
* This method is a copy of setName(String[]) that doesn't do any validation. |
1345 |
* This method is a copy of setName(String[]) that doesn't do any validation. |
1310 |
*/ |
1346 |
*/ |
Lines 1326-1340
Link Here
|
1326 |
|
1362 |
|
1327 |
/** |
1363 |
/** |
1328 |
* Creates and returns a new unparented name node for the given name. |
1364 |
* Creates and returns a new unparented name node for the given name. |
1329 |
* The name string must consist of 1 or more name segments separated |
1365 |
* The name string must consist of 1 or more name segments separated |
1330 |
* by single dots '.'. Returns a {@link QualifiedName} if the name has |
1366 |
* by single dots '.'. Returns a {@link QualifiedName} if the name has |
1331 |
* dots, and a {@link SimpleName} otherwise. Each of the name |
1367 |
* dots, and a {@link SimpleName} otherwise. Each of the name |
1332 |
* segments should be legal Java identifiers (this constraint may or may |
1368 |
* segments should be legal Java identifiers (this constraint may or may |
1333 |
* not be enforced), and there must be at least one name segment. |
1369 |
* not be enforced), and there must be at least one name segment. |
1334 |
* The string must not contains white space, '<', '>', |
1370 |
* The string must not contains white space, '<', '>', |
1335 |
* '[', ']', or other any other characters that are not |
1371 |
* '[', ']', or other any other characters that are not |
1336 |
* part of the Java identifiers or separating '.'s. |
1372 |
* part of the Java identifiers or separating '.'s. |
1337 |
* |
1373 |
* |
1338 |
* @param qualifiedName string consisting of 1 or more name segments, |
1374 |
* @param qualifiedName string consisting of 1 or more name segments, |
1339 |
* each of which is a legal Java identifier, separated by single dots '.' |
1375 |
* each of which is a legal Java identifier, separated by single dots '.' |
1340 |
* @return a new unparented name node |
1376 |
* @return a new unparented name node |
Lines 1390-1396
Link Here
|
1390 |
* This method can be used to convert a name (<code>Name</code>) into a |
1426 |
* This method can be used to convert a name (<code>Name</code>) into a |
1391 |
* type (<code>Type</code>) by wrapping it. |
1427 |
* type (<code>Type</code>) by wrapping it. |
1392 |
* </p> |
1428 |
* </p> |
1393 |
* |
1429 |
* |
1394 |
* @param typeName the name of the class or interface |
1430 |
* @param typeName the name of the class or interface |
1395 |
* @return a new unparented simple type node |
1431 |
* @return a new unparented simple type node |
1396 |
* @exception IllegalArgumentException if: |
1432 |
* @exception IllegalArgumentException if: |
Lines 1408-1414
Link Here
|
1408 |
/** |
1444 |
/** |
1409 |
* Creates and returns a new unparented array type node with the given |
1445 |
* Creates and returns a new unparented array type node with the given |
1410 |
* component type, which may be another array type. |
1446 |
* component type, which may be another array type. |
1411 |
* |
1447 |
* |
1412 |
* @param componentType the component type (possibly another array type) |
1448 |
* @param componentType the component type (possibly another array type) |
1413 |
* @return a new unparented array type node |
1449 |
* @return a new unparented array type node |
1414 |
* @exception IllegalArgumentException if: |
1450 |
* @exception IllegalArgumentException if: |
Lines 1426-1437
Link Here
|
1426 |
|
1462 |
|
1427 |
/** |
1463 |
/** |
1428 |
* Creates and returns a new unparented array type node with the given |
1464 |
* Creates and returns a new unparented array type node with the given |
1429 |
* element type and number of dimensions. |
1465 |
* element type and number of dimensions. |
1430 |
* <p> |
1466 |
* <p> |
1431 |
* Note that if the element type passed in is an array type, the |
1467 |
* Note that if the element type passed in is an array type, the |
1432 |
* element type of the result will not be the same as what was passed in. |
1468 |
* element type of the result will not be the same as what was passed in. |
1433 |
* </p> |
1469 |
* </p> |
1434 |
* |
1470 |
* |
1435 |
* @param elementType the element type (never an array type) |
1471 |
* @param elementType the element type (never an array type) |
1436 |
* @param dimensions the number of dimensions, a positive number |
1472 |
* @param dimensions the number of dimensions, a positive number |
1437 |
* @return a new unparented array type node |
1473 |
* @return a new unparented array type node |
Lines 1460-1473
Link Here
|
1460 |
result = newArrayType(result); |
1496 |
result = newArrayType(result); |
1461 |
} |
1497 |
} |
1462 |
return result; |
1498 |
return result; |
1463 |
|
1499 |
|
1464 |
} |
1500 |
} |
1465 |
|
1501 |
|
1466 |
/** |
1502 |
/** |
1467 |
* Creates and returns a new unparented primitive type node with the given |
1503 |
* Creates and returns a new unparented primitive type node with the given |
1468 |
* type code. |
1504 |
* type code. |
1469 |
* |
1505 |
* |
1470 |
* @param typeCode one of the primitive type code constants declared in |
1506 |
* @param typeCode one of the primitive type code constants declared in |
1471 |
* <code>PrimitiveType</code> |
1507 |
* <code>PrimitiveType</code> |
1472 |
* @return a new unparented primitive type node |
1508 |
* @return a new unparented primitive type node |
1473 |
* @exception IllegalArgumentException if the primitive type code is invalid |
1509 |
* @exception IllegalArgumentException if the primitive type code is invalid |
Lines 1481-1487
Link Here
|
1481 |
/** |
1517 |
/** |
1482 |
* Creates and returns a new unparented parameterized type node with the |
1518 |
* Creates and returns a new unparented parameterized type node with the |
1483 |
* given type and an empty list of type arguments. |
1519 |
* given type and an empty list of type arguments. |
1484 |
* |
1520 |
* |
1485 |
* @param type the type that is parameterized |
1521 |
* @param type the type that is parameterized |
1486 |
* @return a new unparented parameterized type node |
1522 |
* @return a new unparented parameterized type node |
1487 |
* @exception IllegalArgumentException if: |
1523 |
* @exception IllegalArgumentException if: |
Lines 1500-1508
Link Here
|
1500 |
} |
1536 |
} |
1501 |
|
1537 |
|
1502 |
/** |
1538 |
/** |
1503 |
* Creates and returns a new unparented qualified type node with |
1539 |
* Creates and returns a new unparented qualified type node with |
1504 |
* the given qualifier type and name. |
1540 |
* the given qualifier type and name. |
1505 |
* |
1541 |
* |
1506 |
* @param qualifier the qualifier type node |
1542 |
* @param qualifier the qualifier type node |
1507 |
* @param name the simple name being qualified |
1543 |
* @param name the simple name being qualified |
1508 |
* @return a new unparented qualified type node |
1544 |
* @return a new unparented qualified type node |
Lines 1521-1531
Link Here
|
1521 |
result.setName(name); |
1557 |
result.setName(name); |
1522 |
return result; |
1558 |
return result; |
1523 |
} |
1559 |
} |
1524 |
|
1560 |
|
1525 |
/** |
1561 |
/** |
1526 |
* Creates and returns a new unparented wildcard type node with no |
1562 |
* Creates and returns a new unparented wildcard type node with no |
1527 |
* type bound. |
1563 |
* type bound. |
1528 |
* |
1564 |
* |
1529 |
* @return a new unparented wildcard type node |
1565 |
* @return a new unparented wildcard type node |
1530 |
* @exception UnsupportedOperationException if this operation is used in |
1566 |
* @exception UnsupportedOperationException if this operation is used in |
1531 |
* a JLS2 AST |
1567 |
* a JLS2 AST |
Lines 1541-1581
Link Here
|
1541 |
* Creates an unparented compilation unit node owned by this AST. |
1577 |
* Creates an unparented compilation unit node owned by this AST. |
1542 |
* The compilation unit initially has no package declaration, no |
1578 |
* The compilation unit initially has no package declaration, no |
1543 |
* import declarations, and no type declarations. |
1579 |
* import declarations, and no type declarations. |
1544 |
* |
1580 |
* |
1545 |
* @return the new unparented compilation unit node |
1581 |
* @return the new unparented compilation unit node |
1546 |
*/ |
1582 |
*/ |
1547 |
public CompilationUnit newCompilationUnit() { |
1583 |
public CompilationUnit newCompilationUnit() { |
1548 |
return new CompilationUnit(this); |
1584 |
return new CompilationUnit(this); |
1549 |
} |
1585 |
} |
1550 |
|
1586 |
|
1551 |
/** |
1587 |
/** |
1552 |
* Creates an unparented package declaration node owned by this AST. |
1588 |
* Creates an unparented package declaration node owned by this AST. |
1553 |
* The package declaration initially declares a package with an |
1589 |
* The package declaration initially declares a package with an |
1554 |
* unspecified name. |
1590 |
* unspecified name. |
1555 |
* |
1591 |
* |
1556 |
* @return the new unparented package declaration node |
1592 |
* @return the new unparented package declaration node |
1557 |
*/ |
1593 |
*/ |
1558 |
public PackageDeclaration newPackageDeclaration() { |
1594 |
public PackageDeclaration newPackageDeclaration() { |
1559 |
PackageDeclaration result = new PackageDeclaration(this); |
1595 |
PackageDeclaration result = new PackageDeclaration(this); |
1560 |
return result; |
1596 |
return result; |
1561 |
} |
1597 |
} |
1562 |
|
1598 |
|
1563 |
/** |
1599 |
/** |
1564 |
* Creates an unparented import declaration node owned by this AST. |
1600 |
* Creates an unparented import declaration node owned by this AST. |
1565 |
* The import declaration initially contains a single-type import |
1601 |
* The import declaration initially contains a single-type import |
1566 |
* of a type with an unspecified name. |
1602 |
* of a type with an unspecified name. |
1567 |
* |
1603 |
* |
1568 |
* @return the new unparented import declaration node |
1604 |
* @return the new unparented import declaration node |
1569 |
*/ |
1605 |
*/ |
1570 |
public ImportDeclaration newImportDeclaration() { |
1606 |
public ImportDeclaration newImportDeclaration() { |
1571 |
ImportDeclaration result = new ImportDeclaration(this); |
1607 |
ImportDeclaration result = new ImportDeclaration(this); |
1572 |
return result; |
1608 |
return result; |
1573 |
} |
1609 |
} |
1574 |
|
1610 |
|
1575 |
/** |
1611 |
/** |
1576 |
* Creates an unparented class declaration node owned by this AST. |
1612 |
* Creates an unparented class declaration node owned by this AST. |
1577 |
* The name of the class is an unspecified, but legal, name; |
1613 |
* The name of the class is an unspecified, but legal, name; |
1578 |
* no modifiers; no doc comment; no superclass or superinterfaces; |
1614 |
* no modifiers; no doc comment; no superclass or superinterfaces; |
1579 |
* and an empty class body. |
1615 |
* and an empty class body. |
1580 |
* <p> |
1616 |
* <p> |
1581 |
* To create an interface, use this method and then call |
1617 |
* To create an interface, use this method and then call |
Lines 1585-1591
Link Here
|
1585 |
* To create an enum declaration, use this method and then call |
1621 |
* To create an enum declaration, use this method and then call |
1586 |
* <code>TypeDeclaration.setEnumeration(true)</code>. |
1622 |
* <code>TypeDeclaration.setEnumeration(true)</code>. |
1587 |
* </p> |
1623 |
* </p> |
1588 |
* |
1624 |
* |
1589 |
* @return a new unparented type declaration node |
1625 |
* @return a new unparented type declaration node |
1590 |
*/ |
1626 |
*/ |
1591 |
public TypeDeclaration newTypeDeclaration() { |
1627 |
public TypeDeclaration newTypeDeclaration() { |
Lines 1593-1602
Link Here
|
1593 |
result.setInterface(false); |
1629 |
result.setInterface(false); |
1594 |
return result; |
1630 |
return result; |
1595 |
} |
1631 |
} |
1596 |
|
1632 |
|
1597 |
/** |
1633 |
/** |
1598 |
* Creates an unparented method declaration node owned by this AST. |
1634 |
* Creates an unparented method declaration node owned by this AST. |
1599 |
* By default, the declaration is for a method of an unspecified, but |
1635 |
* By default, the declaration is for a method of an unspecified, but |
1600 |
* legal, name; no modifiers; no doc comment; no parameters; return |
1636 |
* legal, name; no modifiers; no doc comment; no parameters; return |
1601 |
* type void; no extra array dimensions; no thrown exceptions; and no |
1637 |
* type void; no extra array dimensions; no thrown exceptions; and no |
1602 |
* body (as opposed to an empty body). |
1638 |
* body (as opposed to an empty body). |
Lines 1605-1611
Link Here
|
1605 |
* <code>MethodDeclaration.setConstructor(true)</code> and |
1641 |
* <code>MethodDeclaration.setConstructor(true)</code> and |
1606 |
* <code>MethodDeclaration.setName(className)</code>. |
1642 |
* <code>MethodDeclaration.setName(className)</code>. |
1607 |
* </p> |
1643 |
* </p> |
1608 |
* |
1644 |
* |
1609 |
* @return a new unparented method declaration node |
1645 |
* @return a new unparented method declaration node |
1610 |
*/ |
1646 |
*/ |
1611 |
public MethodDeclaration newMethodDeclaration() { |
1647 |
public MethodDeclaration newMethodDeclaration() { |
Lines 1613-1649
Link Here
|
1613 |
result.setConstructor(false); |
1649 |
result.setConstructor(false); |
1614 |
return result; |
1650 |
return result; |
1615 |
} |
1651 |
} |
1616 |
|
1652 |
|
1617 |
/** |
1653 |
/** |
1618 |
* Creates an unparented single variable declaration node owned by this AST. |
1654 |
* Creates an unparented single variable declaration node owned by this AST. |
1619 |
* By default, the declaration is for a variable with an unspecified, but |
1655 |
* By default, the declaration is for a variable with an unspecified, but |
1620 |
* legal, name and type; no modifiers; no array dimensions after the |
1656 |
* legal, name and type; no modifiers; no array dimensions after the |
1621 |
* variable; no initializer; not variable arity. |
1657 |
* variable; no initializer; not variable arity. |
1622 |
* |
1658 |
* |
1623 |
* @return a new unparented single variable declaration node |
1659 |
* @return a new unparented single variable declaration node |
1624 |
*/ |
1660 |
*/ |
1625 |
public SingleVariableDeclaration newSingleVariableDeclaration() { |
1661 |
public SingleVariableDeclaration newSingleVariableDeclaration() { |
1626 |
SingleVariableDeclaration result = new SingleVariableDeclaration(this); |
1662 |
SingleVariableDeclaration result = new SingleVariableDeclaration(this); |
1627 |
return result; |
1663 |
return result; |
1628 |
} |
1664 |
} |
1629 |
|
1665 |
|
1630 |
/** |
1666 |
/** |
1631 |
* Creates an unparented variable declaration fragment node owned by this |
1667 |
* Creates an unparented variable declaration fragment node owned by this |
1632 |
* AST. By default, the fragment is for a variable with an unspecified, but |
1668 |
* AST. By default, the fragment is for a variable with an unspecified, but |
1633 |
* legal, name; no extra array dimensions; and no initializer. |
1669 |
* legal, name; no extra array dimensions; and no initializer. |
1634 |
* |
1670 |
* |
1635 |
* @return a new unparented variable declaration fragment node |
1671 |
* @return a new unparented variable declaration fragment node |
1636 |
*/ |
1672 |
*/ |
1637 |
public VariableDeclarationFragment newVariableDeclarationFragment() { |
1673 |
public VariableDeclarationFragment newVariableDeclarationFragment() { |
1638 |
VariableDeclarationFragment result = new VariableDeclarationFragment(this); |
1674 |
VariableDeclarationFragment result = new VariableDeclarationFragment(this); |
1639 |
return result; |
1675 |
return result; |
1640 |
} |
1676 |
} |
1641 |
|
1677 |
|
1642 |
/** |
1678 |
/** |
1643 |
* Creates an unparented initializer node owned by this AST, with an |
1679 |
* Creates an unparented initializer node owned by this AST, with an |
1644 |
* empty block. By default, the initializer has no modifiers and |
1680 |
* empty block. By default, the initializer has no modifiers and |
1645 |
* an empty block. |
1681 |
* an empty block. |
1646 |
* |
1682 |
* |
1647 |
* @return a new unparented initializer node |
1683 |
* @return a new unparented initializer node |
1648 |
*/ |
1684 |
*/ |
1649 |
public Initializer newInitializer() { |
1685 |
public Initializer newInitializer() { |
Lines 1653-1662
Link Here
|
1653 |
|
1689 |
|
1654 |
/** |
1690 |
/** |
1655 |
* Creates an unparented enum constant declaration node owned by this AST. |
1691 |
* Creates an unparented enum constant declaration node owned by this AST. |
1656 |
* The name of the constant is an unspecified, but legal, name; |
1692 |
* The name of the constant is an unspecified, but legal, name; |
1657 |
* no doc comment; no modifiers or annotations; no arguments; |
1693 |
* no doc comment; no modifiers or annotations; no arguments; |
1658 |
* and does not declare an anonymous class. |
1694 |
* and does not declare an anonymous class. |
1659 |
* |
1695 |
* |
1660 |
* @return a new unparented enum constant declaration node |
1696 |
* @return a new unparented enum constant declaration node |
1661 |
* @exception UnsupportedOperationException if this operation is used in |
1697 |
* @exception UnsupportedOperationException if this operation is used in |
1662 |
* a JLS2 AST |
1698 |
* a JLS2 AST |
Lines 1666-1679
Link Here
|
1666 |
EnumConstantDeclaration result = new EnumConstantDeclaration(this); |
1702 |
EnumConstantDeclaration result = new EnumConstantDeclaration(this); |
1667 |
return result; |
1703 |
return result; |
1668 |
} |
1704 |
} |
1669 |
|
1705 |
|
1670 |
/** |
1706 |
/** |
1671 |
* Creates an unparented enum declaration node owned by this AST. |
1707 |
* Creates an unparented enum declaration node owned by this AST. |
1672 |
* The name of the enum is an unspecified, but legal, name; |
1708 |
* The name of the enum is an unspecified, but legal, name; |
1673 |
* no doc comment; no modifiers or annotations; |
1709 |
* no doc comment; no modifiers or annotations; |
1674 |
* no superinterfaces; and empty lists of enum constants |
1710 |
* no superinterfaces; and empty lists of enum constants |
1675 |
* and body declarations. |
1711 |
* and body declarations. |
1676 |
* |
1712 |
* |
1677 |
* @return a new unparented enum declaration node |
1713 |
* @return a new unparented enum declaration node |
1678 |
* @exception UnsupportedOperationException if this operation is used in |
1714 |
* @exception UnsupportedOperationException if this operation is used in |
1679 |
* a JLS2 AST |
1715 |
* a JLS2 AST |
Lines 1683-1693
Link Here
|
1683 |
EnumDeclaration result = new EnumDeclaration(this); |
1719 |
EnumDeclaration result = new EnumDeclaration(this); |
1684 |
return result; |
1720 |
return result; |
1685 |
} |
1721 |
} |
1686 |
|
1722 |
|
1687 |
/** |
1723 |
/** |
1688 |
* Creates and returns a new unparented type parameter type node with an |
1724 |
* Creates and returns a new unparented type parameter type node with an |
1689 |
* unspecified type variable name and an empty list of type bounds. |
1725 |
* unspecified type variable name and an empty list of type bounds. |
1690 |
* |
1726 |
* |
1691 |
* @return a new unparented type parameter node |
1727 |
* @return a new unparented type parameter node |
1692 |
* @exception UnsupportedOperationException if this operation is used in |
1728 |
* @exception UnsupportedOperationException if this operation is used in |
1693 |
* a JLS2 AST |
1729 |
* a JLS2 AST |
Lines 1700-1708
Link Here
|
1700 |
|
1736 |
|
1701 |
/** |
1737 |
/** |
1702 |
* Creates and returns a new unparented annotation type declaration |
1738 |
* Creates and returns a new unparented annotation type declaration |
1703 |
* node for an unspecified, but legal, name; no modifiers; no javadoc; |
1739 |
* node for an unspecified, but legal, name; no modifiers; no javadoc; |
1704 |
* and an empty list of member declarations. |
1740 |
* and an empty list of member declarations. |
1705 |
* |
1741 |
* |
1706 |
* @return a new unparented annotation type declaration node |
1742 |
* @return a new unparented annotation type declaration node |
1707 |
* @exception UnsupportedOperationException if this operation is used in |
1743 |
* @exception UnsupportedOperationException if this operation is used in |
1708 |
* a JLS2 AST |
1744 |
* a JLS2 AST |
Lines 1712-1724
Link Here
|
1712 |
AnnotationTypeDeclaration result = new AnnotationTypeDeclaration(this); |
1748 |
AnnotationTypeDeclaration result = new AnnotationTypeDeclaration(this); |
1713 |
return result; |
1749 |
return result; |
1714 |
} |
1750 |
} |
1715 |
|
1751 |
|
1716 |
/** |
1752 |
/** |
1717 |
* Creates and returns a new unparented annotation type |
1753 |
* Creates and returns a new unparented annotation type |
1718 |
* member declaration node for an unspecified, but legal, |
1754 |
* member declaration node for an unspecified, but legal, |
1719 |
* member name and type; no modifiers; no javadoc; |
1755 |
* member name and type; no modifiers; no javadoc; |
1720 |
* and no default value. |
1756 |
* and no default value. |
1721 |
* |
1757 |
* |
1722 |
* @return a new unparented annotation type member declaration node |
1758 |
* @return a new unparented annotation type member declaration node |
1723 |
* @exception UnsupportedOperationException if this operation is used in |
1759 |
* @exception UnsupportedOperationException if this operation is used in |
1724 |
* a JLS2 AST |
1760 |
* a JLS2 AST |
Lines 1728-1738
Link Here
|
1728 |
AnnotationTypeMemberDeclaration result = new AnnotationTypeMemberDeclaration(this); |
1764 |
AnnotationTypeMemberDeclaration result = new AnnotationTypeMemberDeclaration(this); |
1729 |
return result; |
1765 |
return result; |
1730 |
} |
1766 |
} |
1731 |
|
1767 |
|
1732 |
/** |
1768 |
/** |
1733 |
* Creates and returns a new unparented modifier node for the given |
1769 |
* Creates and returns a new unparented modifier node for the given |
1734 |
* modifier. |
1770 |
* modifier. |
1735 |
* |
1771 |
* |
1736 |
* @param keyword one of the modifier keyword constants |
1772 |
* @param keyword one of the modifier keyword constants |
1737 |
* @return a new unparented modifier node |
1773 |
* @return a new unparented modifier node |
1738 |
* @exception IllegalArgumentException if the primitive type code is invalid |
1774 |
* @exception IllegalArgumentException if the primitive type code is invalid |
Lines 1747-1759
Link Here
|
1747 |
} |
1783 |
} |
1748 |
|
1784 |
|
1749 |
/** |
1785 |
/** |
1750 |
* Creates and returns a list of new unparented modifier nodes |
1786 |
* Creates and returns a list of new unparented modifier nodes |
1751 |
* for the given modifier flags. When multiple modifiers are |
1787 |
* for the given modifier flags. When multiple modifiers are |
1752 |
* requested the modifiers nodes will appear in the following order: |
1788 |
* requested the modifiers nodes will appear in the following order: |
1753 |
* public, protected, private, abstract, static, final, synchronized, |
1789 |
* public, protected, private, abstract, static, final, synchronized, |
1754 |
* native, strictfp, transient, volatile. This order is consistent |
1790 |
* native, strictfp, transient, volatile. This order is consistent |
1755 |
* with the recommendations in JLS2 8.1.1, 8.3.1, and 8.4.3. |
1791 |
* with the recommendations in JLS2 8.1.1, 8.3.1, and 8.4.3. |
1756 |
* |
1792 |
* |
1757 |
* @param flags bitwise or of modifier flags declared on {@link Modifier} |
1793 |
* @param flags bitwise or of modifier flags declared on {@link Modifier} |
1758 |
* @return a possibly empty list of new unparented modifier nodes |
1794 |
* @return a possibly empty list of new unparented modifier nodes |
1759 |
* (element type <code>Modifier</code>) |
1795 |
* (element type <code>Modifier</code>) |
Lines 1809-1819
Link Here
|
1809 |
* <p> |
1845 |
* <p> |
1810 |
* Note that this node type is used to recording the source |
1846 |
* Note that this node type is used to recording the source |
1811 |
* range where a comment was found in the source string. |
1847 |
* range where a comment was found in the source string. |
1812 |
* These comment nodes are normally found (only) in |
1848 |
* These comment nodes are normally found (only) in |
1813 |
* {@linkplain CompilationUnit#getCommentList() |
1849 |
* {@linkplain CompilationUnit#getCommentList() |
1814 |
* the comment table} for parsed compilation units. |
1850 |
* the comment table} for parsed compilation units. |
1815 |
* </p> |
1851 |
* </p> |
1816 |
* |
1852 |
* |
1817 |
* @return a new unparented block comment node |
1853 |
* @return a new unparented block comment node |
1818 |
* @since 3.0 |
1854 |
* @since 3.0 |
1819 |
*/ |
1855 |
*/ |
Lines 1821-1837
Link Here
|
1821 |
BlockComment result = new BlockComment(this); |
1857 |
BlockComment result = new BlockComment(this); |
1822 |
return result; |
1858 |
return result; |
1823 |
} |
1859 |
} |
1824 |
|
1860 |
|
1825 |
/** |
1861 |
/** |
1826 |
* Creates and returns a new line comment placeholder node. |
1862 |
* Creates and returns a new line comment placeholder node. |
1827 |
* <p> |
1863 |
* <p> |
1828 |
* Note that this node type is used to recording the source |
1864 |
* Note that this node type is used to recording the source |
1829 |
* range where a comment was found in the source string. |
1865 |
* range where a comment was found in the source string. |
1830 |
* These comment nodes are normally found (only) in |
1866 |
* These comment nodes are normally found (only) in |
1831 |
* {@linkplain CompilationUnit#getCommentList() |
1867 |
* {@linkplain CompilationUnit#getCommentList() |
1832 |
* the comment table} for parsed compilation units. |
1868 |
* the comment table} for parsed compilation units. |
1833 |
* </p> |
1869 |
* </p> |
1834 |
* |
1870 |
* |
1835 |
* @return a new unparented line comment node |
1871 |
* @return a new unparented line comment node |
1836 |
* @since 3.0 |
1872 |
* @since 3.0 |
1837 |
*/ |
1873 |
*/ |
Lines 1839-1858
Link Here
|
1839 |
LineComment result = new LineComment(this); |
1875 |
LineComment result = new LineComment(this); |
1840 |
return result; |
1876 |
return result; |
1841 |
} |
1877 |
} |
1842 |
|
1878 |
|
1843 |
/** |
1879 |
/** |
1844 |
* Creates and returns a new doc comment node. |
1880 |
* Creates and returns a new doc comment node. |
1845 |
* Initially the new node has an empty list of tag elements |
1881 |
* Initially the new node has an empty list of tag elements |
1846 |
* (and, for backwards compatability, an unspecified, but legal, |
1882 |
* (and, for backwards compatability, an unspecified, but legal, |
1847 |
* doc comment string) |
1883 |
* doc comment string) |
1848 |
* |
1884 |
* |
1849 |
* @return a new unparented doc comment node |
1885 |
* @return a new unparented doc comment node |
1850 |
*/ |
1886 |
*/ |
1851 |
public Javadoc newJavadoc() { |
1887 |
public Javadoc newJavadoc() { |
1852 |
Javadoc result = new Javadoc(this); |
1888 |
Javadoc result = new Javadoc(this); |
1853 |
return result; |
1889 |
return result; |
1854 |
} |
1890 |
} |
1855 |
|
1891 |
|
1856 |
/** |
1892 |
/** |
1857 |
* Creates and returns a new tag element node. |
1893 |
* Creates and returns a new tag element node. |
1858 |
* Initially the new node has no tag name and an empty list of fragments. |
1894 |
* Initially the new node has no tag name and an empty list of fragments. |
Lines 1860-1866
Link Here
|
1860 |
* Note that this node type is used only inside doc comments |
1896 |
* Note that this node type is used only inside doc comments |
1861 |
* ({@link Javadoc}). |
1897 |
* ({@link Javadoc}). |
1862 |
* </p> |
1898 |
* </p> |
1863 |
* |
1899 |
* |
1864 |
* @return a new unparented tag element node |
1900 |
* @return a new unparented tag element node |
1865 |
* @since 3.0 |
1901 |
* @since 3.0 |
1866 |
*/ |
1902 |
*/ |
Lines 1868-1874
Link Here
|
1868 |
TagElement result = new TagElement(this); |
1904 |
TagElement result = new TagElement(this); |
1869 |
return result; |
1905 |
return result; |
1870 |
} |
1906 |
} |
1871 |
|
1907 |
|
1872 |
/** |
1908 |
/** |
1873 |
* Creates and returns a new text element node. |
1909 |
* Creates and returns a new text element node. |
1874 |
* Initially the new node has an empty text string. |
1910 |
* Initially the new node has an empty text string. |
Lines 1876-1882
Link Here
|
1876 |
* Note that this node type is used only inside doc comments |
1912 |
* Note that this node type is used only inside doc comments |
1877 |
* ({@link Javadoc Javadoc}). |
1913 |
* ({@link Javadoc Javadoc}). |
1878 |
* </p> |
1914 |
* </p> |
1879 |
* |
1915 |
* |
1880 |
* @return a new unparented text element node |
1916 |
* @return a new unparented text element node |
1881 |
* @since 3.0 |
1917 |
* @since 3.0 |
1882 |
*/ |
1918 |
*/ |
Lines 1884-1899
Link Here
|
1884 |
TextElement result = new TextElement(this); |
1920 |
TextElement result = new TextElement(this); |
1885 |
return result; |
1921 |
return result; |
1886 |
} |
1922 |
} |
1887 |
|
1923 |
|
1888 |
/** |
1924 |
/** |
1889 |
* Creates and returns a new member reference node. |
1925 |
* Creates and returns a new member reference node. |
1890 |
* Initially the new node has no qualifier name and |
1926 |
* Initially the new node has no qualifier name and |
1891 |
* an unspecified, but legal, member name. |
1927 |
* an unspecified, but legal, member name. |
1892 |
* <p> |
1928 |
* <p> |
1893 |
* Note that this node type is used only inside doc comments |
1929 |
* Note that this node type is used only inside doc comments |
1894 |
* ({@link Javadoc}). |
1930 |
* ({@link Javadoc}). |
1895 |
* </p> |
1931 |
* </p> |
1896 |
* |
1932 |
* |
1897 |
* @return a new unparented member reference node |
1933 |
* @return a new unparented member reference node |
1898 |
* @since 3.0 |
1934 |
* @since 3.0 |
1899 |
*/ |
1935 |
*/ |
Lines 1901-1917
Link Here
|
1901 |
MemberRef result = new MemberRef(this); |
1937 |
MemberRef result = new MemberRef(this); |
1902 |
return result; |
1938 |
return result; |
1903 |
} |
1939 |
} |
1904 |
|
1940 |
|
1905 |
/** |
1941 |
/** |
1906 |
* Creates and returns a new method reference node. |
1942 |
* Creates and returns a new method reference node. |
1907 |
* Initially the new node has no qualifier name, |
1943 |
* Initially the new node has no qualifier name, |
1908 |
* an unspecified, but legal, method name, and an |
1944 |
* an unspecified, but legal, method name, and an |
1909 |
* empty parameter list. |
1945 |
* empty parameter list. |
1910 |
* <p> |
1946 |
* <p> |
1911 |
* Note that this node type is used only inside doc comments |
1947 |
* Note that this node type is used only inside doc comments |
1912 |
* ({@link Javadoc Javadoc}). |
1948 |
* ({@link Javadoc Javadoc}). |
1913 |
* </p> |
1949 |
* </p> |
1914 |
* |
1950 |
* |
1915 |
* @return a new unparented method reference node |
1951 |
* @return a new unparented method reference node |
1916 |
* @since 3.0 |
1952 |
* @since 3.0 |
1917 |
*/ |
1953 |
*/ |
Lines 1919-1934
Link Here
|
1919 |
MethodRef result = new MethodRef(this); |
1955 |
MethodRef result = new MethodRef(this); |
1920 |
return result; |
1956 |
return result; |
1921 |
} |
1957 |
} |
1922 |
|
1958 |
|
1923 |
/** |
1959 |
/** |
1924 |
* Creates and returns a new method reference node. |
1960 |
* Creates and returns a new method reference node. |
1925 |
* Initially the new node has an unspecified, but legal, |
1961 |
* Initially the new node has an unspecified, but legal, |
1926 |
* type, not variable arity, and no parameter name. |
1962 |
* type, not variable arity, and no parameter name. |
1927 |
* <p> |
1963 |
* <p> |
1928 |
* Note that this node type is used only inside doc comments |
1964 |
* Note that this node type is used only inside doc comments |
1929 |
* ({@link Javadoc}). |
1965 |
* ({@link Javadoc}). |
1930 |
* </p> |
1966 |
* </p> |
1931 |
* |
1967 |
* |
1932 |
* @return a new unparented method reference parameter node |
1968 |
* @return a new unparented method reference parameter node |
1933 |
* @since 3.0 |
1969 |
* @since 3.0 |
1934 |
*/ |
1970 |
*/ |
Lines 1936-1946
Link Here
|
1936 |
MethodRefParameter result = new MethodRefParameter(this); |
1972 |
MethodRefParameter result = new MethodRefParameter(this); |
1937 |
return result; |
1973 |
return result; |
1938 |
} |
1974 |
} |
1939 |
|
1975 |
|
1940 |
//=============================== STATEMENTS =========================== |
1976 |
//=============================== STATEMENTS =========================== |
1941 |
/** |
1977 |
/** |
1942 |
* Creates a new unparented local variable declaration statement node |
1978 |
* Creates a new unparented local variable declaration statement node |
1943 |
* owned by this AST, for the given variable declaration fragment. |
1979 |
* owned by this AST, for the given variable declaration fragment. |
1944 |
* By default, there are no modifiers and the base type is unspecified |
1980 |
* By default, there are no modifiers and the base type is unspecified |
1945 |
* (but legal). |
1981 |
* (but legal). |
1946 |
* <p> |
1982 |
* <p> |
Lines 1949-1955
Link Here
|
1949 |
* (<code>Statement</code>) by wrapping it. Additional variable |
1985 |
* (<code>Statement</code>) by wrapping it. Additional variable |
1950 |
* declaration fragments can be added afterwards. |
1986 |
* declaration fragments can be added afterwards. |
1951 |
* </p> |
1987 |
* </p> |
1952 |
* |
1988 |
* |
1953 |
* @param fragment the variable declaration fragment |
1989 |
* @param fragment the variable declaration fragment |
1954 |
* @return a new unparented variable declaration statement node |
1990 |
* @return a new unparented variable declaration statement node |
1955 |
* @exception IllegalArgumentException if: |
1991 |
* @exception IllegalArgumentException if: |
Lines 1970-1985
Link Here
|
1970 |
result.fragments().add(fragment); |
2006 |
result.fragments().add(fragment); |
1971 |
return result; |
2007 |
return result; |
1972 |
} |
2008 |
} |
1973 |
|
2009 |
|
1974 |
/** |
2010 |
/** |
1975 |
* Creates a new unparented local type declaration statement node |
2011 |
* Creates a new unparented local type declaration statement node |
1976 |
* owned by this AST, for the given type declaration. |
2012 |
* owned by this AST, for the given type declaration. |
1977 |
* <p> |
2013 |
* <p> |
1978 |
* This method can be used to convert a type declaration |
2014 |
* This method can be used to convert a type declaration |
1979 |
* (<code>TypeDeclaration</code>) into a statement |
2015 |
* (<code>TypeDeclaration</code>) into a statement |
1980 |
* (<code>Statement</code>) by wrapping it. |
2016 |
* (<code>Statement</code>) by wrapping it. |
1981 |
* </p> |
2017 |
* </p> |
1982 |
* |
2018 |
* |
1983 |
* @param decl the type declaration |
2019 |
* @param decl the type declaration |
1984 |
* @return a new unparented local type declaration statement node |
2020 |
* @return a new unparented local type declaration statement node |
1985 |
* @exception IllegalArgumentException if: |
2021 |
* @exception IllegalArgumentException if: |
Lines 1989-2010
Link Here
|
1989 |
* <li>a cycle in would be created</li> |
2025 |
* <li>a cycle in would be created</li> |
1990 |
* </ul> |
2026 |
* </ul> |
1991 |
*/ |
2027 |
*/ |
1992 |
public TypeDeclarationStatement |
2028 |
public TypeDeclarationStatement |
1993 |
newTypeDeclarationStatement(TypeDeclaration decl) { |
2029 |
newTypeDeclarationStatement(TypeDeclaration decl) { |
1994 |
TypeDeclarationStatement result = new TypeDeclarationStatement(this); |
2030 |
TypeDeclarationStatement result = new TypeDeclarationStatement(this); |
1995 |
result.setDeclaration(decl); |
2031 |
result.setDeclaration(decl); |
1996 |
return result; |
2032 |
return result; |
1997 |
} |
2033 |
} |
1998 |
|
2034 |
|
1999 |
/** |
2035 |
/** |
2000 |
* Creates a new unparented local type declaration statement node |
2036 |
* Creates a new unparented local type declaration statement node |
2001 |
* owned by this AST, for the given type declaration. |
2037 |
* owned by this AST, for the given type declaration. |
2002 |
* <p> |
2038 |
* <p> |
2003 |
* This method can be used to convert any kind of type declaration |
2039 |
* This method can be used to convert any kind of type declaration |
2004 |
* (<code>AbstractTypeDeclaration</code>) into a statement |
2040 |
* (<code>AbstractTypeDeclaration</code>) into a statement |
2005 |
* (<code>Statement</code>) by wrapping it. |
2041 |
* (<code>Statement</code>) by wrapping it. |
2006 |
* </p> |
2042 |
* </p> |
2007 |
* |
2043 |
* |
2008 |
* @param decl the type declaration |
2044 |
* @param decl the type declaration |
2009 |
* @return a new unparented local type declaration statement node |
2045 |
* @return a new unparented local type declaration statement node |
2010 |
* @exception IllegalArgumentException if: |
2046 |
* @exception IllegalArgumentException if: |
Lines 2015-2021
Link Here
|
2015 |
* </ul> |
2051 |
* </ul> |
2016 |
* @since 3.0 |
2052 |
* @since 3.0 |
2017 |
*/ |
2053 |
*/ |
2018 |
public TypeDeclarationStatement |
2054 |
public TypeDeclarationStatement |
2019 |
newTypeDeclarationStatement(AbstractTypeDeclaration decl) { |
2055 |
newTypeDeclarationStatement(AbstractTypeDeclaration decl) { |
2020 |
TypeDeclarationStatement result = new TypeDeclarationStatement(this); |
2056 |
TypeDeclarationStatement result = new TypeDeclarationStatement(this); |
2021 |
if (this.apiLevel == AST.JLS2) { |
2057 |
if (this.apiLevel == AST.JLS2) { |
Lines 2026-2073
Link Here
|
2026 |
} |
2062 |
} |
2027 |
return result; |
2063 |
return result; |
2028 |
} |
2064 |
} |
2029 |
|
2065 |
|
2030 |
/** |
2066 |
/** |
2031 |
* Creates an unparented block node owned by this AST, for an empty list |
2067 |
* Creates an unparented block node owned by this AST, for an empty list |
2032 |
* of statements. |
2068 |
* of statements. |
2033 |
* |
2069 |
* |
2034 |
* @return a new unparented, empty block node |
2070 |
* @return a new unparented, empty block node |
2035 |
*/ |
2071 |
*/ |
2036 |
public Block newBlock() { |
2072 |
public Block newBlock() { |
2037 |
return new Block(this); |
2073 |
return new Block(this); |
2038 |
} |
2074 |
} |
2039 |
|
2075 |
|
2040 |
/** |
2076 |
/** |
2041 |
* Creates an unparented continue statement node owned by this AST. |
2077 |
* Creates an unparented continue statement node owned by this AST. |
2042 |
* The continue statement has no label. |
2078 |
* The continue statement has no label. |
2043 |
* |
2079 |
* |
2044 |
* @return a new unparented continue statement node |
2080 |
* @return a new unparented continue statement node |
2045 |
*/ |
2081 |
*/ |
2046 |
public ContinueStatement newContinueStatement() { |
2082 |
public ContinueStatement newContinueStatement() { |
2047 |
return new ContinueStatement(this); |
2083 |
return new ContinueStatement(this); |
2048 |
} |
2084 |
} |
2049 |
|
2085 |
|
2050 |
/** |
2086 |
/** |
2051 |
* Creates an unparented break statement node owned by this AST. |
2087 |
* Creates an unparented break statement node owned by this AST. |
2052 |
* The break statement has no label. |
2088 |
* The break statement has no label. |
2053 |
* |
2089 |
* |
2054 |
* @return a new unparented break statement node |
2090 |
* @return a new unparented break statement node |
2055 |
*/ |
2091 |
*/ |
2056 |
public BreakStatement newBreakStatement() { |
2092 |
public BreakStatement newBreakStatement() { |
2057 |
return new BreakStatement(this); |
2093 |
return new BreakStatement(this); |
2058 |
} |
2094 |
} |
2059 |
|
2095 |
|
2060 |
/** |
2096 |
/** |
2061 |
* Creates a new unparented expression statement node owned by this AST, |
2097 |
* Creates a new unparented expression statement node owned by this AST, |
2062 |
* for the given expression. |
2098 |
* for the given expression. |
2063 |
* <p> |
2099 |
* <p> |
2064 |
* This method can be used to convert an expression |
2100 |
* This method can be used to convert an expression |
2065 |
* (<code>Expression</code>) into a statement (<code>Type</code>) |
2101 |
* (<code>Expression</code>) into a statement (<code>Type</code>) |
2066 |
* by wrapping it. Note, however, that the result is only legal for |
2102 |
* by wrapping it. Note, however, that the result is only legal for |
2067 |
* limited expression types, including method invocations, assignments, |
2103 |
* limited expression types, including method invocations, assignments, |
2068 |
* and increment/decrement operations. |
2104 |
* and increment/decrement operations. |
2069 |
* </p> |
2105 |
* </p> |
2070 |
* |
2106 |
* |
2071 |
* @param expression the expression |
2107 |
* @param expression the expression |
2072 |
* @return a new unparented statement node |
2108 |
* @return a new unparented statement node |
2073 |
* @exception IllegalArgumentException if: |
2109 |
* @exception IllegalArgumentException if: |
Lines 2082-2093
Link Here
|
2082 |
result.setExpression(expression); |
2118 |
result.setExpression(expression); |
2083 |
return result; |
2119 |
return result; |
2084 |
} |
2120 |
} |
2085 |
|
2121 |
|
2086 |
/** |
2122 |
/** |
2087 |
* Creates a new unparented if statement node owned by this AST. |
2123 |
* Creates a new unparented if statement node owned by this AST. |
2088 |
* By default, the expression is unspecified (but legal), |
2124 |
* By default, the expression is unspecified (but legal), |
2089 |
* the then statement is an empty block, and there is no else statement. |
2125 |
* the then statement is an empty block, and there is no else statement. |
2090 |
* |
2126 |
* |
2091 |
* @return a new unparented if statement node |
2127 |
* @return a new unparented if statement node |
2092 |
*/ |
2128 |
*/ |
2093 |
public IfStatement newIfStatement() { |
2129 |
public IfStatement newIfStatement() { |
Lines 2098-2104
Link Here
|
2098 |
* Creates a new unparented while statement node owned by this AST. |
2134 |
* Creates a new unparented while statement node owned by this AST. |
2099 |
* By default, the expression is unspecified (but legal), and |
2135 |
* By default, the expression is unspecified (but legal), and |
2100 |
* the body statement is an empty block. |
2136 |
* the body statement is an empty block. |
2101 |
* |
2137 |
* |
2102 |
* @return a new unparented while statement node |
2138 |
* @return a new unparented while statement node |
2103 |
*/ |
2139 |
*/ |
2104 |
public WhileStatement newWhileStatement() { |
2140 |
public WhileStatement newWhileStatement() { |
Lines 2109-2115
Link Here
|
2109 |
* Creates a new unparented do statement node owned by this AST. |
2145 |
* Creates a new unparented do statement node owned by this AST. |
2110 |
* By default, the expression is unspecified (but legal), and |
2146 |
* By default, the expression is unspecified (but legal), and |
2111 |
* the body statement is an empty block. |
2147 |
* the body statement is an empty block. |
2112 |
* |
2148 |
* |
2113 |
* @return a new unparented do statement node |
2149 |
* @return a new unparented do statement node |
2114 |
*/ |
2150 |
*/ |
2115 |
public DoStatement newDoStatement() { |
2151 |
public DoStatement newDoStatement() { |
Lines 2120-2126
Link Here
|
2120 |
* Creates a new unparented try statement node owned by this AST. |
2156 |
* Creates a new unparented try statement node owned by this AST. |
2121 |
* By default, the try statement has an empty block, no catch |
2157 |
* By default, the try statement has an empty block, no catch |
2122 |
* clauses, and no finally block. |
2158 |
* clauses, and no finally block. |
2123 |
* |
2159 |
* |
2124 |
* @return a new unparented try statement node |
2160 |
* @return a new unparented try statement node |
2125 |
*/ |
2161 |
*/ |
2126 |
public TryStatement newTryStatement() { |
2162 |
public TryStatement newTryStatement() { |
Lines 2129-2137
Link Here
|
2129 |
|
2165 |
|
2130 |
/** |
2166 |
/** |
2131 |
* Creates a new unparented catch clause node owned by this AST. |
2167 |
* Creates a new unparented catch clause node owned by this AST. |
2132 |
* By default, the catch clause declares an unspecified, but legal, |
2168 |
* By default, the catch clause declares an unspecified, but legal, |
2133 |
* exception declaration and has an empty block. |
2169 |
* exception declaration and has an empty block. |
2134 |
* |
2170 |
* |
2135 |
* @return a new unparented catch clause node |
2171 |
* @return a new unparented catch clause node |
2136 |
*/ |
2172 |
*/ |
2137 |
public CatchClause newCatchClause() { |
2173 |
public CatchClause newCatchClause() { |
Lines 2141-2147
Link Here
|
2141 |
/** |
2177 |
/** |
2142 |
* Creates a new unparented return statement node owned by this AST. |
2178 |
* Creates a new unparented return statement node owned by this AST. |
2143 |
* By default, the return statement has no expression. |
2179 |
* By default, the return statement has no expression. |
2144 |
* |
2180 |
* |
2145 |
* @return a new unparented return statement node |
2181 |
* @return a new unparented return statement node |
2146 |
*/ |
2182 |
*/ |
2147 |
public ReturnStatement newReturnStatement() { |
2183 |
public ReturnStatement newReturnStatement() { |
Lines 2151-2157
Link Here
|
2151 |
/** |
2187 |
/** |
2152 |
* Creates a new unparented throw statement node owned by this AST. |
2188 |
* Creates a new unparented throw statement node owned by this AST. |
2153 |
* By default, the expression is unspecified, but legal. |
2189 |
* By default, the expression is unspecified, but legal. |
2154 |
* |
2190 |
* |
2155 |
* @return a new unparented throw statement node |
2191 |
* @return a new unparented throw statement node |
2156 |
*/ |
2192 |
*/ |
2157 |
public ThrowStatement newThrowStatement() { |
2193 |
public ThrowStatement newThrowStatement() { |
Lines 2162-2168
Link Here
|
2162 |
* Creates a new unparented assert statement node owned by this AST. |
2198 |
* Creates a new unparented assert statement node owned by this AST. |
2163 |
* By default, the first expression is unspecified, but legal, and has no |
2199 |
* By default, the first expression is unspecified, but legal, and has no |
2164 |
* message expression. |
2200 |
* message expression. |
2165 |
* |
2201 |
* |
2166 |
* @return a new unparented assert statement node |
2202 |
* @return a new unparented assert statement node |
2167 |
*/ |
2203 |
*/ |
2168 |
public AssertStatement newAssertStatement() { |
2204 |
public AssertStatement newAssertStatement() { |
Lines 2171-2177
Link Here
|
2171 |
|
2207 |
|
2172 |
/** |
2208 |
/** |
2173 |
* Creates a new unparented empty statement node owned by this AST. |
2209 |
* Creates a new unparented empty statement node owned by this AST. |
2174 |
* |
2210 |
* |
2175 |
* @return a new unparented empty statement node |
2211 |
* @return a new unparented empty statement node |
2176 |
*/ |
2212 |
*/ |
2177 |
public EmptyStatement newEmptyStatement() { |
2213 |
public EmptyStatement newEmptyStatement() { |
Lines 2181-2187
Link Here
|
2181 |
/** |
2217 |
/** |
2182 |
* Creates a new unparented labeled statement node owned by this AST. |
2218 |
* Creates a new unparented labeled statement node owned by this AST. |
2183 |
* By default, the label and statement are both unspecified, but legal. |
2219 |
* By default, the label and statement are both unspecified, but legal. |
2184 |
* |
2220 |
* |
2185 |
* @return a new unparented labeled statement node |
2221 |
* @return a new unparented labeled statement node |
2186 |
*/ |
2222 |
*/ |
2187 |
public LabeledStatement newLabeledStatement() { |
2223 |
public LabeledStatement newLabeledStatement() { |
Lines 2192-2198
Link Here
|
2192 |
* Creates a new unparented switch statement node owned by this AST. |
2228 |
* Creates a new unparented switch statement node owned by this AST. |
2193 |
* By default, the expression is unspecified, but legal, and there are |
2229 |
* By default, the expression is unspecified, but legal, and there are |
2194 |
* no statements or switch cases. |
2230 |
* no statements or switch cases. |
2195 |
* |
2231 |
* |
2196 |
* @return a new unparented labeled statement node |
2232 |
* @return a new unparented labeled statement node |
2197 |
*/ |
2233 |
*/ |
2198 |
public SwitchStatement newSwitchStatement() { |
2234 |
public SwitchStatement newSwitchStatement() { |
Lines 2200-2208
Link Here
|
2200 |
} |
2236 |
} |
2201 |
|
2237 |
|
2202 |
/** |
2238 |
/** |
2203 |
* Creates a new unparented switch case statement node owned by |
2239 |
* Creates a new unparented switch case statement node owned by |
2204 |
* this AST. By default, the expression is unspecified, but legal. |
2240 |
* this AST. By default, the expression is unspecified, but legal. |
2205 |
* |
2241 |
* |
2206 |
* @return a new unparented switch case node |
2242 |
* @return a new unparented switch case node |
2207 |
*/ |
2243 |
*/ |
2208 |
public SwitchCase newSwitchCase() { |
2244 |
public SwitchCase newSwitchCase() { |
Lines 2213-2219
Link Here
|
2213 |
* Creates a new unparented synchronized statement node owned by this AST. |
2249 |
* Creates a new unparented synchronized statement node owned by this AST. |
2214 |
* By default, the expression is unspecified, but legal, and the body is |
2250 |
* By default, the expression is unspecified, but legal, and the body is |
2215 |
* an empty block. |
2251 |
* an empty block. |
2216 |
* |
2252 |
* |
2217 |
* @return a new unparented synchronized statement node |
2253 |
* @return a new unparented synchronized statement node |
2218 |
*/ |
2254 |
*/ |
2219 |
public SynchronizedStatement newSynchronizedStatement() { |
2255 |
public SynchronizedStatement newSynchronizedStatement() { |
Lines 2222-2230
Link Here
|
2222 |
|
2258 |
|
2223 |
/** |
2259 |
/** |
2224 |
* Creates a new unparented for statement node owned by this AST. |
2260 |
* Creates a new unparented for statement node owned by this AST. |
2225 |
* By default, there are no initializers, no condition expression, |
2261 |
* By default, there are no initializers, no condition expression, |
2226 |
* no updaters, and the body is an empty block. |
2262 |
* no updaters, and the body is an empty block. |
2227 |
* |
2263 |
* |
2228 |
* @return a new unparented for statement node |
2264 |
* @return a new unparented for statement node |
2229 |
*/ |
2265 |
*/ |
2230 |
public ForStatement newForStatement() { |
2266 |
public ForStatement newForStatement() { |
Lines 2235-2241
Link Here
|
2235 |
* Creates a new unparented enhanced for statement node owned by this AST. |
2271 |
* Creates a new unparented enhanced for statement node owned by this AST. |
2236 |
* By default, the paramter and expression are unspecified |
2272 |
* By default, the paramter and expression are unspecified |
2237 |
* but legal subtrees, and the body is an empty block. |
2273 |
* but legal subtrees, and the body is an empty block. |
2238 |
* |
2274 |
* |
2239 |
* @return a new unparented throw statement node |
2275 |
* @return a new unparented throw statement node |
2240 |
* @exception UnsupportedOperationException if this operation is used in |
2276 |
* @exception UnsupportedOperationException if this operation is used in |
2241 |
* a JLS2 AST |
2277 |
* a JLS2 AST |
Lines 2247-2266
Link Here
|
2247 |
|
2283 |
|
2248 |
//=============================== EXPRESSIONS =========================== |
2284 |
//=============================== EXPRESSIONS =========================== |
2249 |
/** |
2285 |
/** |
2250 |
* Creates and returns a new unparented string literal node for |
2286 |
* Creates and returns a new unparented string literal node for |
2251 |
* the empty string literal. |
2287 |
* the empty string literal. |
2252 |
* |
2288 |
* |
2253 |
* @return a new unparented string literal node |
2289 |
* @return a new unparented string literal node |
2254 |
*/ |
2290 |
*/ |
2255 |
public StringLiteral newStringLiteral() { |
2291 |
public StringLiteral newStringLiteral() { |
2256 |
return new StringLiteral(this); |
2292 |
return new StringLiteral(this); |
2257 |
} |
2293 |
} |
2258 |
|
2294 |
|
2259 |
|
2295 |
|
2260 |
/** |
2296 |
/** |
2261 |
* Creates and returns a new unparented character literal node. |
2297 |
* Creates and returns a new unparented character literal node. |
2262 |
* Initially the node has an unspecified character literal. |
2298 |
* Initially the node has an unspecified character literal. |
2263 |
* |
2299 |
* |
2264 |
* @return a new unparented character literal node |
2300 |
* @return a new unparented character literal node |
2265 |
*/ |
2301 |
*/ |
2266 |
public CharacterLiteral newCharacterLiteral() { |
2302 |
public CharacterLiteral newCharacterLiteral() { |
Lines 2269-2276
Link Here
|
2269 |
|
2305 |
|
2270 |
/** |
2306 |
/** |
2271 |
* Creates and returns a new unparented number literal node. |
2307 |
* Creates and returns a new unparented number literal node. |
2272 |
* |
2308 |
* |
2273 |
* @param literal the token for the numeric literal as it would |
2309 |
* @param literal the token for the numeric literal as it would |
2274 |
* appear in Java source code |
2310 |
* appear in Java source code |
2275 |
* @return a new unparented number literal node |
2311 |
* @return a new unparented number literal node |
2276 |
* @exception IllegalArgumentException if the literal is null |
2312 |
* @exception IllegalArgumentException if the literal is null |
Lines 2283-2309
Link Here
|
2283 |
result.setToken(literal); |
2319 |
result.setToken(literal); |
2284 |
return result; |
2320 |
return result; |
2285 |
} |
2321 |
} |
2286 |
|
2322 |
|
2287 |
/** |
2323 |
/** |
2288 |
* Creates and returns a new unparented number literal node. |
2324 |
* Creates and returns a new unparented number literal node. |
2289 |
* Initially the number literal token is <code>"0"</code>. |
2325 |
* Initially the number literal token is <code>"0"</code>. |
2290 |
* |
2326 |
* |
2291 |
* @return a new unparented number literal node |
2327 |
* @return a new unparented number literal node |
2292 |
*/ |
2328 |
*/ |
2293 |
public NumberLiteral newNumberLiteral() { |
2329 |
public NumberLiteral newNumberLiteral() { |
2294 |
NumberLiteral result = new NumberLiteral(this); |
2330 |
NumberLiteral result = new NumberLiteral(this); |
2295 |
return result; |
2331 |
return result; |
2296 |
} |
2332 |
} |
2297 |
|
2333 |
|
2298 |
/** |
2334 |
/** |
2299 |
* Creates and returns a new unparented null literal node. |
2335 |
* Creates and returns a new unparented null literal node. |
2300 |
* |
2336 |
* |
2301 |
* @return a new unparented null literal node |
2337 |
* @return a new unparented null literal node |
2302 |
*/ |
2338 |
*/ |
2303 |
public NullLiteral newNullLiteral() { |
2339 |
public NullLiteral newNullLiteral() { |
2304 |
return new NullLiteral(this); |
2340 |
return new NullLiteral(this); |
2305 |
} |
2341 |
} |
2306 |
|
2342 |
|
2307 |
/** |
2343 |
/** |
2308 |
* Creates and returns a new unparented boolean literal node. |
2344 |
* Creates and returns a new unparented boolean literal node. |
2309 |
* <p> |
2345 |
* <p> |
Lines 2317-2323
Link Here
|
2317 |
* </pre> |
2353 |
* </pre> |
2318 |
* </code> |
2354 |
* </code> |
2319 |
* </p> |
2355 |
* </p> |
2320 |
* |
2356 |
* |
2321 |
* @param value the boolean value |
2357 |
* @param value the boolean value |
2322 |
* @return a new unparented boolean literal node |
2358 |
* @return a new unparented boolean literal node |
2323 |
*/ |
2359 |
*/ |
Lines 2326-2398
Link Here
|
2326 |
result.setBooleanValue(value); |
2362 |
result.setBooleanValue(value); |
2327 |
return result; |
2363 |
return result; |
2328 |
} |
2364 |
} |
2329 |
|
2365 |
|
2330 |
/** |
2366 |
/** |
2331 |
* Creates and returns a new unparented assignment expression node |
2367 |
* Creates and returns a new unparented assignment expression node |
2332 |
* owned by this AST. By default, the assignment operator is "=" and |
2368 |
* owned by this AST. By default, the assignment operator is "=" and |
2333 |
* the left and right hand side expressions are unspecified, but |
2369 |
* the left and right hand side expressions are unspecified, but |
2334 |
* legal, names. |
2370 |
* legal, names. |
2335 |
* |
2371 |
* |
2336 |
* @return a new unparented assignment expression node |
2372 |
* @return a new unparented assignment expression node |
2337 |
*/ |
2373 |
*/ |
2338 |
public Assignment newAssignment() { |
2374 |
public Assignment newAssignment() { |
2339 |
Assignment result = new Assignment(this); |
2375 |
Assignment result = new Assignment(this); |
2340 |
return result; |
2376 |
return result; |
2341 |
} |
2377 |
} |
2342 |
|
2378 |
|
2343 |
/** |
2379 |
/** |
2344 |
* Creates an unparented method invocation expression node owned by this |
2380 |
* Creates an unparented method invocation expression node owned by this |
2345 |
* AST. By default, the name of the method is unspecified (but legal) |
2381 |
* AST. By default, the name of the method is unspecified (but legal) |
2346 |
* there is no receiver expression, no type arguments, and the list of |
2382 |
* there is no receiver expression, no type arguments, and the list of |
2347 |
* arguments is empty. |
2383 |
* arguments is empty. |
2348 |
* |
2384 |
* |
2349 |
* @return a new unparented method invocation expression node |
2385 |
* @return a new unparented method invocation expression node |
2350 |
*/ |
2386 |
*/ |
2351 |
public MethodInvocation newMethodInvocation() { |
2387 |
public MethodInvocation newMethodInvocation() { |
2352 |
MethodInvocation result = new MethodInvocation(this); |
2388 |
MethodInvocation result = new MethodInvocation(this); |
2353 |
return result; |
2389 |
return result; |
2354 |
} |
2390 |
} |
2355 |
|
2391 |
|
2356 |
/** |
2392 |
/** |
2357 |
* Creates an unparented "super" method invocation expression node owned by |
2393 |
* Creates an unparented "super" method invocation expression node owned by |
2358 |
* this AST. By default, the name of the method is unspecified (but legal) |
2394 |
* this AST. By default, the name of the method is unspecified (but legal) |
2359 |
* there is no qualifier, no type arguments, and the list of arguments is empty. |
2395 |
* there is no qualifier, no type arguments, and the list of arguments is empty. |
2360 |
* |
2396 |
* |
2361 |
* @return a new unparented "super" method invocation |
2397 |
* @return a new unparented "super" method invocation |
2362 |
* expression node |
2398 |
* expression node |
2363 |
*/ |
2399 |
*/ |
2364 |
public SuperMethodInvocation newSuperMethodInvocation() { |
2400 |
public SuperMethodInvocation newSuperMethodInvocation() { |
2365 |
SuperMethodInvocation result = new SuperMethodInvocation(this); |
2401 |
SuperMethodInvocation result = new SuperMethodInvocation(this); |
2366 |
return result; |
2402 |
return result; |
2367 |
} |
2403 |
} |
2368 |
|
2404 |
|
2369 |
/** |
2405 |
/** |
2370 |
* Creates an unparented alternate constructor ("this(...);") invocation |
2406 |
* Creates an unparented alternate constructor ("this(...);") invocation |
2371 |
* statement node owned by this AST. By default, the lists of arguments |
2407 |
* statement node owned by this AST. By default, the lists of arguments |
2372 |
* and type arguments are both empty. |
2408 |
* and type arguments are both empty. |
2373 |
* <p> |
2409 |
* <p> |
2374 |
* Note that this type of node is a Statement, whereas a regular |
2410 |
* Note that this type of node is a Statement, whereas a regular |
2375 |
* method invocation is an Expression. The only valid use of these |
2411 |
* method invocation is an Expression. The only valid use of these |
2376 |
* statements are as the first statement of a constructor body. |
2412 |
* statements are as the first statement of a constructor body. |
2377 |
* </p> |
2413 |
* </p> |
2378 |
* |
2414 |
* |
2379 |
* @return a new unparented alternate constructor invocation statement node |
2415 |
* @return a new unparented alternate constructor invocation statement node |
2380 |
*/ |
2416 |
*/ |
2381 |
public ConstructorInvocation newConstructorInvocation() { |
2417 |
public ConstructorInvocation newConstructorInvocation() { |
2382 |
ConstructorInvocation result = new ConstructorInvocation(this); |
2418 |
ConstructorInvocation result = new ConstructorInvocation(this); |
2383 |
return result; |
2419 |
return result; |
2384 |
} |
2420 |
} |
2385 |
|
2421 |
|
2386 |
/** |
2422 |
/** |
2387 |
* Creates an unparented alternate super constructor ("super(...);") |
2423 |
* Creates an unparented alternate super constructor ("super(...);") |
2388 |
* invocation statement node owned by this AST. By default, there is no |
2424 |
* invocation statement node owned by this AST. By default, there is no |
2389 |
* qualifier, no type arguments, and the list of arguments is empty. |
2425 |
* qualifier, no type arguments, and the list of arguments is empty. |
2390 |
* <p> |
2426 |
* <p> |
2391 |
* Note that this type of node is a Statement, whereas a regular |
2427 |
* Note that this type of node is a Statement, whereas a regular |
2392 |
* super method invocation is an Expression. The only valid use of these |
2428 |
* super method invocation is an Expression. The only valid use of these |
2393 |
* statements are as the first statement of a constructor body. |
2429 |
* statements are as the first statement of a constructor body. |
2394 |
* </p> |
2430 |
* </p> |
2395 |
* |
2431 |
* |
2396 |
* @return a new unparented super constructor invocation statement node |
2432 |
* @return a new unparented super constructor invocation statement node |
2397 |
*/ |
2433 |
*/ |
2398 |
public SuperConstructorInvocation newSuperConstructorInvocation() { |
2434 |
public SuperConstructorInvocation newSuperConstructorInvocation() { |
Lines 2400-2409
Link Here
|
2400 |
new SuperConstructorInvocation(this); |
2436 |
new SuperConstructorInvocation(this); |
2401 |
return result; |
2437 |
return result; |
2402 |
} |
2438 |
} |
2403 |
|
2439 |
|
2404 |
/** |
2440 |
/** |
2405 |
* Creates a new unparented local variable declaration expression node |
2441 |
* Creates a new unparented local variable declaration expression node |
2406 |
* owned by this AST, for the given variable declaration fragment. By |
2442 |
* owned by this AST, for the given variable declaration fragment. By |
2407 |
* default, there are no modifiers and the base type is unspecified |
2443 |
* default, there are no modifiers and the base type is unspecified |
2408 |
* (but legal). |
2444 |
* (but legal). |
2409 |
* <p> |
2445 |
* <p> |
Lines 2412-2418
Link Here
|
2412 |
* (<code>Expression</code>) by wrapping it. Additional variable |
2448 |
* (<code>Expression</code>) by wrapping it. Additional variable |
2413 |
* declaration fragments can be added afterwards. |
2449 |
* declaration fragments can be added afterwards. |
2414 |
* </p> |
2450 |
* </p> |
2415 |
* |
2451 |
* |
2416 |
* @param fragment the first variable declaration fragment |
2452 |
* @param fragment the first variable declaration fragment |
2417 |
* @return a new unparented variable declaration expression node |
2453 |
* @return a new unparented variable declaration expression node |
2418 |
* @exception IllegalArgumentException if: |
2454 |
* @exception IllegalArgumentException if: |
Lines 2434-2444
Link Here
|
2434 |
result.fragments().add(fragment); |
2470 |
result.fragments().add(fragment); |
2435 |
return result; |
2471 |
return result; |
2436 |
} |
2472 |
} |
2437 |
|
2473 |
|
2438 |
/** |
2474 |
/** |
2439 |
* Creates a new unparented field declaration node owned by this AST, |
2475 |
* Creates a new unparented field declaration node owned by this AST, |
2440 |
* for the given variable declaration fragment. By default, there are no |
2476 |
* for the given variable declaration fragment. By default, there are no |
2441 |
* modifiers, no doc comment, and the base type is unspecified |
2477 |
* modifiers, no doc comment, and the base type is unspecified |
2442 |
* (but legal). |
2478 |
* (but legal). |
2443 |
* <p> |
2479 |
* <p> |
2444 |
* This method can be used to wrap a variable declaration fragment |
2480 |
* This method can be used to wrap a variable declaration fragment |
Lines 2447-2453
Link Here
|
2447 |
* (<code>FieldDeclaration</code> implements <code>BodyDeclaration</code>). |
2483 |
* (<code>FieldDeclaration</code> implements <code>BodyDeclaration</code>). |
2448 |
* Additional variable declaration fragments can be added afterwards. |
2484 |
* Additional variable declaration fragments can be added afterwards. |
2449 |
* </p> |
2485 |
* </p> |
2450 |
* |
2486 |
* |
2451 |
* @param fragment the variable declaration fragment |
2487 |
* @param fragment the variable declaration fragment |
2452 |
* @return a new unparented field declaration node |
2488 |
* @return a new unparented field declaration node |
2453 |
* @exception IllegalArgumentException if: |
2489 |
* @exception IllegalArgumentException if: |
Lines 2466-2476
Link Here
|
2466 |
result.fragments().add(fragment); |
2502 |
result.fragments().add(fragment); |
2467 |
return result; |
2503 |
return result; |
2468 |
} |
2504 |
} |
2469 |
|
2505 |
|
2470 |
/** |
2506 |
/** |
2471 |
* Creates and returns a new unparented "this" expression node |
2507 |
* Creates and returns a new unparented "this" expression node |
2472 |
* owned by this AST. By default, there is no qualifier. |
2508 |
* owned by this AST. By default, there is no qualifier. |
2473 |
* |
2509 |
* |
2474 |
* @return a new unparented "this" expression node |
2510 |
* @return a new unparented "this" expression node |
2475 |
*/ |
2511 |
*/ |
2476 |
public ThisExpression newThisExpression() { |
2512 |
public ThisExpression newThisExpression() { |
Lines 2479-2488
Link Here
|
2479 |
} |
2515 |
} |
2480 |
|
2516 |
|
2481 |
/** |
2517 |
/** |
2482 |
* Creates and returns a new unparented field access expression node |
2518 |
* Creates and returns a new unparented field access expression node |
2483 |
* owned by this AST. By default, the expression and field are both |
2519 |
* owned by this AST. By default, the expression and field are both |
2484 |
* unspecified, but legal, names. |
2520 |
* unspecified, but legal, names. |
2485 |
* |
2521 |
* |
2486 |
* @return a new unparented field access expression node |
2522 |
* @return a new unparented field access expression node |
2487 |
*/ |
2523 |
*/ |
2488 |
public FieldAccess newFieldAccess() { |
2524 |
public FieldAccess newFieldAccess() { |
Lines 2491-2500
Link Here
|
2491 |
} |
2527 |
} |
2492 |
|
2528 |
|
2493 |
/** |
2529 |
/** |
2494 |
* Creates and returns a new unparented super field access expression node |
2530 |
* Creates and returns a new unparented super field access expression node |
2495 |
* owned by this AST. By default, the expression and field are both |
2531 |
* owned by this AST. By default, the expression and field are both |
2496 |
* unspecified, but legal, names. |
2532 |
* unspecified, but legal, names. |
2497 |
* |
2533 |
* |
2498 |
* @return a new unparented super field access expression node |
2534 |
* @return a new unparented super field access expression node |
2499 |
*/ |
2535 |
*/ |
2500 |
public SuperFieldAccess newSuperFieldAccess() { |
2536 |
public SuperFieldAccess newSuperFieldAccess() { |
Lines 2503-2511
Link Here
|
2503 |
} |
2539 |
} |
2504 |
|
2540 |
|
2505 |
/** |
2541 |
/** |
2506 |
* Creates and returns a new unparented type literal expression node |
2542 |
* Creates and returns a new unparented type literal expression node |
2507 |
* owned by this AST. By default, the type is unspecified (but legal). |
2543 |
* owned by this AST. By default, the type is unspecified (but legal). |
2508 |
* |
2544 |
* |
2509 |
* @return a new unparented type literal node |
2545 |
* @return a new unparented type literal node |
2510 |
*/ |
2546 |
*/ |
2511 |
public TypeLiteral newTypeLiteral() { |
2547 |
public TypeLiteral newTypeLiteral() { |
Lines 2514-2523
Link Here
|
2514 |
} |
2550 |
} |
2515 |
|
2551 |
|
2516 |
/** |
2552 |
/** |
2517 |
* Creates and returns a new unparented cast expression node |
2553 |
* Creates and returns a new unparented cast expression node |
2518 |
* owned by this AST. By default, the type and expression are unspecified |
2554 |
* owned by this AST. By default, the type and expression are unspecified |
2519 |
* (but legal). |
2555 |
* (but legal). |
2520 |
* |
2556 |
* |
2521 |
* @return a new unparented cast expression node |
2557 |
* @return a new unparented cast expression node |
2522 |
*/ |
2558 |
*/ |
2523 |
public CastExpression newCastExpression() { |
2559 |
public CastExpression newCastExpression() { |
Lines 2526-2534
Link Here
|
2526 |
} |
2562 |
} |
2527 |
|
2563 |
|
2528 |
/** |
2564 |
/** |
2529 |
* Creates and returns a new unparented parenthesized expression node |
2565 |
* Creates and returns a new unparented parenthesized expression node |
2530 |
* owned by this AST. By default, the expression is unspecified (but legal). |
2566 |
* owned by this AST. By default, the expression is unspecified (but legal). |
2531 |
* |
2567 |
* |
2532 |
* @return a new unparented parenthesized expression node |
2568 |
* @return a new unparented parenthesized expression node |
2533 |
*/ |
2569 |
*/ |
2534 |
public ParenthesizedExpression newParenthesizedExpression() { |
2570 |
public ParenthesizedExpression newParenthesizedExpression() { |
Lines 2537-2547
Link Here
|
2537 |
} |
2573 |
} |
2538 |
|
2574 |
|
2539 |
/** |
2575 |
/** |
2540 |
* Creates and returns a new unparented infix expression node |
2576 |
* Creates and returns a new unparented infix expression node |
2541 |
* owned by this AST. By default, the operator and left and right |
2577 |
* owned by this AST. By default, the operator and left and right |
2542 |
* operand are unspecified (but legal), and there are no extended |
2578 |
* operand are unspecified (but legal), and there are no extended |
2543 |
* operands. |
2579 |
* operands. |
2544 |
* |
2580 |
* |
2545 |
* @return a new unparented infix expression node |
2581 |
* @return a new unparented infix expression node |
2546 |
*/ |
2582 |
*/ |
2547 |
public InfixExpression newInfixExpression() { |
2583 |
public InfixExpression newInfixExpression() { |
Lines 2550-2559
Link Here
|
2550 |
} |
2586 |
} |
2551 |
|
2587 |
|
2552 |
/** |
2588 |
/** |
2553 |
* Creates and returns a new unparented instanceof expression node |
2589 |
* Creates and returns a new unparented instanceof expression node |
2554 |
* owned by this AST. By default, the operator and left and right |
2590 |
* owned by this AST. By default, the operator and left and right |
2555 |
* operand are unspecified (but legal). |
2591 |
* operand are unspecified (but legal). |
2556 |
* |
2592 |
* |
2557 |
* @return a new unparented instanceof expression node |
2593 |
* @return a new unparented instanceof expression node |
2558 |
*/ |
2594 |
*/ |
2559 |
public InstanceofExpression newInstanceofExpression() { |
2595 |
public InstanceofExpression newInstanceofExpression() { |
Lines 2562-2571
Link Here
|
2562 |
} |
2598 |
} |
2563 |
|
2599 |
|
2564 |
/** |
2600 |
/** |
2565 |
* Creates and returns a new unparented postfix expression node |
2601 |
* Creates and returns a new unparented postfix expression node |
2566 |
* owned by this AST. By default, the operator and operand are |
2602 |
* owned by this AST. By default, the operator and operand are |
2567 |
* unspecified (but legal). |
2603 |
* unspecified (but legal). |
2568 |
* |
2604 |
* |
2569 |
* @return a new unparented postfix expression node |
2605 |
* @return a new unparented postfix expression node |
2570 |
*/ |
2606 |
*/ |
2571 |
public PostfixExpression newPostfixExpression() { |
2607 |
public PostfixExpression newPostfixExpression() { |
Lines 2574-2583
Link Here
|
2574 |
} |
2610 |
} |
2575 |
|
2611 |
|
2576 |
/** |
2612 |
/** |
2577 |
* Creates and returns a new unparented prefix expression node |
2613 |
* Creates and returns a new unparented prefix expression node |
2578 |
* owned by this AST. By default, the operator and operand are |
2614 |
* owned by this AST. By default, the operator and operand are |
2579 |
* unspecified (but legal). |
2615 |
* unspecified (but legal). |
2580 |
* |
2616 |
* |
2581 |
* @return a new unparented prefix expression node |
2617 |
* @return a new unparented prefix expression node |
2582 |
*/ |
2618 |
*/ |
2583 |
public PrefixExpression newPrefixExpression() { |
2619 |
public PrefixExpression newPrefixExpression() { |
Lines 2586-2595
Link Here
|
2586 |
} |
2622 |
} |
2587 |
|
2623 |
|
2588 |
/** |
2624 |
/** |
2589 |
* Creates and returns a new unparented array access expression node |
2625 |
* Creates and returns a new unparented array access expression node |
2590 |
* owned by this AST. By default, the array and index expression are |
2626 |
* owned by this AST. By default, the array and index expression are |
2591 |
* both unspecified (but legal). |
2627 |
* both unspecified (but legal). |
2592 |
* |
2628 |
* |
2593 |
* @return a new unparented array access expression node |
2629 |
* @return a new unparented array access expression node |
2594 |
*/ |
2630 |
*/ |
2595 |
public ArrayAccess newArrayAccess() { |
2631 |
public ArrayAccess newArrayAccess() { |
Lines 2598-2604
Link Here
|
2598 |
} |
2634 |
} |
2599 |
|
2635 |
|
2600 |
/** |
2636 |
/** |
2601 |
* Creates and returns a new unparented array creation expression node |
2637 |
* Creates and returns a new unparented array creation expression node |
2602 |
* owned by this AST. By default, the array type is an unspecified |
2638 |
* owned by this AST. By default, the array type is an unspecified |
2603 |
* 1-dimensional array, the list of dimensions is empty, and there is no |
2639 |
* 1-dimensional array, the list of dimensions is empty, and there is no |
2604 |
* array initializer. |
2640 |
* array initializer. |
Lines 2633-2639
Link Here
|
2633 |
* </pre> |
2669 |
* </pre> |
2634 |
* </code> |
2670 |
* </code> |
2635 |
* </p> |
2671 |
* </p> |
2636 |
* |
2672 |
* |
2637 |
* @return a new unparented array creation expression node |
2673 |
* @return a new unparented array creation expression node |
2638 |
*/ |
2674 |
*/ |
2639 |
public ArrayCreation newArrayCreation() { |
2675 |
public ArrayCreation newArrayCreation() { |
Lines 2642-2653
Link Here
|
2642 |
} |
2678 |
} |
2643 |
|
2679 |
|
2644 |
/** |
2680 |
/** |
2645 |
* Creates and returns a new unparented class instance creation |
2681 |
* Creates and returns a new unparented class instance creation |
2646 |
* ("new") expression node owned by this AST. By default, |
2682 |
* ("new") expression node owned by this AST. By default, |
2647 |
* there is no qualifying expression, no type parameters, |
2683 |
* there is no qualifying expression, no type parameters, |
2648 |
* an unspecified (but legal) type name, an empty list of |
2684 |
* an unspecified (but legal) type name, an empty list of |
2649 |
* arguments, and does not declare an anonymous class declaration. |
2685 |
* arguments, and does not declare an anonymous class declaration. |
2650 |
* |
2686 |
* |
2651 |
* @return a new unparented class instance creation expression node |
2687 |
* @return a new unparented class instance creation expression node |
2652 |
*/ |
2688 |
*/ |
2653 |
public ClassInstanceCreation newClassInstanceCreation() { |
2689 |
public ClassInstanceCreation newClassInstanceCreation() { |
Lines 2658-2664
Link Here
|
2658 |
/** |
2694 |
/** |
2659 |
* Creates and returns a new unparented anonymous class declaration |
2695 |
* Creates and returns a new unparented anonymous class declaration |
2660 |
* node owned by this AST. By default, the body declaration list is empty. |
2696 |
* node owned by this AST. By default, the body declaration list is empty. |
2661 |
* |
2697 |
* |
2662 |
* @return a new unparented anonymous class declaration node |
2698 |
* @return a new unparented anonymous class declaration node |
2663 |
*/ |
2699 |
*/ |
2664 |
public AnonymousClassDeclaration newAnonymousClassDeclaration() { |
2700 |
public AnonymousClassDeclaration newAnonymousClassDeclaration() { |
Lines 2667-2675
Link Here
|
2667 |
} |
2703 |
} |
2668 |
|
2704 |
|
2669 |
/** |
2705 |
/** |
2670 |
* Creates and returns a new unparented array initializer node |
2706 |
* Creates and returns a new unparented array initializer node |
2671 |
* owned by this AST. By default, the initializer has no expressions. |
2707 |
* owned by this AST. By default, the initializer has no expressions. |
2672 |
* |
2708 |
* |
2673 |
* @return a new unparented array initializer node |
2709 |
* @return a new unparented array initializer node |
2674 |
*/ |
2710 |
*/ |
2675 |
public ArrayInitializer newArrayInitializer() { |
2711 |
public ArrayInitializer newArrayInitializer() { |
Lines 2678-2701
Link Here
|
2678 |
} |
2714 |
} |
2679 |
|
2715 |
|
2680 |
/** |
2716 |
/** |
2681 |
* Creates and returns a new unparented conditional expression node |
2717 |
* Creates and returns a new unparented conditional expression node |
2682 |
* owned by this AST. By default, the condition and both expressions |
2718 |
* owned by this AST. By default, the condition and both expressions |
2683 |
* are unspecified (but legal). |
2719 |
* are unspecified (but legal). |
2684 |
* |
2720 |
* |
2685 |
* @return a new unparented array conditional expression node |
2721 |
* @return a new unparented array conditional expression node |
2686 |
*/ |
2722 |
*/ |
2687 |
public ConditionalExpression newConditionalExpression() { |
2723 |
public ConditionalExpression newConditionalExpression() { |
2688 |
ConditionalExpression result = new ConditionalExpression(this); |
2724 |
ConditionalExpression result = new ConditionalExpression(this); |
2689 |
return result; |
2725 |
return result; |
2690 |
} |
2726 |
} |
2691 |
|
2727 |
|
2692 |
//=============================== ANNOTATIONS ==================== |
2728 |
//=============================== ANNOTATIONS ==================== |
2693 |
|
2729 |
|
2694 |
/** |
2730 |
/** |
2695 |
* Creates and returns a new unparented normal annotation node with |
2731 |
* Creates and returns a new unparented normal annotation node with |
2696 |
* an unspecified type name and an empty list of member value |
2732 |
* an unspecified type name and an empty list of member value |
2697 |
* pairs. |
2733 |
* pairs. |
2698 |
* |
2734 |
* |
2699 |
* @return a new unparented normal annotation node |
2735 |
* @return a new unparented normal annotation node |
2700 |
* @exception UnsupportedOperationException if this operation is used in |
2736 |
* @exception UnsupportedOperationException if this operation is used in |
2701 |
* a JLS2 AST |
2737 |
* a JLS2 AST |
Lines 2705-2715
Link Here
|
2705 |
NormalAnnotation result = new NormalAnnotation(this); |
2741 |
NormalAnnotation result = new NormalAnnotation(this); |
2706 |
return result; |
2742 |
return result; |
2707 |
} |
2743 |
} |
2708 |
|
2744 |
|
2709 |
/** |
2745 |
/** |
2710 |
* Creates and returns a new unparented marker annotation node with |
2746 |
* Creates and returns a new unparented marker annotation node with |
2711 |
* an unspecified type name. |
2747 |
* an unspecified type name. |
2712 |
* |
2748 |
* |
2713 |
* @return a new unparented marker annotation node |
2749 |
* @return a new unparented marker annotation node |
2714 |
* @exception UnsupportedOperationException if this operation is used in |
2750 |
* @exception UnsupportedOperationException if this operation is used in |
2715 |
* a JLS2 AST |
2751 |
* a JLS2 AST |
Lines 2719-2729
Link Here
|
2719 |
MarkerAnnotation result = new MarkerAnnotation(this); |
2755 |
MarkerAnnotation result = new MarkerAnnotation(this); |
2720 |
return result; |
2756 |
return result; |
2721 |
} |
2757 |
} |
2722 |
|
2758 |
|
2723 |
/** |
2759 |
/** |
2724 |
* Creates and returns a new unparented single member annotation node with |
2760 |
* Creates and returns a new unparented single member annotation node with |
2725 |
* an unspecified type name and value. |
2761 |
* an unspecified type name and value. |
2726 |
* |
2762 |
* |
2727 |
* @return a new unparented single member annotation node |
2763 |
* @return a new unparented single member annotation node |
2728 |
* @exception UnsupportedOperationException if this operation is used in |
2764 |
* @exception UnsupportedOperationException if this operation is used in |
2729 |
* a JLS2 AST |
2765 |
* a JLS2 AST |
Lines 2733-2743
Link Here
|
2733 |
SingleMemberAnnotation result = new SingleMemberAnnotation(this); |
2769 |
SingleMemberAnnotation result = new SingleMemberAnnotation(this); |
2734 |
return result; |
2770 |
return result; |
2735 |
} |
2771 |
} |
2736 |
|
2772 |
|
2737 |
/** |
2773 |
/** |
2738 |
* Creates and returns a new unparented member value pair node with |
2774 |
* Creates and returns a new unparented member value pair node with |
2739 |
* an unspecified member name and value. |
2775 |
* an unspecified member name and value. |
2740 |
* |
2776 |
* |
2741 |
* @return a new unparented member value pair node |
2777 |
* @return a new unparented member value pair node |
2742 |
* @exception UnsupportedOperationException if this operation is used in |
2778 |
* @exception UnsupportedOperationException if this operation is used in |
2743 |
* a JLS2 AST |
2779 |
* a JLS2 AST |
Lines 2747-2753
Link Here
|
2747 |
MemberValuePair result = new MemberValuePair(this); |
2783 |
MemberValuePair result = new MemberValuePair(this); |
2748 |
return result; |
2784 |
return result; |
2749 |
} |
2785 |
} |
2750 |
|
2786 |
|
2751 |
/** |
2787 |
/** |
2752 |
* Enables the recording of changes to the given compilation |
2788 |
* Enables the recording of changes to the given compilation |
2753 |
* unit and its descendents. The compilation unit must have |
2789 |
* unit and its descendents. The compilation unit must have |
Lines 2756-2766
Link Here
|
2756 |
* arbitrary changes to the subtree rooted at the compilation |
2792 |
* arbitrary changes to the subtree rooted at the compilation |
2757 |
* unit are recorded internally. Once the modification has |
2793 |
* unit are recorded internally. Once the modification has |
2758 |
* been completed, call <code>rewrite</code> to get an object |
2794 |
* been completed, call <code>rewrite</code> to get an object |
2759 |
* representing the corresponding edits to the original |
2795 |
* representing the corresponding edits to the original |
2760 |
* source code string. |
2796 |
* source code string. |
2761 |
* |
2797 |
* |
2762 |
* @exception IllegalArgumentException if this compilation unit is |
2798 |
* @exception IllegalArgumentException if this compilation unit is |
2763 |
* marked as unmodifiable, or if this compilation unit has already |
2799 |
* marked as unmodifiable, or if this compilation unit has already |
2764 |
* been tampered with, or if recording has already been enabled, |
2800 |
* been tampered with, or if recording has already been enabled, |
2765 |
* or if <code>root</code> is not owned by this AST |
2801 |
* or if <code>root</code> is not owned by this AST |
2766 |
* @see CompilationUnit#recordModifications() |
2802 |
* @see CompilationUnit#recordModifications() |
Lines 2776-2782
Link Here
|
2776 |
} else if(root.getAST() != this) { |
2812 |
} else if(root.getAST() != this) { |
2777 |
throw new IllegalArgumentException("Root node is not owned by this ast"); //$NON-NLS-1$ |
2813 |
throw new IllegalArgumentException("Root node is not owned by this ast"); //$NON-NLS-1$ |
2778 |
} |
2814 |
} |
2779 |
|
2815 |
|
2780 |
this.rewriter = new InternalASTRewrite(root); |
2816 |
this.rewriter = new InternalASTRewrite(root); |
2781 |
this.setEventHandler(this.rewriter); |
2817 |
this.setEventHandler(this.rewriter); |
2782 |
} |
2818 |
} |
Lines 2787-2793
Link Here
|
2787 |
* given document containing the original source |
2823 |
* given document containing the original source |
2788 |
* code for the compilation unit that gave rise to |
2824 |
* code for the compilation unit that gave rise to |
2789 |
* this AST. |
2825 |
* this AST. |
2790 |
* |
2826 |
* |
2791 |
* @param document original document containing source code |
2827 |
* @param document original document containing source code |
2792 |
* for the compilation unit |
2828 |
* for the compilation unit |
2793 |
* @param options the table of formatter options |
2829 |
* @param options the table of formatter options |
Lines 2812-2816
Link Here
|
2812 |
} |
2848 |
} |
2813 |
return this.rewriter.rewriteAST(document, options); |
2849 |
return this.rewriter.rewriteAST(document, options); |
2814 |
} |
2850 |
} |
|
|
2851 |
|
2852 |
void setFlag(int newValue) { |
2853 |
this.bits |= newValue; |
2854 |
} |
2815 |
} |
2855 |
} |
2816 |
|
2856 |
|