Lines 54-60
Link Here
|
54 |
this.name = name; |
54 |
this.name = name; |
55 |
this.owner = owner; |
55 |
this.owner = owner; |
56 |
} |
56 |
} |
57 |
/* |
57 |
/* (non-Javadoc) |
58 |
* @see ICompilationUnit#becomeWorkingCopy(IProblemRequestor, IProgressMonitor) |
58 |
* @see ICompilationUnit#becomeWorkingCopy(IProblemRequestor, IProgressMonitor) |
59 |
*/ |
59 |
*/ |
60 |
public void becomeWorkingCopy(IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException { |
60 |
public void becomeWorkingCopy(IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException { |
Lines 68-73
Link Here
|
68 |
operation.runOperation(monitor); |
68 |
operation.runOperation(monitor); |
69 |
} |
69 |
} |
70 |
} |
70 |
} |
|
|
71 |
/* (non-Javadoc) |
72 |
* @see org.eclipse.jdt.core.ICompilationUnit#becomeWorkingCopy(org.eclipse.core.runtime.IProgressMonitor) |
73 |
*/ |
74 |
public void becomeWorkingCopy(IProgressMonitor monitor) throws JavaModelException { |
75 |
becomeWorkingCopy(this.owner.getProblemRequestor(), monitor); |
76 |
} |
71 |
protected boolean buildStructure(OpenableElementInfo info, final IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { |
77 |
protected boolean buildStructure(OpenableElementInfo info, final IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { |
72 |
|
78 |
|
73 |
// check if this compilation unit can be opened |
79 |
// check if this compilation unit can be opened |
Lines 196-222
Link Here
|
196 |
|
202 |
|
197 |
return unitInfo.isStructureKnown(); |
203 |
return unitInfo.isStructureKnown(); |
198 |
} |
204 |
} |
199 |
/* |
205 |
/* (non-Javadoc) |
200 |
* @see Openable#canBeRemovedFromCache |
206 |
* @see Openable#canBeRemovedFromCache |
201 |
*/ |
207 |
*/ |
202 |
public boolean canBeRemovedFromCache() { |
208 |
public boolean canBeRemovedFromCache() { |
203 |
if (getPerWorkingCopyInfo() != null) return false; // working copies should remain in the cache until they are destroyed |
209 |
if (getPerWorkingCopyInfo() != null) return false; // working copies should remain in the cache until they are destroyed |
204 |
return super.canBeRemovedFromCache(); |
210 |
return super.canBeRemovedFromCache(); |
205 |
} |
211 |
} |
206 |
/* |
212 |
/* (non-Javadoc) |
207 |
* @see Openable#canBufferBeRemovedFromCache |
213 |
* @see Openable#canBufferBeRemovedFromCache |
208 |
*/ |
214 |
*/ |
209 |
public boolean canBufferBeRemovedFromCache(IBuffer buffer) { |
215 |
public boolean canBufferBeRemovedFromCache(IBuffer buffer) { |
210 |
if (getPerWorkingCopyInfo() != null) return false; // working copy buffers should remain in the cache until working copy is destroyed |
216 |
if (getPerWorkingCopyInfo() != null) return false; // working copy buffers should remain in the cache until working copy is destroyed |
211 |
return super.canBufferBeRemovedFromCache(buffer); |
217 |
return super.canBufferBeRemovedFromCache(buffer); |
212 |
}/* |
218 |
} |
|
|
219 |
/* (non-Javadoc) |
213 |
* @see IOpenable#close |
220 |
* @see IOpenable#close |
214 |
*/ |
221 |
*/ |
215 |
public void close() throws JavaModelException { |
222 |
public void close() throws JavaModelException { |
216 |
if (getPerWorkingCopyInfo() != null) return; // a working copy must remain opened until it is discarded |
223 |
if (getPerWorkingCopyInfo() != null) return; // a working copy must remain opened until it is discarded |
217 |
super.close(); |
224 |
super.close(); |
218 |
} |
225 |
} |
219 |
/* |
226 |
/* (non-Javadoc) |
220 |
* @see Openable#closing |
227 |
* @see Openable#closing |
221 |
*/ |
228 |
*/ |
222 |
protected void closing(Object info) { |
229 |
protected void closing(Object info) { |
Lines 224-239
Link Here
|
224 |
super.closing(info); |
231 |
super.closing(info); |
225 |
} // else the buffer of a working copy must remain open for the lifetime of the working copy |
232 |
} // else the buffer of a working copy must remain open for the lifetime of the working copy |
226 |
} |
233 |
} |
|
|
234 |
|
235 |
/* (non-Javadoc) |
236 |
* @see org.eclipse.jdt.core.ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) |
237 |
*/ |
238 |
public void codeComplete(int offset, CompletionRequestor requestor) throws JavaModelException { |
239 |
codeComplete(offset, requestor, DefaultWorkingCopyOwner.PRIMARY); |
240 |
} |
241 |
|
242 |
/* (non-Javadoc) |
243 |
* @see org.eclipse.jdt.core.ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor, org.eclipse.jdt.core.WorkingCopyOwner) |
244 |
*/ |
245 |
public void codeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner workingCopyOwner) throws JavaModelException { |
246 |
codeComplete(this, isWorkingCopy() ? (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) getOriginalElement() : this, offset, requestor, workingCopyOwner); |
247 |
} |
248 |
|
227 |
/** |
249 |
/** |
228 |
* @see ICodeAssist#codeComplete(int, ICompletionRequestor) |
250 |
* @see ICodeAssist#codeComplete(int, ICompletionRequestor) |
229 |
* @deprecated |
251 |
* @deprecated As it use deprecated requestor |
230 |
*/ |
252 |
*/ |
231 |
public void codeComplete(int offset, ICompletionRequestor requestor) throws JavaModelException { |
253 |
public void codeComplete(int offset, ICompletionRequestor requestor) throws JavaModelException { |
232 |
codeComplete(offset, requestor, DefaultWorkingCopyOwner.PRIMARY); |
254 |
codeComplete(offset, requestor, DefaultWorkingCopyOwner.PRIMARY); |
233 |
} |
255 |
} |
234 |
/** |
256 |
/** |
235 |
* @see ICodeAssist#codeComplete(int, ICompletionRequestor, WorkingCopyOwner) |
257 |
* @see ICodeAssist#codeComplete(int, ICompletionRequestor, WorkingCopyOwner) |
236 |
* @deprecated |
258 |
* @deprecated As it use deprecated requestor |
237 |
*/ |
259 |
*/ |
238 |
public void codeComplete(int offset, ICompletionRequestor requestor, WorkingCopyOwner workingCopyOwner) throws JavaModelException { |
260 |
public void codeComplete(int offset, ICompletionRequestor requestor, WorkingCopyOwner workingCopyOwner) throws JavaModelException { |
239 |
if (requestor == null) { |
261 |
if (requestor == null) { |
Lines 243-249
Link Here
|
243 |
} |
265 |
} |
244 |
/** |
266 |
/** |
245 |
* @see ICodeAssist#codeComplete(int, ICodeCompletionRequestor) |
267 |
* @see ICodeAssist#codeComplete(int, ICodeCompletionRequestor) |
246 |
* @deprecated - use codeComplete(int, ICompletionRequestor) |
268 |
* @deprecated As it use deprecated requestor |
247 |
*/ |
269 |
*/ |
248 |
public void codeComplete(int offset, final ICodeCompletionRequestor requestor) throws JavaModelException { |
270 |
public void codeComplete(int offset, final ICodeCompletionRequestor requestor) throws JavaModelException { |
249 |
|
271 |
|
Lines 301-346
Link Here
|
301 |
} |
323 |
} |
302 |
|
324 |
|
303 |
/* (non-Javadoc) |
325 |
/* (non-Javadoc) |
304 |
* @see org.eclipse.jdt.core.ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) |
|
|
305 |
*/ |
306 |
public void codeComplete(int offset, CompletionRequestor requestor) throws JavaModelException { |
307 |
codeComplete(offset, requestor, DefaultWorkingCopyOwner.PRIMARY); |
308 |
} |
309 |
|
310 |
/* (non-Javadoc) |
311 |
* @see org.eclipse.jdt.core.ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor, org.eclipse.jdt.core.WorkingCopyOwner) |
312 |
*/ |
313 |
public void codeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner workingCopyOwner) throws JavaModelException { |
314 |
codeComplete(this, isWorkingCopy() ? (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) getOriginalElement() : this, offset, requestor, workingCopyOwner); |
315 |
} |
316 |
|
317 |
/** |
318 |
* @see ICodeAssist#codeSelect(int, int) |
326 |
* @see ICodeAssist#codeSelect(int, int) |
319 |
*/ |
327 |
*/ |
320 |
public IJavaElement[] codeSelect(int offset, int length) throws JavaModelException { |
328 |
public IJavaElement[] codeSelect(int offset, int length) throws JavaModelException { |
321 |
return codeSelect(offset, length, DefaultWorkingCopyOwner.PRIMARY); |
329 |
return codeSelect(offset, length, DefaultWorkingCopyOwner.PRIMARY); |
322 |
} |
330 |
} |
323 |
/** |
331 |
/* (non-Javadoc) |
324 |
* @see ICodeAssist#codeSelect(int, int, WorkingCopyOwner) |
332 |
* @see ICodeAssist#codeSelect(int, int, WorkingCopyOwner) |
325 |
*/ |
333 |
*/ |
326 |
public IJavaElement[] codeSelect(int offset, int length, WorkingCopyOwner workingCopyOwner) throws JavaModelException { |
334 |
public IJavaElement[] codeSelect(int offset, int length, WorkingCopyOwner workingCopyOwner) throws JavaModelException { |
327 |
return super.codeSelect(this, offset, length, workingCopyOwner); |
335 |
return super.codeSelect(this, offset, length, workingCopyOwner); |
328 |
} |
336 |
} |
329 |
/** |
337 |
/* (non-Javadoc) |
330 |
* @see IWorkingCopy#commit(boolean, IProgressMonitor) |
338 |
* @see IWorkingCopy#commit(boolean, IProgressMonitor) |
331 |
* @deprecated |
|
|
332 |
*/ |
339 |
*/ |
333 |
public void commit(boolean force, IProgressMonitor monitor) throws JavaModelException { |
340 |
public void commit(boolean force, IProgressMonitor monitor) throws JavaModelException { |
334 |
commitWorkingCopy(force, monitor); |
341 |
commitWorkingCopy(force, monitor); |
335 |
} |
342 |
} |
336 |
/** |
343 |
/* (non-Javadoc) |
337 |
* @see ICompilationUnit#commitWorkingCopy(boolean, IProgressMonitor) |
344 |
* @see ICompilationUnit#commitWorkingCopy(boolean, IProgressMonitor) |
338 |
*/ |
345 |
*/ |
339 |
public void commitWorkingCopy(boolean force, IProgressMonitor monitor) throws JavaModelException { |
346 |
public void commitWorkingCopy(boolean force, IProgressMonitor monitor) throws JavaModelException { |
340 |
CommitWorkingCopyOperation op= new CommitWorkingCopyOperation(this, force); |
347 |
CommitWorkingCopyOperation op= new CommitWorkingCopyOperation(this, force); |
341 |
op.runOperation(monitor); |
348 |
op.runOperation(monitor); |
342 |
} |
349 |
} |
343 |
/** |
350 |
/* (non-Javadoc) |
344 |
* @see ISourceManipulation#copy(IJavaElement, IJavaElement, String, boolean, IProgressMonitor) |
351 |
* @see ISourceManipulation#copy(IJavaElement, IJavaElement, String, boolean, IProgressMonitor) |
345 |
*/ |
352 |
*/ |
346 |
public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException { |
353 |
public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException { |
Lines 355-376
Link Here
|
355 |
} |
362 |
} |
356 |
getJavaModel().copy(elements, containers, null, renamings, force, monitor); |
363 |
getJavaModel().copy(elements, containers, null, renamings, force, monitor); |
357 |
} |
364 |
} |
358 |
/** |
365 |
/* (non-Javadoc) |
359 |
* Returns a new element info for this element. |
366 |
* @see org.eclipse.jdt.internal.core.Openable#createElementInfo() |
360 |
*/ |
367 |
*/ |
361 |
protected Object createElementInfo() { |
368 |
protected Object createElementInfo() { |
362 |
return new CompilationUnitElementInfo(); |
369 |
return new CompilationUnitElementInfo(); |
363 |
} |
370 |
} |
364 |
/** |
371 |
/* (non-Javadoc) |
365 |
* @see ICompilationUnit#createImport(String, IJavaElement, IProgressMonitor) |
372 |
* @see ICompilationUnit#createImport(String, IJavaElement, IProgressMonitor) |
366 |
*/ |
373 |
*/ |
367 |
public IImportDeclaration createImport(String importName, IJavaElement sibling, IProgressMonitor monitor) throws JavaModelException { |
374 |
public IImportDeclaration createImport(String importName, IJavaElement sibling, IProgressMonitor monitor) throws JavaModelException { |
368 |
return createImport(importName, sibling, Flags.AccDefault, monitor); |
375 |
return createImport(importName, sibling, Flags.AccDefault, monitor); |
369 |
} |
376 |
} |
370 |
|
377 |
|
371 |
/** |
378 |
/* (non-Javadoc) |
372 |
* @see ICompilationUnit#createImport(String, IJavaElement, int, IProgressMonitor) |
379 |
* @see ICompilationUnit#createImport(String, IJavaElement, int, IProgressMonitor) |
373 |
* @since 3.0 |
|
|
374 |
*/ |
380 |
*/ |
375 |
public IImportDeclaration createImport(String importName, IJavaElement sibling, int flags, IProgressMonitor monitor) throws JavaModelException { |
381 |
public IImportDeclaration createImport(String importName, IJavaElement sibling, int flags, IProgressMonitor monitor) throws JavaModelException { |
376 |
CreateImportOperation op = new CreateImportOperation(importName, this, flags); |
382 |
CreateImportOperation op = new CreateImportOperation(importName, this, flags); |
Lines 381-387
Link Here
|
381 |
return getImport(importName); |
387 |
return getImport(importName); |
382 |
} |
388 |
} |
383 |
|
389 |
|
384 |
/** |
390 |
/* (non-Javadoc) |
385 |
* @see ICompilationUnit#createPackageDeclaration(String, IProgressMonitor) |
391 |
* @see ICompilationUnit#createPackageDeclaration(String, IProgressMonitor) |
386 |
*/ |
392 |
*/ |
387 |
public IPackageDeclaration createPackageDeclaration(String pkg, IProgressMonitor monitor) throws JavaModelException { |
393 |
public IPackageDeclaration createPackageDeclaration(String pkg, IProgressMonitor monitor) throws JavaModelException { |
Lines 390-396
Link Here
|
390 |
op.runOperation(monitor); |
396 |
op.runOperation(monitor); |
391 |
return getPackageDeclaration(pkg); |
397 |
return getPackageDeclaration(pkg); |
392 |
} |
398 |
} |
393 |
/** |
399 |
/* (non-Javadoc) |
394 |
* @see ICompilationUnit#createType(String, IJavaElement, boolean, IProgressMonitor) |
400 |
* @see ICompilationUnit#createType(String, IJavaElement, boolean, IProgressMonitor) |
395 |
*/ |
401 |
*/ |
396 |
public IType createType(String content, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { |
402 |
public IType createType(String content, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { |
Lines 413-428
Link Here
|
413 |
op.runOperation(monitor); |
419 |
op.runOperation(monitor); |
414 |
return (IType) op.getResultElements()[0]; |
420 |
return (IType) op.getResultElements()[0]; |
415 |
} |
421 |
} |
416 |
/** |
422 |
/* (non-Javadoc) |
417 |
* @see ISourceManipulation#delete(boolean, IProgressMonitor) |
423 |
* @see ISourceManipulation#delete(boolean, IProgressMonitor) |
418 |
*/ |
424 |
*/ |
419 |
public void delete(boolean force, IProgressMonitor monitor) throws JavaModelException { |
425 |
public void delete(boolean force, IProgressMonitor monitor) throws JavaModelException { |
420 |
IJavaElement[] elements= new IJavaElement[] {this}; |
426 |
IJavaElement[] elements= new IJavaElement[] {this}; |
421 |
getJavaModel().delete(elements, force, monitor); |
427 |
getJavaModel().delete(elements, force, monitor); |
422 |
} |
428 |
} |
423 |
/** |
429 |
/* (non-Javadoc) |
424 |
* @see IWorkingCopy#destroy() |
430 |
* @see IWorkingCopy#destroy() |
425 |
* @deprecated |
|
|
426 |
*/ |
431 |
*/ |
427 |
public void destroy() { |
432 |
public void destroy() { |
428 |
try { |
433 |
try { |
Lines 432-438
Link Here
|
432 |
e.printStackTrace(); |
437 |
e.printStackTrace(); |
433 |
} |
438 |
} |
434 |
} |
439 |
} |
435 |
/* |
440 |
/* (non-Javadoc) |
436 |
* @see ICompilationUnit#discardWorkingCopy |
441 |
* @see ICompilationUnit#discardWorkingCopy |
437 |
*/ |
442 |
*/ |
438 |
public void discardWorkingCopy() throws JavaModelException { |
443 |
public void discardWorkingCopy() throws JavaModelException { |
Lines 440-446
Link Here
|
440 |
DiscardWorkingCopyOperation op = new DiscardWorkingCopyOperation(this); |
445 |
DiscardWorkingCopyOperation op = new DiscardWorkingCopyOperation(this); |
441 |
op.runOperation(null); |
446 |
op.runOperation(null); |
442 |
} |
447 |
} |
443 |
/** |
448 |
/* (non-Javadoc) |
444 |
* Returns true if this handle represents the same Java element |
449 |
* Returns true if this handle represents the same Java element |
445 |
* as the given handle. |
450 |
* as the given handle. |
446 |
* |
451 |
* |
Lines 451-456
Link Here
|
451 |
CompilationUnit other = (CompilationUnit)obj; |
456 |
CompilationUnit other = (CompilationUnit)obj; |
452 |
return this.owner.equals(other.owner) && super.equals(obj); |
457 |
return this.owner.equals(other.owner) && super.equals(obj); |
453 |
} |
458 |
} |
|
|
459 |
/* (non-Javadoc) |
460 |
* @see org.eclipse.jdt.internal.core.Openable#exists() |
461 |
*/ |
454 |
public boolean exists() { |
462 |
public boolean exists() { |
455 |
// working copy always exists in the model until it is gotten rid of (even if not on classpath) |
463 |
// working copy always exists in the model until it is gotten rid of (even if not on classpath) |
456 |
if (getPerWorkingCopyInfo() != null) return true; |
464 |
if (getPerWorkingCopyInfo() != null) return true; |
Lines 458-464
Link Here
|
458 |
// if not a working copy, it exists only if it is a primary compilation unit |
466 |
// if not a working copy, it exists only if it is a primary compilation unit |
459 |
return isPrimary() && validateCompilationUnit(getResource()).isOK(); |
467 |
return isPrimary() && validateCompilationUnit(getResource()).isOK(); |
460 |
} |
468 |
} |
461 |
/** |
469 |
/* (non-Javadoc) |
462 |
* @see ICompilationUnit#findElements(IJavaElement) |
470 |
* @see ICompilationUnit#findElements(IJavaElement) |
463 |
*/ |
471 |
*/ |
464 |
public IJavaElement[] findElements(IJavaElement element) { |
472 |
public IJavaElement[] findElements(IJavaElement element) { |
Lines 514-520
Link Here
|
514 |
return null; |
522 |
return null; |
515 |
} |
523 |
} |
516 |
} |
524 |
} |
517 |
/** |
525 |
/* (non-Javadoc) |
518 |
* @see ICompilationUnit#findPrimaryType() |
526 |
* @see ICompilationUnit#findPrimaryType() |
519 |
*/ |
527 |
*/ |
520 |
public IType findPrimaryType() { |
528 |
public IType findPrimaryType() { |
Lines 528-534
Link Here
|
528 |
|
536 |
|
529 |
/** |
537 |
/** |
530 |
* @see IWorkingCopy#findSharedWorkingCopy(IBufferFactory) |
538 |
* @see IWorkingCopy#findSharedWorkingCopy(IBufferFactory) |
531 |
* @deprecated |
539 |
* @deprecated As it use a deprecated interface |
532 |
*/ |
540 |
*/ |
533 |
public IJavaElement findSharedWorkingCopy(IBufferFactory factory) { |
541 |
public IJavaElement findSharedWorkingCopy(IBufferFactory factory) { |
534 |
|
542 |
|
Lines 538-544
Link Here
|
538 |
return findWorkingCopy(BufferFactoryWrapper.create(factory)); |
546 |
return findWorkingCopy(BufferFactoryWrapper.create(factory)); |
539 |
} |
547 |
} |
540 |
|
548 |
|
541 |
/** |
549 |
/* (non-Javadoc) |
542 |
* @see ICompilationUnit#findWorkingCopy(WorkingCopyOwner) |
550 |
* @see ICompilationUnit#findWorkingCopy(WorkingCopyOwner) |
543 |
*/ |
551 |
*/ |
544 |
public ICompilationUnit findWorkingCopy(WorkingCopyOwner workingCopyOwner) { |
552 |
public ICompilationUnit findWorkingCopy(WorkingCopyOwner workingCopyOwner) { |
Lines 555-561
Link Here
|
555 |
} |
563 |
} |
556 |
} |
564 |
} |
557 |
} |
565 |
} |
558 |
/** |
566 |
/* (non-Javadoc) |
559 |
* @see ICompilationUnit#getAllTypes() |
567 |
* @see ICompilationUnit#getAllTypes() |
560 |
*/ |
568 |
*/ |
561 |
public IType[] getAllTypes() throws JavaModelException { |
569 |
public IType[] getAllTypes() throws JavaModelException { |
Lines 579-591
Link Here
|
579 |
allTypes.toArray(arrayOfAllTypes); |
587 |
allTypes.toArray(arrayOfAllTypes); |
580 |
return arrayOfAllTypes; |
588 |
return arrayOfAllTypes; |
581 |
} |
589 |
} |
582 |
/** |
590 |
/* (non-Javadoc) |
583 |
* @see IMember#getCompilationUnit() |
591 |
* @see org.eclipse.jdt.internal.core.JavaElement#getCompilationUnit() |
584 |
*/ |
592 |
*/ |
585 |
public ICompilationUnit getCompilationUnit() { |
593 |
public ICompilationUnit getCompilationUnit() { |
586 |
return this; |
594 |
return this; |
587 |
} |
595 |
} |
588 |
/** |
596 |
/* (non-Javadoc) |
589 |
* @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents() |
597 |
* @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents() |
590 |
*/ |
598 |
*/ |
591 |
public char[] getContents() { |
599 |
public char[] getContents() { |
Lines 604-614
Link Here
|
604 |
return CharOperation.NO_CHAR; |
612 |
return CharOperation.NO_CHAR; |
605 |
return contents; |
613 |
return contents; |
606 |
} |
614 |
} |
607 |
/** |
615 |
/* (non-Javadoc) |
608 |
* A compilation unit has a corresponding resource unless it is contained |
616 |
* A compilation unit has a corresponding resource unless it is contained |
609 |
* in a jar. |
617 |
* in a jar. |
610 |
* |
618 |
* |
611 |
* @see IJavaElement#getCorrespondingResource() |
619 |
* @see org.eclipse.jdt.internal.core.Openable#getCorrespondingResource() |
612 |
*/ |
620 |
*/ |
613 |
public IResource getCorrespondingResource() throws JavaModelException { |
621 |
public IResource getCorrespondingResource() throws JavaModelException { |
614 |
PackageFragmentRoot root = getPackageFragmentRoot(); |
622 |
PackageFragmentRoot root = getPackageFragmentRoot(); |
Lines 618-625
Link Here
|
618 |
return getUnderlyingResource(); |
626 |
return getUnderlyingResource(); |
619 |
} |
627 |
} |
620 |
} |
628 |
} |
621 |
/** |
629 |
/* (non-Javadoc) |
622 |
* @see ICompilationUnit#getElementAt(int) |
630 |
* @see IJavaFile#getElementAt(int) |
623 |
*/ |
631 |
*/ |
624 |
public IJavaElement getElementAt(int position) throws JavaModelException { |
632 |
public IJavaElement getElementAt(int position) throws JavaModelException { |
625 |
|
633 |
|
Lines 630-653
Link Here
|
630 |
return e; |
638 |
return e; |
631 |
} |
639 |
} |
632 |
} |
640 |
} |
|
|
641 |
/* (non-Javadoc) |
642 |
* @see org.eclipse.jdt.internal.core.JavaElement#getElementName() |
643 |
*/ |
633 |
public String getElementName() { |
644 |
public String getElementName() { |
634 |
return this.name; |
645 |
return this.name; |
635 |
} |
646 |
} |
636 |
/** |
647 |
/* (non-Javadoc) |
637 |
* @see IJavaElement |
648 |
* @see org.eclipse.jdt.core.IJavaElement#getElementType() |
638 |
*/ |
649 |
*/ |
639 |
public int getElementType() { |
650 |
public int getElementType() { |
640 |
return COMPILATION_UNIT; |
651 |
return COMPILATION_UNIT; |
641 |
} |
652 |
} |
642 |
/** |
653 |
/* (non-Javadoc) |
643 |
* @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName() |
654 |
* @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName() |
644 |
*/ |
655 |
*/ |
645 |
public char[] getFileName(){ |
656 |
public char[] getFileName(){ |
646 |
return getPath().toString().toCharArray(); |
657 |
return getPath().toString().toCharArray(); |
647 |
} |
658 |
} |
648 |
|
659 |
|
649 |
/* |
660 |
/* (non-Javadoc) |
650 |
* @see JavaElement |
661 |
* @see org.eclipse.jdt.internal.core.JavaElement#getHandleFromMemento(java.lang.String, org.eclipse.jdt.internal.core.util.MementoTokenizer, org.eclipse.jdt.core.WorkingCopyOwner) |
651 |
*/ |
662 |
*/ |
652 |
public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) { |
663 |
public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) { |
653 |
switch (token.charAt(0)) { |
664 |
switch (token.charAt(0)) { |
Lines 668-694
Link Here
|
668 |
return null; |
679 |
return null; |
669 |
} |
680 |
} |
670 |
|
681 |
|
671 |
/** |
682 |
/* (non-Javadoc) |
672 |
* @see JavaElement#getHandleMementoDelimiter() |
683 |
* @see JavaElement#getHandleMementoDelimiter() |
673 |
*/ |
684 |
*/ |
674 |
protected char getHandleMementoDelimiter() { |
685 |
protected char getHandleMementoDelimiter() { |
675 |
return JavaElement.JEM_COMPILATIONUNIT; |
686 |
return JavaElement.JEM_COMPILATIONUNIT; |
676 |
} |
687 |
} |
677 |
/** |
688 |
/* (non-Javadoc) |
678 |
* @see ICompilationUnit#getImport(String) |
689 |
* @see ICompilationUnit#getImport(String) |
679 |
*/ |
690 |
*/ |
680 |
public IImportDeclaration getImport(String importName) { |
691 |
public IImportDeclaration getImport(String importName) { |
681 |
return getImportContainer().getImport(importName); |
692 |
return getImportContainer().getImport(importName); |
682 |
} |
693 |
} |
683 |
/** |
694 |
/* (non-Javadoc) |
684 |
* @see ICompilationUnit#getImportContainer() |
695 |
* @see ICompilationUnit#getImportContainer() |
685 |
*/ |
696 |
*/ |
686 |
public IImportContainer getImportContainer() { |
697 |
public IImportContainer getImportContainer() { |
687 |
return new ImportContainer(this); |
698 |
return new ImportContainer(this); |
688 |
} |
699 |
} |
689 |
|
700 |
|
690 |
|
701 |
/* (non-Javadoc) |
691 |
/** |
|
|
692 |
* @see ICompilationUnit#getImports() |
702 |
* @see ICompilationUnit#getImports() |
693 |
*/ |
703 |
*/ |
694 |
public IImportDeclaration[] getImports() throws JavaModelException { |
704 |
public IImportDeclaration[] getImports() throws JavaModelException { |
Lines 713-727
Link Here
|
713 |
System.arraycopy(elements, 0, imports, 0, length); |
723 |
System.arraycopy(elements, 0, imports, 0, length); |
714 |
return imports; |
724 |
return imports; |
715 |
} |
725 |
} |
716 |
/** |
726 |
/* (non-Javadoc) |
|
|
727 |
* @see org.eclipse.jdt.internal.core.JavaElement#getJavaFile() |
728 |
*/ |
729 |
public IJavaFile getJavaFile() { |
730 |
return this; |
731 |
} |
732 |
/* (non-Javadoc) |
717 |
* @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getMainTypeName() |
733 |
* @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getMainTypeName() |
718 |
*/ |
734 |
*/ |
719 |
public char[] getMainTypeName(){ |
735 |
public char[] getMainTypeName(){ |
720 |
return Util.getNameWithoutJavaLikeExtension(getElementName()).toCharArray(); |
736 |
return Util.getNameWithoutJavaLikeExtension(getElementName()).toCharArray(); |
721 |
} |
737 |
} |
722 |
/** |
738 |
/* (non-Javadoc) |
723 |
* @see IWorkingCopy#getOriginal(IJavaElement) |
739 |
* @see IWorkingCopy#getOriginal(IJavaElement) |
724 |
* @deprecated |
|
|
725 |
*/ |
740 |
*/ |
726 |
public IJavaElement getOriginal(IJavaElement workingCopyElement) { |
741 |
public IJavaElement getOriginal(IJavaElement workingCopyElement) { |
727 |
// backward compatibility |
742 |
// backward compatibility |
Lines 733-741
Link Here
|
733 |
|
748 |
|
734 |
return workingCopyElement.getPrimaryElement(); |
749 |
return workingCopyElement.getPrimaryElement(); |
735 |
} |
750 |
} |
736 |
/** |
751 |
/* (non-Javadoc) |
737 |
* @see IWorkingCopy#getOriginalElement() |
752 |
* @see IWorkingCopy#getOriginalElement() |
738 |
* @deprecated |
|
|
739 |
*/ |
753 |
*/ |
740 |
public IJavaElement getOriginalElement() { |
754 |
public IJavaElement getOriginalElement() { |
741 |
// backward compatibility |
755 |
// backward compatibility |
Lines 749-761
Link Here
|
749 |
public WorkingCopyOwner getOwner() { |
763 |
public WorkingCopyOwner getOwner() { |
750 |
return isPrimary() || !isWorkingCopy() ? null : this.owner; |
764 |
return isPrimary() || !isWorkingCopy() ? null : this.owner; |
751 |
} |
765 |
} |
752 |
/** |
766 |
/* (non-Javadoc) |
753 |
* @see ICompilationUnit#getPackageDeclaration(String) |
767 |
* @see ICompilationUnit#getPackageDeclaration(String) |
754 |
*/ |
768 |
*/ |
755 |
public IPackageDeclaration getPackageDeclaration(String pkg) { |
769 |
public IPackageDeclaration getPackageDeclaration(String pkg) { |
756 |
return new PackageDeclaration(this, pkg); |
770 |
return new PackageDeclaration(this, pkg); |
757 |
} |
771 |
} |
758 |
/** |
772 |
/* (non-Javadoc) |
759 |
* @see ICompilationUnit#getPackageDeclarations() |
773 |
* @see ICompilationUnit#getPackageDeclarations() |
760 |
*/ |
774 |
*/ |
761 |
public IPackageDeclaration[] getPackageDeclarations() throws JavaModelException { |
775 |
public IPackageDeclaration[] getPackageDeclarations() throws JavaModelException { |
Lines 764-770
Link Here
|
764 |
list.toArray(array); |
778 |
list.toArray(array); |
765 |
return array; |
779 |
return array; |
766 |
} |
780 |
} |
767 |
/** |
781 |
/* (non-Javadoc) |
768 |
* @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getPackageName() |
782 |
* @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getPackageName() |
769 |
*/ |
783 |
*/ |
770 |
public char[][] getPackageName() { |
784 |
public char[][] getPackageName() { |
Lines 773-779
Link Here
|
773 |
return Util.toCharArrays(packageFragment.names); |
787 |
return Util.toCharArrays(packageFragment.names); |
774 |
} |
788 |
} |
775 |
|
789 |
|
776 |
/** |
790 |
/* (non-Javadoc) |
777 |
* @see IJavaElement#getPath() |
791 |
* @see IJavaElement#getPath() |
778 |
*/ |
792 |
*/ |
779 |
public IPath getPath() { |
793 |
public IPath getPath() { |
Lines 792-811
Link Here
|
792 |
public JavaModelManager.PerWorkingCopyInfo getPerWorkingCopyInfo() { |
806 |
public JavaModelManager.PerWorkingCopyInfo getPerWorkingCopyInfo() { |
793 |
return JavaModelManager.getJavaModelManager().getPerWorkingCopyInfo(this, false/*don't create*/, false/*don't record usage*/, null/*no problem requestor needed*/); |
807 |
return JavaModelManager.getJavaModelManager().getPerWorkingCopyInfo(this, false/*don't create*/, false/*don't record usage*/, null/*no problem requestor needed*/); |
794 |
} |
808 |
} |
795 |
/* |
809 |
/* (non-Javadoc) |
796 |
* @see ICompilationUnit#getPrimary() |
810 |
* @see ICompilationUnit#getPrimary() |
797 |
*/ |
811 |
*/ |
798 |
public ICompilationUnit getPrimary() { |
812 |
public ICompilationUnit getPrimary() { |
799 |
return (ICompilationUnit)getPrimaryElement(true); |
813 |
return (ICompilationUnit)getPrimaryElement(true); |
800 |
} |
814 |
} |
801 |
/* |
815 |
/* (non-Javadoc) |
802 |
* @see JavaElement#getPrimaryElement(boolean) |
816 |
* @see JavaElement#getPrimaryElement(boolean) |
803 |
*/ |
817 |
*/ |
804 |
public IJavaElement getPrimaryElement(boolean checkOwner) { |
818 |
public IJavaElement getPrimaryElement(boolean checkOwner) { |
805 |
if (checkOwner && isPrimary()) return this; |
819 |
if (checkOwner && isPrimary()) return this; |
806 |
return new CompilationUnit((PackageFragment)getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY); |
820 |
return new CompilationUnit((PackageFragment)getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY); |
807 |
} |
821 |
} |
808 |
/** |
822 |
/* (non-Javadoc) |
809 |
* @see IJavaElement#getResource() |
823 |
* @see IJavaElement#getResource() |
810 |
*/ |
824 |
*/ |
811 |
public IResource getResource() { |
825 |
public IResource getResource() { |
Lines 818-823
Link Here
|
818 |
} |
832 |
} |
819 |
} |
833 |
} |
820 |
/** |
834 |
/** |
|
|
835 |
* @see IWorkingCopy#getSharedWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor) |
836 |
* @deprecated As it use deprecated interface |
837 |
*/ |
838 |
public IJavaElement getSharedWorkingCopy(IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException { |
839 |
|
840 |
// if factory is null, default factory must be used |
841 |
if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory(); |
842 |
|
843 |
return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, pm); |
844 |
} |
845 |
/* (non-Javadoc) |
821 |
* @see ISourceReference#getSource() |
846 |
* @see ISourceReference#getSource() |
822 |
*/ |
847 |
*/ |
823 |
public String getSource() throws JavaModelException { |
848 |
public String getSource() throws JavaModelException { |
Lines 825-843
Link Here
|
825 |
if (buffer == null) return ""; //$NON-NLS-1$ |
850 |
if (buffer == null) return ""; //$NON-NLS-1$ |
826 |
return buffer.getContents(); |
851 |
return buffer.getContents(); |
827 |
} |
852 |
} |
828 |
/** |
853 |
/* (non-Javadoc) |
829 |
* @see ISourceReference#getSourceRange() |
854 |
* @see ISourceReference#getSourceRange() |
830 |
*/ |
855 |
*/ |
831 |
public ISourceRange getSourceRange() throws JavaModelException { |
856 |
public ISourceRange getSourceRange() throws JavaModelException { |
832 |
return ((CompilationUnitElementInfo) getElementInfo()).getSourceRange(); |
857 |
return ((CompilationUnitElementInfo) getElementInfo()).getSourceRange(); |
833 |
} |
858 |
} |
834 |
/** |
859 |
/* (non-Javadoc) |
835 |
* @see ICompilationUnit#getType(String) |
860 |
* @see ICompilationUnit#getType(String) |
836 |
*/ |
861 |
*/ |
837 |
public IType getType(String typeName) { |
862 |
public IType getType(String typeName) { |
838 |
return new SourceType(this, typeName); |
863 |
return new SourceType(this, typeName); |
839 |
} |
864 |
} |
840 |
/** |
865 |
/* (non-Javadoc) |
841 |
* @see ICompilationUnit#getTypes() |
866 |
* @see ICompilationUnit#getTypes() |
842 |
*/ |
867 |
*/ |
843 |
public IType[] getTypes() throws JavaModelException { |
868 |
public IType[] getTypes() throws JavaModelException { |
Lines 846-877
Link Here
|
846 |
list.toArray(array); |
871 |
list.toArray(array); |
847 |
return array; |
872 |
return array; |
848 |
} |
873 |
} |
849 |
/** |
874 |
/* (non-Javadoc) |
850 |
* @see IJavaElement |
875 |
* @see org.eclipse.jdt.internal.core.Openable#getUnderlyingResource() |
851 |
*/ |
876 |
*/ |
852 |
public IResource getUnderlyingResource() throws JavaModelException { |
877 |
public IResource getUnderlyingResource() throws JavaModelException { |
853 |
if (isWorkingCopy() && !isPrimary()) return null; |
878 |
if (isWorkingCopy() && !isPrimary()) return null; |
854 |
return super.getUnderlyingResource(); |
879 |
return super.getUnderlyingResource(); |
855 |
} |
880 |
} |
856 |
/** |
881 |
/* (non-Javadoc) |
857 |
* @see IWorkingCopy#getSharedWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor) |
|
|
858 |
* @deprecated |
859 |
*/ |
860 |
public IJavaElement getSharedWorkingCopy(IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException { |
861 |
|
862 |
// if factory is null, default factory must be used |
863 |
if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory(); |
864 |
|
865 |
return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, pm); |
866 |
} |
867 |
/** |
868 |
* @see IWorkingCopy#getWorkingCopy() |
882 |
* @see IWorkingCopy#getWorkingCopy() |
869 |
* @deprecated |
|
|
870 |
*/ |
883 |
*/ |
871 |
public IJavaElement getWorkingCopy() throws JavaModelException { |
884 |
public IJavaElement getWorkingCopy() throws JavaModelException { |
872 |
return getWorkingCopy(null); |
885 |
return getWorkingCopy(null); |
873 |
} |
886 |
} |
874 |
/** |
887 |
/* (non-Javadoc) |
875 |
* @see ICompilationUnit#getWorkingCopy(IProgressMonitor) |
888 |
* @see ICompilationUnit#getWorkingCopy(IProgressMonitor) |
876 |
*/ |
889 |
*/ |
877 |
public ICompilationUnit getWorkingCopy(IProgressMonitor monitor) throws JavaModelException { |
890 |
public ICompilationUnit getWorkingCopy(IProgressMonitor monitor) throws JavaModelException { |
Lines 879-890
Link Here
|
879 |
} |
892 |
} |
880 |
/** |
893 |
/** |
881 |
* @see IWorkingCopy#getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor) |
894 |
* @see IWorkingCopy#getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor) |
882 |
* @deprecated |
895 |
* @deprecated As it use a deprecated interface |
883 |
*/ |
896 |
*/ |
884 |
public IJavaElement getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException { |
897 |
public IJavaElement getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException { |
885 |
return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, monitor); |
898 |
return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, monitor); |
886 |
} |
899 |
} |
887 |
/** |
900 |
/* (non-Javadoc) |
888 |
* @see ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor) |
901 |
* @see ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor) |
889 |
*/ |
902 |
*/ |
890 |
public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException { |
903 |
public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException { |
Lines 902-914
Link Here
|
902 |
op.runOperation(monitor); |
915 |
op.runOperation(monitor); |
903 |
return workingCopy; |
916 |
return workingCopy; |
904 |
} |
917 |
} |
905 |
/** |
918 |
/* (non-Javadoc) |
|
|
919 |
* @see org.eclipse.jdt.core.IJavaFile#getWorkingCopy(org.eclipse.jdt.core.WorkingCopyOwner, org.eclipse.core.runtime.IProgressMonitor) |
920 |
*/ |
921 |
public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProgressMonitor monitor) throws JavaModelException { |
922 |
return getWorkingCopy(workingCopyOwner, workingCopyOwner.getProblemRequestor(), monitor); |
923 |
} |
924 |
/* (non-Javadoc) |
906 |
* @see Openable#hasBuffer() |
925 |
* @see Openable#hasBuffer() |
907 |
*/ |
926 |
*/ |
908 |
protected boolean hasBuffer() { |
927 |
protected boolean hasBuffer() { |
909 |
return true; |
928 |
return true; |
910 |
} |
929 |
} |
911 |
/* |
930 |
/* (non-Javadoc) |
912 |
* @see ICompilationUnit#hasResourceChanged() |
931 |
* @see ICompilationUnit#hasResourceChanged() |
913 |
*/ |
932 |
*/ |
914 |
public boolean hasResourceChanged() { |
933 |
public boolean hasResourceChanged() { |
Lines 922-971
Link Here
|
922 |
if (resource == null) return false; |
941 |
if (resource == null) return false; |
923 |
return ((CompilationUnitElementInfo)info).timestamp != resource.getModificationStamp(); |
942 |
return ((CompilationUnitElementInfo)info).timestamp != resource.getModificationStamp(); |
924 |
} |
943 |
} |
925 |
/** |
944 |
/* (non-Javadoc) |
926 |
* @see IWorkingCopy#isBasedOn(IResource) |
945 |
* @see IWorkingCopy#isBasedOn(IResource) |
927 |
* @deprecated |
|
|
928 |
*/ |
946 |
*/ |
929 |
public boolean isBasedOn(IResource resource) { |
947 |
public boolean isBasedOn(IResource resource) { |
930 |
if (!isWorkingCopy()) return false; |
948 |
if (!isWorkingCopy()) return false; |
931 |
if (!getResource().equals(resource)) return false; |
949 |
if (!getResource().equals(resource)) return false; |
932 |
return !hasResourceChanged(); |
950 |
return !hasResourceChanged(); |
933 |
} |
951 |
} |
934 |
/** |
952 |
/* (non-Javadoc) |
935 |
* @see IOpenable#isConsistent() |
953 |
* @see IOpenable#isConsistent() |
936 |
*/ |
954 |
*/ |
937 |
public boolean isConsistent() { |
955 |
public boolean isConsistent() { |
938 |
return !JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().contains(this); |
956 |
return !JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().contains(this); |
939 |
} |
957 |
} |
|
|
958 |
/* (non-Javadoc) |
959 |
* @see org.eclipse.jdt.core.ICompilationUnit#isPrimary() |
960 |
*/ |
940 |
public boolean isPrimary() { |
961 |
public boolean isPrimary() { |
941 |
return this.owner == DefaultWorkingCopyOwner.PRIMARY; |
962 |
return this.owner == DefaultWorkingCopyOwner.PRIMARY; |
942 |
} |
963 |
} |
943 |
/** |
964 |
/* (non-Javadoc) |
944 |
* @see Openable#isSourceElement() |
965 |
* @see Openable#isSourceElement() |
945 |
*/ |
966 |
*/ |
946 |
protected boolean isSourceElement() { |
967 |
protected boolean isSourceElement() { |
947 |
return true; |
968 |
return true; |
948 |
} |
969 |
} |
949 |
protected IStatus validateCompilationUnit(IResource resource) { |
970 |
/* (non-Javadoc) |
950 |
IPackageFragmentRoot root = getPackageFragmentRoot(); |
|
|
951 |
// root never null as validation is not done for working copies |
952 |
try { |
953 |
if (root.getKind() != IPackageFragmentRoot.K_SOURCE) |
954 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); |
955 |
} catch (JavaModelException e) { |
956 |
return e.getJavaModelStatus(); |
957 |
} |
958 |
if (resource != null) { |
959 |
char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); |
960 |
char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); |
961 |
if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) |
962 |
return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); |
963 |
if (!resource.isAccessible()) |
964 |
return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); |
965 |
} |
966 |
return JavaConventions.validateCompilationUnitName(getElementName()); |
967 |
} |
968 |
/* |
969 |
* @see ICompilationUnit#isWorkingCopy() |
971 |
* @see ICompilationUnit#isWorkingCopy() |
970 |
*/ |
972 |
*/ |
971 |
public boolean isWorkingCopy() { |
973 |
public boolean isWorkingCopy() { |
Lines 973-984
Link Here
|
973 |
// delta, clients can still check that element was a working copy before being discarded. |
975 |
// delta, clients can still check that element was a working copy before being discarded. |
974 |
return !isPrimary() || getPerWorkingCopyInfo() != null; |
976 |
return !isPrimary() || getPerWorkingCopyInfo() != null; |
975 |
} |
977 |
} |
976 |
/** |
|
|
977 |
* @see IOpenable#makeConsistent(IProgressMonitor) |
978 |
*/ |
979 |
public void makeConsistent(IProgressMonitor monitor) throws JavaModelException { |
980 |
makeConsistent(NO_AST, false/*don't resolve bindings*/, false /* don't perform statements recovery */, null/*don't collect problems but report them*/, monitor); |
981 |
} |
982 |
public org.eclipse.jdt.core.dom.CompilationUnit makeConsistent(int astLevel, boolean resolveBindings, boolean statementsRecovery, HashMap problems, IProgressMonitor monitor) throws JavaModelException { |
978 |
public org.eclipse.jdt.core.dom.CompilationUnit makeConsistent(int astLevel, boolean resolveBindings, boolean statementsRecovery, HashMap problems, IProgressMonitor monitor) throws JavaModelException { |
983 |
if (isConsistent()) return null; |
979 |
if (isConsistent()) return null; |
984 |
|
980 |
|
Lines 999-1005
Link Here
|
999 |
return null; |
995 |
return null; |
1000 |
} |
996 |
} |
1001 |
} |
997 |
} |
1002 |
/** |
998 |
/* (non-Javadoc) |
|
|
999 |
* @see org.eclipse.jdt.internal.core.Openable#makeConsistent(org.eclipse.core.runtime.IProgressMonitor) |
1000 |
*/ |
1001 |
public void makeConsistent(IProgressMonitor monitor) throws JavaModelException { |
1002 |
makeConsistent(NO_AST, false/*don't resolve bindings*/, false /* don't perform statements recovery */, null/*don't collect problems but report them*/, monitor); |
1003 |
} |
1004 |
/* (non-Javadoc) |
1003 |
* @see ISourceManipulation#move(IJavaElement, IJavaElement, String, boolean, IProgressMonitor) |
1005 |
* @see ISourceManipulation#move(IJavaElement, IJavaElement, String, boolean, IProgressMonitor) |
1004 |
*/ |
1006 |
*/ |
1005 |
public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException { |
1007 |
public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException { |
Lines 1016-1022
Link Here
|
1016 |
getJavaModel().move(elements, containers, null, renamings, force, monitor); |
1018 |
getJavaModel().move(elements, containers, null, renamings, force, monitor); |
1017 |
} |
1019 |
} |
1018 |
|
1020 |
|
1019 |
/** |
1021 |
/* (non-Javadoc) |
1020 |
* @see Openable#openBuffer(IProgressMonitor, Object) |
1022 |
* @see Openable#openBuffer(IProgressMonitor, Object) |
1021 |
*/ |
1023 |
*/ |
1022 |
protected IBuffer openBuffer(IProgressMonitor pm, Object info) throws JavaModelException { |
1024 |
protected IBuffer openBuffer(IProgressMonitor pm, Object info) throws JavaModelException { |
Lines 1070-1099
Link Here
|
1070 |
} |
1072 |
} |
1071 |
return buffer; |
1073 |
return buffer; |
1072 |
} |
1074 |
} |
|
|
1075 |
/* (non-Javadoc) |
1076 |
* @see org.eclipse.jdt.internal.core.Openable#openParent(java.lang.Object, java.util.HashMap, org.eclipse.core.runtime.IProgressMonitor) |
1077 |
*/ |
1073 |
protected void openParent(Object childInfo, HashMap newElements, IProgressMonitor pm) throws JavaModelException { |
1078 |
protected void openParent(Object childInfo, HashMap newElements, IProgressMonitor pm) throws JavaModelException { |
1074 |
if (!isWorkingCopy()) |
1079 |
if (!isWorkingCopy()) |
1075 |
super.openParent(childInfo, newElements, pm); |
1080 |
super.openParent(childInfo, newElements, pm); |
1076 |
// don't open parent for a working copy to speed up the first becomeWorkingCopy |
1081 |
// don't open parent for a working copy to speed up the first becomeWorkingCopy |
1077 |
// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89411) |
1082 |
// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89411) |
1078 |
} |
1083 |
} |
1079 |
/** |
1084 |
/* (non-Javadoc) |
1080 |
* @see ICompilationUnit#reconcile() |
1085 |
* @see ICompilationUnit#reconcile() |
1081 |
* @deprecated |
|
|
1082 |
*/ |
1086 |
*/ |
1083 |
public IMarker[] reconcile() throws JavaModelException { |
1087 |
public IMarker[] reconcile() throws JavaModelException { |
1084 |
reconcile(NO_AST, false/*don't force problem detection*/, false, null/*use primary owner*/, null/*no progress monitor*/); |
1088 |
reconcile(NO_AST, false/*don't force problem detection*/, false, null/*use primary owner*/, null/*no progress monitor*/); |
1085 |
return null; |
1089 |
return null; |
1086 |
} |
1090 |
} |
1087 |
/** |
1091 |
/* (non-Javadoc) |
1088 |
* @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) |
1092 |
* @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) |
1089 |
*/ |
1093 |
*/ |
1090 |
public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws JavaModelException { |
1094 |
public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws JavaModelException { |
1091 |
reconcile(NO_AST, forceProblemDetection, false, null/*use primary owner*/, monitor); |
1095 |
reconcile(NO_AST, forceProblemDetection, false, null/*use primary owner*/, monitor); |
1092 |
} |
1096 |
} |
1093 |
|
1097 |
|
1094 |
/** |
1098 |
/* (non-Javadoc) |
1095 |
* @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) |
1099 |
* @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) |
1096 |
* @since 3.0 |
|
|
1097 |
*/ |
1100 |
*/ |
1098 |
public org.eclipse.jdt.core.dom.CompilationUnit reconcile( |
1101 |
public org.eclipse.jdt.core.dom.CompilationUnit reconcile( |
1099 |
int astLevel, |
1102 |
int astLevel, |
Lines 1104-1112
Link Here
|
1104 |
return reconcile(astLevel, forceProblemDetection, false, workingCopyOwner, monitor); |
1107 |
return reconcile(astLevel, forceProblemDetection, false, workingCopyOwner, monitor); |
1105 |
} |
1108 |
} |
1106 |
|
1109 |
|
1107 |
/** |
1110 |
/* (non-Javadoc) |
1108 |
* @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) |
1111 |
* @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) |
1109 |
* @since 3.0 |
|
|
1110 |
*/ |
1112 |
*/ |
1111 |
public org.eclipse.jdt.core.dom.CompilationUnit reconcile( |
1113 |
public org.eclipse.jdt.core.dom.CompilationUnit reconcile( |
1112 |
int astLevel, |
1114 |
int astLevel, |
Lines 1139-1145
Link Here
|
1139 |
return op.ast; |
1141 |
return op.ast; |
1140 |
} |
1142 |
} |
1141 |
|
1143 |
|
1142 |
/** |
1144 |
/* (non-Javadoc) |
1143 |
* @see ISourceManipulation#rename(String, boolean, IProgressMonitor) |
1145 |
* @see ISourceManipulation#rename(String, boolean, IProgressMonitor) |
1144 |
*/ |
1146 |
*/ |
1145 |
public void rename(String newName, boolean force, IProgressMonitor monitor) throws JavaModelException { |
1147 |
public void rename(String newName, boolean force, IProgressMonitor monitor) throws JavaModelException { |
Lines 1151-1158
Link Here
|
1151 |
String[] renamings= new String[] {newName}; |
1153 |
String[] renamings= new String[] {newName}; |
1152 |
getJavaModel().rename(elements, dests, renamings, force, monitor); |
1154 |
getJavaModel().rename(elements, dests, renamings, force, monitor); |
1153 |
} |
1155 |
} |
1154 |
/* |
1156 |
/* (non-Javadoc) |
1155 |
* @see ICompilationUnit |
1157 |
* @see org.eclipse.jdt.core.ICompilationUnit#restore() |
1156 |
*/ |
1158 |
*/ |
1157 |
public void restore() throws JavaModelException { |
1159 |
public void restore() throws JavaModelException { |
1158 |
|
1160 |
|
Lines 1165-1172
Link Here
|
1165 |
updateTimeStamp(original); |
1167 |
updateTimeStamp(original); |
1166 |
makeConsistent(null); |
1168 |
makeConsistent(null); |
1167 |
} |
1169 |
} |
1168 |
/** |
1170 |
/* (non-Javadoc) |
1169 |
* @see IOpenable |
1171 |
* @see org.eclipse.jdt.internal.core.Openable#save(org.eclipse.core.runtime.IProgressMonitor, boolean) |
1170 |
*/ |
1172 |
*/ |
1171 |
public void save(IProgressMonitor pm, boolean force) throws JavaModelException { |
1173 |
public void save(IProgressMonitor pm, boolean force) throws JavaModelException { |
1172 |
if (isWorkingCopy()) { |
1174 |
if (isWorkingCopy()) { |
Lines 1178-1185
Link Here
|
1178 |
super.save(pm, force); |
1180 |
super.save(pm, force); |
1179 |
} |
1181 |
} |
1180 |
} |
1182 |
} |
1181 |
/** |
1183 |
/* (non-Javadoc) |
1182 |
* Debugging purposes |
1184 |
* @see org.eclipse.jdt.internal.core.JavaElement#toStringInfo(int, java.lang.StringBuffer, java.lang.Object, boolean) |
1183 |
*/ |
1185 |
*/ |
1184 |
protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo) { |
1186 |
protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo) { |
1185 |
if (!isPrimary()) { |
1187 |
if (!isPrimary()) { |
Lines 1211-1215
Link Here
|
1211 |
} |
1213 |
} |
1212 |
((CompilationUnitElementInfo) getElementInfo()).timestamp = timeStamp; |
1214 |
((CompilationUnitElementInfo) getElementInfo()).timestamp = timeStamp; |
1213 |
} |
1215 |
} |
|
|
1216 |
protected IStatus validateCompilationUnit(IResource resource) { |
1217 |
IPackageFragmentRoot root = getPackageFragmentRoot(); |
1218 |
// root never null as validation is not done for working copies |
1219 |
try { |
1220 |
if (root.getKind() != IPackageFragmentRoot.K_SOURCE) |
1221 |
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); |
1222 |
} catch (JavaModelException e) { |
1223 |
return e.getJavaModelStatus(); |
1224 |
} |
1225 |
if (resource != null) { |
1226 |
char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); |
1227 |
char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); |
1228 |
if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) |
1229 |
return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); |
1230 |
if (!resource.isAccessible()) |
1231 |
return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); |
1232 |
} |
1233 |
return JavaConventions.validateCompilationUnitName(getElementName()); |
1234 |
} |
1214 |
|
1235 |
|
1215 |
} |
1236 |
} |