1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
13 import net.sourceforge.phpdt.core.IJavaElement;
14 import net.sourceforge.phpdt.core.IJavaProject;
15 import net.sourceforge.phpdt.core.IPackageFragment;
16 import net.sourceforge.phpdt.core.IPackageFragmentRoot;
17 import net.sourceforge.phpdt.core.JavaCore;
18 import net.sourceforge.phpdt.core.JavaModelException;
19 import net.sourceforge.phpdt.core.compiler.CharOperation;
21 import org.eclipse.core.resources.IFolder;
22 import org.eclipse.core.resources.IResource;
23 import org.eclipse.core.resources.ResourcesPlugin;
24 import org.eclipse.core.runtime.CoreException;
25 import org.eclipse.core.runtime.IPath;
26 import org.eclipse.core.runtime.QualifiedName;
30 * @see IPackageFragmentRoot
32 public class PackageFragmentRoot extends Openable implements IPackageFragmentRoot {
35 * The delimiter between the source path and root path in the
36 * attachment server property.
38 protected final static char ATTACHMENT_PROPERTY_DELIMITER= '*';
40 * No source attachment property
42 protected final static String NO_SOURCE_ATTACHMENT = ""; //$NON-NLS-1$
44 * No source mapper singleton
46 // protected final static SourceMapper NO_SOURCE_MAPPER = new SourceMapper();
49 * The resource associated with this root.
50 * (an IResource or a java.io.File (for external jar only))
52 protected Object resource;
55 * Constructs a package fragment root which is the root of the java package
56 * directory hierarchy.
58 protected PackageFragmentRoot(IResource resource, IJavaProject project, String name) {
59 super(PACKAGE_FRAGMENT_ROOT, project, name);
60 this.resource = resource;
64 * @see IPackageFragmentRoot
66 //public void attachSource(IPath sourcePath, IPath rootPath, IProgressMonitor monitor) throws JavaModelException {
68 // verifyAttachSource(sourcePath);
69 // if (monitor != null) {
70 // monitor.beginTask(Util.bind("element.attachingSource"), 2); //$NON-NLS-1$
72 // SourceMapper oldMapper= getSourceMapper();
73 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
74 // boolean rootNeedsToBeClosed= false;
76 // if (sourcePath == null) {
77 // //source being detached
78 // rootNeedsToBeClosed= true;
79 // setSourceMapper(null);
80 // /* Disable deltas (see 1GDTUSD)
81 // // fire a delta to notify the UI about the source detachement.
82 // JavaModelManager manager = (JavaModelManager) JavaModelManager.getJavaModelManager();
83 // JavaModel model = (JavaModel) getJavaModel();
84 // JavaElementDelta attachedSourceDelta = new JavaElementDelta(model);
85 // attachedSourceDelta .sourceDetached(this); // this would be a PackageFragmentRoot
86 // manager.registerResourceDelta(attachedSourceDelta );
87 // manager.fire(); // maybe you want to fire the change later. Let us know about it.
91 // // fire a delta to notify the UI about the source attachement.
92 // JavaModelManager manager = (JavaModelManager) JavaModelManager.getJavaModelManager();
93 // JavaModel model = (JavaModel) getJavaModel();
94 // JavaElementDelta attachedSourceDelta = new JavaElementDelta(model);
95 // attachedSourceDelta .sourceAttached(this); // this would be a PackageFragmentRoot
96 // manager.registerResourceDelta(attachedSourceDelta );
97 // manager.fire(); // maybe you want to fire the change later. Let us know about it.
100 // //check if different from the current attachment
101 // IPath storedSourcePath= getSourceAttachmentPath();
102 // IPath storedRootPath= getSourceAttachmentRootPath();
103 // if (monitor != null) {
104 // monitor.worked(1);
106 // if (storedSourcePath != null) {
107 // if (!(storedSourcePath.equals(sourcePath) && (rootPath != null && rootPath.equals(storedRootPath)) || storedRootPath == null)) {
108 // rootNeedsToBeClosed= true;
111 // // check if source path is valid
112 // Object target = JavaModel.getTarget(workspace.getRoot(), sourcePath, false);
113 // if (target == null) {
114 // if (monitor != null) {
117 // throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, sourcePath));
119 // SourceMapper mapper = createSourceMapper(sourcePath, rootPath);
120 // if (rootPath == null && mapper.rootPath != null) {
121 // // as a side effect of calling the SourceMapper constructor, the root path was computed
122 // rootPath = new Path(mapper.rootPath);
124 // setSourceMapper(mapper);
126 // if (sourcePath == null) {
127 // setSourceAttachmentProperty(null); //remove the property
129 // //set the property to the path of the mapped source
130 // setSourceAttachmentProperty(
131 // sourcePath.toString()
132 // + (rootPath == null ? "" : (ATTACHMENT_PROPERTY_DELIMITER + rootPath.toString()))); //$NON-NLS-1$
134 // if (rootNeedsToBeClosed) {
135 // if (oldMapper != null) {
136 // oldMapper.close();
138 // BufferManager manager= BufferManager.getDefaultBufferManager();
139 // Enumeration openBuffers= manager.getOpenBuffers();
140 // while (openBuffers.hasMoreElements()) {
141 // IBuffer buffer= (IBuffer) openBuffers.nextElement();
142 // IOpenable possibleMember= buffer.getOwner();
143 // if (isAncestorOf((IJavaElement) possibleMember)) {
147 // if (monitor != null) {
148 // monitor.worked(1);
151 // } catch (JavaModelException e) {
152 // setSourceAttachmentProperty(null); // loose info - will be recomputed
155 // if (monitor != null) {
161 //SourceMapper createSourceMapper(IPath sourcePath, IPath rootPath) {
162 // SourceMapper mapper = new SourceMapper(
164 // rootPath == null ? null : rootPath.toOSString(),
165 // this.isExternal() ? JavaCore.getOptions() : this.getJavaProject().getOptions(true)); // only project options if associated with resource
169 * @see org.eclipse.jdt.core.IPackageFragmentRoot#delete
171 //public void delete(
172 // int updateResourceFlags,
173 // int updateModelFlags,
174 // IProgressMonitor monitor)
175 // throws JavaModelException {
177 // DeletePackageFragmentRootOperation op = new DeletePackageFragmentRootOperation(this, updateResourceFlags, updateModelFlags);
178 // runOperation(op, monitor);
182 * This root is being closed. If this root has an associated source attachment,
187 //protected void closing(Object info) throws JavaModelException { TODO remove after 2.1
188 // ((PackageFragmentRootInfo) info).sourceMapper = null;
189 // super.closing(info);
192 * Compute the package fragment children of this package fragment root.
194 * @exception JavaModelException The resource associated with this package fragment root does not exist
196 //protected boolean computeChildren(OpenableElementInfo info) throws JavaModelException {
198 // // the underlying resource may be a folder or a project (in the case that the project folder
199 // // is actually the package fragment root)
200 // IResource resource = getResource();
201 // if (resource.getType() == IResource.FOLDER || resource.getType() == IResource.PROJECT) {
202 // ArrayList vChildren = new ArrayList(5);
203 // char[][] exclusionPatterns = fullExclusionPatternChars();
204 // computeFolderChildren((IContainer) resource, "", vChildren, exclusionPatterns); //$NON-NLS-1$
205 // IJavaElement[] children = new IJavaElement[vChildren.size()];
206 // vChildren.toArray(children);
207 // info.setChildren(children);
209 // } catch (JavaModelException e) {
210 // //problem resolving children; structure remains unknown
211 // info.setChildren(new IJavaElement[]{});
218 * Starting at this folder, create package fragments and add the fragments that are not exclused
219 * to the collection of children.
221 * @exception JavaModelException The resource associated with this package fragment does not exist
223 //protected void computeFolderChildren(IContainer folder, String prefix, ArrayList vChildren, char[][] exclusionPatterns) throws JavaModelException {
224 // IPackageFragment pkg = getPackageFragment(prefix);
225 // vChildren.add(pkg);
227 // JavaProject javaProject = (JavaProject)getJavaProject();
228 // IResource[] members = folder.members();
229 // for (int i = 0, max = members.length; i < max; i++) {
230 // IResource member = members[i];
231 // String memberName = member.getName();
232 // if (member.getType() == IResource.FOLDER
233 // && Util.isValidFolderNameForPackage(memberName)
234 // && !Util.isExcluded(member, exclusionPatterns)) {
236 // // eliminate binary output only if nested inside direct subfolders
237 // if (javaProject.contains(member)) {
239 // if (prefix.length() == 0) {
240 // newPrefix = memberName;
242 // newPrefix = prefix + "." + memberName; //$NON-NLS-1$
244 // computeFolderChildren((IFolder) member, newPrefix, vChildren, exclusionPatterns);
248 // } catch(IllegalArgumentException e){
249 // throw new JavaModelException(e, IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST); // could be thrown by ElementTree when path is not found
250 // } catch (CoreException e) {
251 // throw new JavaModelException(e);
255 * Computes and returns the source attachment root path for the given source attachment path.
256 * Returns <code>null</code> if none could be found.
258 * @param sourceAttachmentPath the given absolute path to the source archive or folder
259 * @return the computed source attachment root path or <code>null</cde> if none could be found
260 * @throws JavaModelException
262 //public IPath computeSourceAttachmentRootPath(IPath sourceAttachmentPath) throws JavaModelException {
263 // IPath sourcePath = this.getSourceAttachmentPath();
264 // if (sourcePath == null) return null;
265 // SourceMapper mapper =
268 // null, // detect root path
269 // this.isExternal() ? JavaCore.getOptions() : this.getJavaProject().getOptions(true) // only project options if associated with resource
271 // if (mapper.rootPath == null) return null;
272 // return new Path(mapper.rootPath);
275 * @see org.eclipse.jdt.core.IPackageFragmentRoot#copy
278 // IPath destination,
279 // int updateResourceFlags,
280 // int updateModelFlags,
281 // IClasspathEntry sibling,
282 // IProgressMonitor monitor)
283 // throws JavaModelException {
285 // CopyPackageFragmentRootOperation op =
286 // new CopyPackageFragmentRootOperation(this, destination, updateResourceFlags, updateModelFlags, sibling);
287 // runOperation(op, monitor);
293 * Returns a new element info for this element.
295 //protected OpenableElementInfo createElementInfo() {
296 // return new PackageFragmentRootInfo();
300 * @see IPackageFragmentRoot
302 //public IPackageFragment createPackageFragment(String name, boolean force, IProgressMonitor monitor) throws JavaModelException {
303 // CreatePackageFragmentOperation op = new CreatePackageFragmentOperation(this, name, force);
304 // runOperation(op, monitor);
305 // return getPackageFragment(name);
309 * Returns the root's kind - K_SOURCE or K_BINARY, defaults
310 * to K_SOURCE if it is not on the classpath.
312 * @exception NotPresentException if the project and root do
315 //protected int determineKind(IResource underlyingResource) throws JavaModelException {
316 // IClasspathEntry[] entries= ((JavaProject)getJavaProject()).getExpandedClasspath(true);
317 // for (int i= 0; i < entries.length; i++) {
318 // IClasspathEntry entry= entries[i];
319 // if (entry.getPath().equals(underlyingResource.getFullPath())) {
320 // return entry.getContentKind();
323 // return IPackageFragmentRoot.K_SOURCE;
327 * Compares two objects for equality;
328 * for <code>PackageFragmentRoot</code>s, equality is having the
329 * same <code>JavaModel</code>, same resources, and occurrence count.
332 public boolean equals(Object o) {
335 if (!(o instanceof PackageFragmentRoot))
337 PackageFragmentRoot other = (PackageFragmentRoot) o;
338 return getJavaModel().equals(other.getJavaModel()) &&
339 this.resource.equals(other.resource) &&
340 fOccurrenceCount == other.fOccurrenceCount;
346 //public boolean exists() {
347 // return super.exists()
348 // && isOnClasspath();
351 //public IClasspathEntry findSourceAttachmentRecommendation() {
353 // IPath rootPath = this.getPath();
354 // IClasspathEntry entry;
355 // IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
357 // // try on enclosing project first
358 // JavaProject parentProject = (JavaProject) getJavaProject();
360 // entry = parentProject.getClasspathEntryFor(rootPath);
361 // if (entry != null){
362 // Object target = JavaModel.getTarget(workspaceRoot, entry.getSourceAttachmentPath(), true);
363 // if (target instanceof IFile){
364 // IFile file = (IFile) target;
365 // if (Util.isArchiveFileName(file.getName())){
368 // } else if (target instanceof IFolder) {
371 // if (target instanceof java.io.File){
372 // java.io.File file = (java.io.File) target;
373 // if (file.isFile()) {
374 // if (Util.isArchiveFileName(file.getName())){
378 // // external directory
383 // } catch(JavaModelException e){
386 // // iterate over all projects
387 // IJavaModel model = getJavaModel();
388 // IJavaProject[] jProjects = model.getJavaProjects();
389 // for (int i = 0, max = jProjects.length; i < max; i++){
390 // JavaProject jProject = (JavaProject) jProjects[i];
391 // if (jProject == parentProject) continue; // already done
393 // entry = jProject.getClasspathEntryFor(rootPath);
394 // if (entry != null){
395 // Object target = JavaModel.getTarget(workspaceRoot, entry.getSourceAttachmentPath(), true);
396 // if (target instanceof IFile){
397 // IFile file = (IFile) target;
398 // if (Util.isArchiveFileName(file.getName())){
401 // } else if (target instanceof IFolder) {
404 // if (target instanceof java.io.File){
405 // java.io.File file = (java.io.File) target;
406 // if (file.isFile()) {
407 // if (Util.isArchiveFileName(file.getName())){
411 // // external directory
416 // } catch(JavaModelException e){
419 // } catch(JavaModelException e){
426 * Returns the exclusion patterns from the classpath entry associated with this root.
428 //char[][] fullExclusionPatternChars() {
430 // if (this.isOpen() && this.getKind() != IPackageFragmentRoot.K_SOURCE) return null;
431 // ClasspathEntry entry = (ClasspathEntry)getRawClasspathEntry();
432 // if (entry == null) {
435 // return entry.fullExclusionPatternChars();
437 // } catch (JavaModelException e) {
445 //protected boolean generateInfos(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException {
447 // ((PackageFragmentRootInfo) info).setRootKind(determineKind(underlyingResource));
448 // return computeChildren(info);
452 * @see JavaElement#getHandleMemento()
454 protected char getHandleMementoDelimiter() {
455 return JavaElement.JEM_PACKAGEFRAGMENTROOT;
458 * @see JavaElement#getHandleMemento()
460 public String getHandleMemento(){
462 IResource resource = getResource();
463 if (resource != null) {
464 // internal jar or regular root
465 if (getResource().getProject().equals(getJavaProject().getProject())) {
466 path = resource.getProjectRelativePath();
468 path = resource.getFullPath();
474 StringBuffer buff= new StringBuffer(((JavaElement)getParent()).getHandleMemento());
475 buff.append(getHandleMementoDelimiter());
476 buff.append(path.toString());
477 return buff.toString();
480 * @see IPackageFragmentRoot
482 //public int getKind() throws JavaModelException {
483 // return ((PackageFragmentRootInfo)getElementInfo()).getRootKind();
487 * Returns an array of non-java resources contained in the receiver.
489 //public Object[] getNonJavaResources() throws JavaModelException {
490 // return ((PackageFragmentRootInfo) getElementInfo()).getNonJavaResources(getJavaProject(), getResource(), this);
494 * @see IPackageFragmentRoot
496 public IPackageFragment getPackageFragment(String packageName) {
497 if (packageName.indexOf(' ') != -1) { // tolerate package names with spaces (e.g. 'x . y') (http://bugs.eclipse.org/bugs/show_bug.cgi?id=21957)
498 char[][] compoundName = Util.toCompoundChars(packageName);
499 StringBuffer buffer = new StringBuffer(packageName.length());
500 for (int i = 0, length = compoundName.length; i < length; i++) {
501 buffer.append(CharOperation.trim(compoundName[i]));
506 packageName = buffer.toString();
508 return new PackageFragment(this, packageName);
512 * Returns the package name for the given folder
513 * (which is a decendent of this root).
515 protected String getPackageName(IFolder folder) throws JavaModelException {
516 IPath myPath= getPath();
517 IPath pkgPath= folder.getFullPath();
518 int mySegmentCount= myPath.segmentCount();
519 int pkgSegmentCount= pkgPath.segmentCount();
520 StringBuffer name = new StringBuffer(IPackageFragment.DEFAULT_PACKAGE_NAME);
521 for (int i= mySegmentCount; i < pkgSegmentCount; i++) {
522 if (i > mySegmentCount) {
525 name.append(pkgPath.segment(i));
527 return name.toString();
533 public IPath getPath() {
534 return getResource().getFullPath();
538 * @see IPackageFragmentRoot
540 //public IClasspathEntry getRawClasspathEntry() throws JavaModelException {
542 // IClasspathEntry rawEntry = null;
543 // IJavaProject project = this.getJavaProject();
544 // project.getResolvedClasspath(true); // force the reverse rawEntry cache to be populated
545 // JavaModelManager.PerProjectInfo perProjectInfo =
546 // JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(project.getProject());
547 // if (perProjectInfo != null && perProjectInfo.resolvedPathToRawEntries != null) {
548 // rawEntry = (IClasspathEntry) perProjectInfo.resolvedPathToRawEntries.get(this.getPath());
556 public IResource getResource() {
557 return (IResource)this.resource;
561 * @see IPackageFragmentRoot
563 //public IPath getSourceAttachmentPath() throws JavaModelException {
564 // if (getKind() != K_BINARY) return null;
566 // String serverPathString= getSourceAttachmentProperty();
567 // if (serverPathString == null) {
570 // int index= serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
572 // // no root path specified
573 // return new Path(serverPathString);
575 // String serverSourcePathString= serverPathString.substring(0, index);
576 // return new Path(serverSourcePathString);
581 * Returns the server property for this package fragment root's
582 * source attachement.
584 //protected String getSourceAttachmentProperty() throws JavaModelException {
585 // String propertyString = null;
586 // QualifiedName qName= getSourceAttachmentPropertyName();
588 // propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
590 // // if no existing source attachment information, then lookup a recommendation from classpath entries
591 // if (propertyString == null) {
592 // IClasspathEntry recommendation = findSourceAttachmentRecommendation();
593 // if (recommendation != null) {
594 // IPath rootPath = recommendation.getSourceAttachmentRootPath();
596 // recommendation.getSourceAttachmentPath().toString()
597 // + ((rootPath == null)
598 // ? "" : //$NON-NLS-1$
599 // (ATTACHMENT_PROPERTY_DELIMITER + rootPath.toString()));
600 // setSourceAttachmentProperty(propertyString);
602 // // mark as being already looked up
603 // setSourceAttachmentProperty(NO_SOURCE_ATTACHMENT);
605 // } else if (NO_SOURCE_ATTACHMENT.equals(propertyString)) {
606 // // already looked up and no source attachment found
609 // return propertyString;
610 // } catch (CoreException ce) {
611 // throw new JavaModelException(ce);
616 * Returns the qualified name for the source attachment property
619 protected QualifiedName getSourceAttachmentPropertyName() throws JavaModelException {
620 return new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + this.getPath().toOSString()); //$NON-NLS-1$
623 public void setSourceAttachmentProperty(String property) {
625 ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(this.getSourceAttachmentPropertyName(), property);
626 } catch (CoreException ce) {
631 * For use by <code>AttachSourceOperation</code> only.
632 * Sets the source mapper associated with this root.
634 //public void setSourceMapper(SourceMapper mapper) throws JavaModelException {
635 // ((PackageFragmentRootInfo) getElementInfo()).setSourceMapper(mapper);
641 * @see IPackageFragmentRoot
643 //public IPath getSourceAttachmentRootPath() throws JavaModelException {
644 // if (getKind() != K_BINARY) return null;
646 // String serverPathString= getSourceAttachmentProperty();
647 // if (serverPathString == null) {
650 // int index = serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
651 // if (index == -1) return null;
652 // String serverRootPathString= IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH;
653 // if (index != serverPathString.length() - 1) {
654 // serverRootPathString= serverPathString.substring(index + 1);
656 // return new Path(serverRootPathString);
662 //public SourceMapper getSourceMapper() {
663 // SourceMapper mapper;
665 // PackageFragmentRootInfo rootInfo = (PackageFragmentRootInfo) getElementInfo();
666 // mapper = rootInfo.getSourceMapper();
667 // if (mapper == null) {
668 // // first call to this method
669 // IPath sourcePath= getSourceAttachmentPath();
670 // if (sourcePath != null) {
671 // IPath rootPath= getSourceAttachmentRootPath();
672 // mapper = this.createSourceMapper(sourcePath, rootPath);
673 // if (rootPath == null && mapper.rootPath != null) {
674 // // as a side effect of calling the SourceMapper constructor, the root path was computed
675 // rootPath = new Path(mapper.rootPath);
677 // //set the property to the path of the mapped source
678 // this.setSourceAttachmentProperty(
679 // sourcePath.toString()
680 // + ATTACHMENT_PROPERTY_DELIMITER
681 // + rootPath.toString());
683 // rootInfo.setSourceMapper(mapper);
685 // // remember that no source is attached
686 // rootInfo.setSourceMapper(NO_SOURCE_MAPPER);
689 // } else if (mapper == NO_SOURCE_MAPPER) {
690 // // a previous call to this method found out that no source was attached
693 // } catch (JavaModelException e) {
694 // // no source can be attached
703 public IResource getUnderlyingResource() throws JavaModelException {
704 if (!exists()) throw newNotPresentException();
705 return getResource();
708 public int hashCode() {
709 return this.resource.hashCode();
713 * @see IPackageFragmentRoot
715 public boolean isArchive() {
720 * @see IPackageFragmentRoot
722 public boolean isExternal() {
727 * Returns whether this package fragment root is on the classpath of its project.
729 //protected boolean isOnClasspath() {
730 // if (this.getElementType() == IJavaElement.JAVA_PROJECT){
734 // IPath path = this.getPath();
736 // // check package fragment root on classpath of its project
737 // IJavaProject project = this.getJavaProject();
738 // IClasspathEntry[] classpath = project.getResolvedClasspath(true);
739 // for (int i = 0, length = classpath.length; i < length; i++) {
740 // IClasspathEntry entry = classpath[i];
741 // if (entry.getPath().equals(path)) {
745 // } catch(JavaModelException e){
746 // // could not read classpath, then assume it is outside
751 * @see org.eclipse.jdt.core.IPackageFragmentRoot#move
754 // IPath destination,
755 // int updateResourceFlags,
756 // int updateModelFlags,
757 // IClasspathEntry sibling,
758 // IProgressMonitor monitor)
759 // throws JavaModelException {
761 // MovePackageFragmentRootOperation op =
762 // new MovePackageFragmentRootOperation(this, destination, updateResourceFlags, updateModelFlags, sibling);
763 // runOperation(op, monitor);
767 //protected void openWhenClosed(IProgressMonitor pm) throws JavaModelException {
768 // if (!this.resourceExists()
769 // || !this.isOnClasspath()) {
770 // throw newNotPresentException();
772 // super.openWhenClosed(pm);
776 * Recomputes the children of this element, based on the current state
779 //public void refreshChildren() {
781 // OpenableElementInfo info= (OpenableElementInfo)getElementInfo();
782 // computeChildren(info);
783 // } catch (JavaModelException e) {
789 * @see JavaElement#rootedAt(IJavaProject)
791 public IJavaElement rootedAt(IJavaProject project) {
793 new PackageFragmentRoot(
800 * @private Debugging purposes
802 protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
803 buffer.append(this.tabString(tab));
804 if (getElementName().length() == 0) {
805 buffer.append("[project root]"); //$NON-NLS-1$
807 IPath path = getPath();
808 if (getJavaProject().getElementName().equals(path.segment(0))) {
809 buffer.append(path.removeFirstSegments(1).makeRelative());
815 buffer.append(" (not open)"); //$NON-NLS-1$
820 * Possible failures: <ul>
821 * <li>ELEMENT_NOT_PRESENT - the root supplied to the operation
823 * <li>INVALID_ELEMENT_TYPES - the root is not of kind K_BINARY
824 * <li>RELATIVE_PATH - the path supplied to this operation must be
828 //protected void verifyAttachSource(IPath sourcePath) throws JavaModelException {
830 // throw newNotPresentException();
831 // } else if (this.getKind() != K_BINARY) {
832 // throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this));
833 // } else if (sourcePath != null && !sourcePath.isAbsolute()) {
834 // throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.RELATIVE_PATH, sourcePath));