Lines 30-39
Link Here
|
30 |
* This interface is not intended to be implemented by clients. |
30 |
* This interface is not intended to be implemented by clients. |
31 |
* </p> |
31 |
* </p> |
32 |
*/ |
32 |
*/ |
33 |
public interface ICompilationUnit extends IJavaElement, ISourceReference, IParent, IOpenable, IWorkingCopy, ISourceManipulation, ICodeAssist { |
33 |
public interface ICompilationUnit extends IJavaFile, IWorkingCopy, ISourceManipulation { |
34 |
/** |
34 |
/** |
35 |
* Constant indicating that a reconcile operation should not return an AST. |
35 |
* Constant indicating that a reconcile operation should not return an AST. |
36 |
* @since 3.0 |
36 |
* @since 3.0 |
|
|
37 |
* |
38 |
* @deprecated |
37 |
*/ |
39 |
*/ |
38 |
public static final int NO_AST = 0; |
40 |
public static final int NO_AST = 0; |
39 |
|
41 |
|
Lines 67-74
Link Here
|
67 |
* @throws JavaModelException if this compilation unit could not become a working copy. |
69 |
* @throws JavaModelException if this compilation unit could not become a working copy. |
68 |
* @see #discardWorkingCopy() |
70 |
* @see #discardWorkingCopy() |
69 |
* @since 3.0 |
71 |
* @since 3.0 |
|
|
72 |
* |
73 |
* @deprecated Use {@link #becomeWorkingCopy(IProgressMonitor)} instead which uses the |
74 |
* {@IProblemRequestor problem requestor} defined by this compilation units working copy owner |
75 |
* (see {@link WorkingCopyOwner#getProblemRequestor()}). |
70 |
*/ |
76 |
*/ |
71 |
void becomeWorkingCopy(IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException; |
77 |
void becomeWorkingCopy(IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException; |
|
|
78 |
|
79 |
/** |
80 |
* Makes sure this compilation unit handle is in a working copy mode, say an {@link IBuffer} is |
81 |
* created using this compilation units working copy owner. |
82 |
* This method only has an effect if the compilation is a primary compilation unit ({@link ICompilationUnit#isPrimary()} |
83 |
* as only primary working copies can be in a non-working copy state. |
84 |
* <p> |
85 |
* For each call to this API, regardless if this compilation unit was already a working copy or not, |
86 |
* an internal reference counter is incremented. As long as this reference counter is not 0, the buffer is kept in memory. |
87 |
* </p> |
88 |
* <p> |
89 |
* To bring this compilation unit back into the original mode (where it reflects the underlying resource) and to |
90 |
* to release the buffer, {@link #discardWorkingCopy} must be called as many |
91 |
* times as {@link #becomeWorkingCopy(IProgressMonitor)}. |
92 |
* </p> |
93 |
* <p> |
94 |
* Once in working copy mode, changes to this compilation unit or its children are done in memory. |
95 |
* Only the buffer is affected. Using {@link #commitWorkingCopy(boolean, IProgressMonitor)} |
96 |
* will bring the underlying resource in sync with this compilation unit. {@link #commitWorkingCopy(boolean, IProgressMonitor)} |
97 |
* does not modify the internal reference counter. |
98 |
* </p> |
99 |
* |
100 |
* @param monitor a progress monitor used to report progress while opening this compilation unit |
101 |
* or <code>null</code> if no progress should be reported |
102 |
* @throws JavaModelException if this compilation unit could not become a working copy. |
103 |
* @see #discardWorkingCopy() |
104 |
* |
105 |
* @since 3.3 |
106 |
*/ |
107 |
void becomeWorkingCopy(IProgressMonitor monitor) throws JavaModelException; |
108 |
|
72 |
/** |
109 |
/** |
73 |
* Commits the contents of this working copy to its underlying resource. |
110 |
* Commits the contents of this working copy to its underlying resource. |
74 |
* |
111 |
* |
Lines 223-235
Link Here
|
223 |
* This has no effect if this compilation unit was not in working copy mode. |
260 |
* This has no effect if this compilation unit was not in working copy mode. |
224 |
* </p> |
261 |
* </p> |
225 |
* <p> |
262 |
* <p> |
226 |
* If {@link #becomeWorkingCopy} was called several times on this |
263 |
* If {@link #becomeWorkingCopy(IProgressMonitor)} was called several times on this |
227 |
* compilation unit, {@link #discardWorkingCopy} must be called as |
264 |
* compilation unit, {@link #discardWorkingCopy} must be called as |
228 |
* many times before it switches back to the original mode. |
265 |
* many times before it switches back to the original mode. |
229 |
* </p> |
266 |
* </p> |
|
|
267 |
* <p>{@link #discardWorkingCopy} also has to be called on each compilation unit returned by |
268 |
* {@link #getWorkingCopy(WorkingCopyOwner, IProgressMonitor)}. |
269 |
* </p> |
230 |
* |
270 |
* |
231 |
* @throws JavaModelException if this working copy could not return in its original mode. |
271 |
* @throws JavaModelException if this working copy could not return in its original mode. |
232 |
* @see #becomeWorkingCopy(IProblemRequestor, IProgressMonitor) |
272 |
* @see #becomeWorkingCopy(IProgressMonitor) |
|
|
273 |
* @see #getWorkingCopy(WorkingCopyOwner, IProgressMonitor) |
233 |
* @since 3.0 |
274 |
* @since 3.0 |
234 |
*/ |
275 |
*/ |
235 |
void discardWorkingCopy() throws JavaModelException; |
276 |
void discardWorkingCopy() throws JavaModelException; |
Lines 286-305
Link Here
|
286 |
*/ |
327 |
*/ |
287 |
IType[] getAllTypes() throws JavaModelException; |
328 |
IType[] getAllTypes() throws JavaModelException; |
288 |
/** |
329 |
/** |
289 |
* Returns the smallest element within this compilation unit that |
|
|
290 |
* includes the given source position (that is, a method, field, etc.), or |
291 |
* <code>null</code> if there is no element other than the compilation |
292 |
* unit itself at the given position, or if the given position is not |
293 |
* within the source range of this compilation unit. |
294 |
* |
295 |
* @param position a source position inside the compilation unit |
296 |
* @return the innermost Java element enclosing a given source position or <code>null</code> |
297 |
* if none (excluding the compilation unit). |
298 |
* @throws JavaModelException if the compilation unit does not exist or if an |
299 |
* exception occurs while accessing its corresponding resource |
300 |
*/ |
301 |
IJavaElement getElementAt(int position) throws JavaModelException; |
302 |
/** |
303 |
* Returns the first import declaration in this compilation unit with the given name. |
330 |
* Returns the first import declaration in this compilation unit with the given name. |
304 |
* This is a handle-only method. The import declaration may or may not exist. This |
331 |
* This is a handle-only method. The import declaration may or may not exist. This |
305 |
* is a convenience method - imports can also be accessed from a compilation unit's |
332 |
* is a convenience method - imports can also be accessed from a compilation unit's |
Lines 344-351
Link Here
|
344 |
*/ |
371 |
*/ |
345 |
ICompilationUnit getPrimary(); |
372 |
ICompilationUnit getPrimary(); |
346 |
/** |
373 |
/** |
347 |
* Returns the working copy owner of this working copy. |
374 |
* Returns the working copy owner of this working copy or <code>null</code> if this compilation unit is managed by the |
348 |
* Returns null if it is not a working copy or if it has no owner. |
375 |
* primary owner. |
349 |
* |
376 |
* |
350 |
* @return WorkingCopyOwner the owner of this working copy or <code>null</code> |
377 |
* @return WorkingCopyOwner the owner of this working copy or <code>null</code> |
351 |
* @since 3.0 |
378 |
* @since 3.0 |
Lines 415-420
Link Here
|
415 |
* @return a new working copy of this element if this element is not |
442 |
* @return a new working copy of this element if this element is not |
416 |
* a working copy, or this element if this element is already a working copy |
443 |
* a working copy, or this element if this element is already a working copy |
417 |
* @since 3.0 |
444 |
* @since 3.0 |
|
|
445 |
* |
446 |
* @deprecated use {@link #getWorkingCopy(WorkingCopyOwner, IProgressMonitor)} instead with a own instance of a working copy |
447 |
* owner. |
418 |
*/ |
448 |
*/ |
419 |
ICompilationUnit getWorkingCopy(IProgressMonitor monitor) throws JavaModelException; |
449 |
ICompilationUnit getWorkingCopy(IProgressMonitor monitor) throws JavaModelException; |
420 |
/** |
450 |
/** |
Lines 457-462
Link Here
|
457 |
* @return a new working copy of this element using the given factory to create |
487 |
* @return a new working copy of this element using the given factory to create |
458 |
* the buffer, or this element if this element is already a working copy |
488 |
* the buffer, or this element if this element is already a working copy |
459 |
* @since 3.0 |
489 |
* @since 3.0 |
|
|
490 |
* |
491 |
* @deprecated Use {@link IJavaFile#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)} instead |
460 |
*/ |
492 |
*/ |
461 |
ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException; |
493 |
ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException; |
462 |
/** |
494 |
/** |
Lines 469-475
Link Here
|
469 |
*/ |
501 |
*/ |
470 |
public boolean hasResourceChanged(); |
502 |
public boolean hasResourceChanged(); |
471 |
/** |
503 |
/** |
472 |
* Returns whether this element is a working copy. |
504 |
* Returns true if this compilation is managed by the primary owner. The primary owner |
|
|
505 |
* typically contains the elements as seen in the file system or by the shared buffer. |
506 |
* All non-primary files belong to a custom woking copy ower that typically contains some |
507 |
* selected elements in a working state and inherits all other elements from the primary buffer. |
508 |
* |
509 |
* @return returns true if this compilation is managed by the primary owner |
510 |
* |
511 |
* @since 3.3 |
512 |
*/ |
513 |
boolean isPrimary(); |
514 |
/** |
515 |
* Returns whether this element is a working copy. A woking copy is either a compilation unit with a non-primary |
516 |
* woking copy woner, or a primary compilation unit in buffered state. |
473 |
* |
517 |
* |
474 |
* @return true if this element is a working copy, false otherwise |
518 |
* @return true if this element is a working copy, false otherwise |
475 |
* @since 3.0 |
519 |
* @since 3.0 |
Lines 536-541
Link Here
|
536 |
* <li> The original Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li> |
580 |
* <li> The original Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li> |
537 |
* </ul> |
581 |
* </ul> |
538 |
* @since 3.0 |
582 |
* @since 3.0 |
|
|
583 |
* |
584 |
* @deprecated use {@link #reconcile(boolean, WorkingCopyOwner, IProgressMonitor)} instead and use the AST as specified by |
585 |
* {@link WorkingCopyOwner}. Using this API can result in performance degradation if the requested AST is |
586 |
* incompatible to the one configured in the {@link WorkingCopyOwner}. |
539 |
*/ |
587 |
*/ |
540 |
CompilationUnit reconcile(int astLevel, boolean forceProblemDetection, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException; |
588 |
CompilationUnit reconcile(int astLevel, boolean forceProblemDetection, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException; |
541 |
|
589 |
|
Lines 601-610
Link Here
|
601 |
* <li> The original Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li> |
649 |
* <li> The original Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li> |
602 |
* </ul> |
650 |
* </ul> |
603 |
* @since 3.2 |
651 |
* @since 3.2 |
|
|
652 |
* |
653 |
* @deprecated Use {@link #reconcile(boolean, WorkingCopyOwner, IProgressMonitor)} instead and use the AST as specified by |
654 |
* {@link WorkingCopyOwner}. Using this API can result in performance degradation if the requested AST is |
655 |
* incompatible to the one configured in the {@link WorkingCopyOwner}. |
604 |
*/ |
656 |
*/ |
605 |
CompilationUnit reconcile(int astLevel, boolean forceProblemDetection, boolean enableStatementsRecovery, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException; |
657 |
CompilationUnit reconcile(int astLevel, boolean forceProblemDetection, boolean enableStatementsRecovery, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException; |
606 |
|
658 |
|
607 |
/** |
659 |
/** |
|
|
660 |
* Reconciles the contents of this working copy, sends out a Java delta |
661 |
* notification indicating the nature of the change of the working copy since |
662 |
* the last time it was either reconciled or made consistent |
663 |
* ({@link IOpenable#makeConsistent(IProgressMonitor)}), and returns a |
664 |
* compilation unit AST if requested. |
665 |
* <p> |
666 |
* It performs the reconciliation by locally caching the contents of |
667 |
* the working copy, updating the contents, then creating a delta |
668 |
* over the cached contents and the new contents, and finally firing |
669 |
* this delta. |
670 |
* <p> |
671 |
* The boolean argument allows to force problem detection even if the |
672 |
* working copy is already consistent. |
673 |
* </p> |
674 |
* <p> |
675 |
* This functionality allows to specify a working copy owner which is used |
676 |
* during problem detection. All references contained in the working copy are |
677 |
* resolved against other units; for which corresponding owned working copies |
678 |
* are going to take precedence over their original compilation units. If |
679 |
* <code>null</code> is passed in, then the primary working copy owner is used. |
680 |
* </p> |
681 |
* <p> |
682 |
* If the working copy owner defines a problem requestor (see {@link WorkingCopyOwner#getProblemRequestor()}) |
683 |
* all compilation problems found in the new contents are reported to the requestor. |
684 |
* </p> |
685 |
* <p> |
686 |
* If the working copy owner defines that an AST should be build (see {@link WorkingCopyOwner#getReconcileASTKind()}) |
687 |
* the created AST using the given parameters (see {@link WorkingCopyOwner#getReconcileASTRecoverStatements()}, {@link WorkingCopyOwner#getReconcileASTResolveBindings()}) |
688 |
* is returned by this method and also reported in the Java delta notification (see {@link IJavaElementDelta#getCompilationUnitAST()}). |
689 |
* </p> |
690 |
* <p> |
691 |
* Note: Since 3.0, added/removed/changed inner types generate change deltas. |
692 |
* </p> |
693 |
* @param forceProblemDetection boolean indicating whether problem should be |
694 |
* recomputed even if the source hasn't changed |
695 |
* @param owner the owner of working copies that take precedence over the |
696 |
* original compilation units, or <code>null</code> if the primary working |
697 |
* copy owner should be used |
698 |
* @param monitor a progress monitor |
699 |
* @return the compilation unit AST as configured by the {@link WorkingCopyOwner} or <code>null</code> |
700 |
* or the working copy did not request an AST. |
701 |
* @throws JavaModelException if the contents of the original element |
702 |
* cannot be accessed. Reasons include: |
703 |
* <ul> |
704 |
* <li> The original Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li> |
705 |
* </ul> |
706 |
* |
707 |
* @since 3.3 |
708 |
*/ |
709 |
CompilationUnit reconcile(boolean forceProblemDetection, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException; |
710 |
|
711 |
/** |
608 |
* Restores the contents of this working copy to the current contents of |
712 |
* Restores the contents of this working copy to the current contents of |
609 |
* this working copy's original element. Has no effect if this element |
713 |
* this working copy's original element. Has no effect if this element |
610 |
* is not a working copy. |
714 |
* is not a working copy. |