### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java,v retrieving revision 1.122 diff -u -r1.122 PackageFragmentRoot.java --- model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 16 Mar 2007 18:28:58 -0000 1.122 +++ model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 12 Apr 2007 15:05:32 -0000 @@ -461,6 +461,16 @@ return null; } } +private IClasspathEntry getClasspathEntry() throws JavaModelException { + IPath path = getPath(); + IClasspathEntry[] resolvedClasspath = ((JavaProject) getParent()).getResolvedClasspath(true); + for (int i = 0, length = resolvedClasspath.length; i < length; i++) { + IClasspathEntry entry = resolvedClasspath[i]; + if (path.equals(entry.getPath())) + return entry; + } + return null; +} public String getElementName() { if (this.resource instanceof IFolder) return ((IFolder) this.resource).getName(); @@ -607,6 +617,11 @@ public IPath getSourceAttachmentPath() throws JavaModelException { if (getKind() != K_BINARY) return null; + IClasspathEntry entry = getClasspathEntry(); + IPath sourceAttachmentPath; + if (entry != null && (sourceAttachmentPath = entry.getSourceAttachmentPath()) != null) + return sourceAttachmentPath; + String serverPathString= getSourceAttachmentProperty(); if (serverPathString == null) { return null; @@ -688,6 +703,11 @@ public IPath getSourceAttachmentRootPath() throws JavaModelException { if (getKind() != K_BINARY) return null; + IClasspathEntry entry = getClasspathEntry(); + IPath sourceAttachmentRootPath; + if (entry != null && (sourceAttachmentRootPath = entry.getSourceAttachmentRootPath()) != null) + return sourceAttachmentRootPath; + String serverPathString= getSourceAttachmentProperty(); if (serverPathString == null) { return null; @@ -717,17 +737,6 @@ mapper = createSourceMapper(getPath(), rootPath); // attach root to itself else mapper = createSourceMapper(sourcePath, rootPath); - if (rootPath == null && mapper.rootPath != null) { - // as a side effect of calling the SourceMapper constructor, the root path was computed - rootPath = new Path(mapper.rootPath); - - //set the property to the path of the mapped source - if (sourcePath != null) - setSourceAttachmentProperty( - sourcePath.toString() - + ATTACHMENT_PROPERTY_DELIMITER - + rootPath.toString()); - } rootInfo.setSourceMapper(mapper); } } catch (JavaModelException e) { Index: model/org/eclipse/jdt/internal/core/JavaProject.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java,v retrieving revision 1.386 diff -u -r1.386 JavaProject.java --- model/org/eclipse/jdt/internal/core/JavaProject.java 30 Mar 2007 12:38:03 -0000 1.386 +++ model/org/eclipse/jdt/internal/core/JavaProject.java 12 Apr 2007 15:05:32 -0000 @@ -402,20 +402,6 @@ return true; } - protected void closing(Object info) { - - // forget source attachment recommendations - Object[] children = ((JavaElementInfo)info).children; - for (int i = 0, length = children.length; i < length; i++) { - Object child = children[i]; - if (child instanceof JarPackageFragmentRoot){ - ((JarPackageFragmentRoot)child).setSourceAttachmentProperty(null); - } - } - - super.closing(info); - } - /** * Computes the collection of package fragment roots (local ones) and set it on the given info. * Need to check *all* package fragment roots in order to reset NameLookup Index: model/org/eclipse/jdt/internal/core/ClasspathChange.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathChange.java,v retrieving revision 1.5 diff -u -r1.5 ClasspathChange.java --- model/org/eclipse/jdt/internal/core/ClasspathChange.java 6 Mar 2007 02:38:49 -0000 1.5 +++ model/org/eclipse/jdt/internal/core/ClasspathChange.java 12 Apr 2007 15:05:31 -0000 @@ -61,8 +61,6 @@ } catch (JavaModelException e) { // ignore } - // force detach source on jar package fragment roots (source will be lazily computed when needed) - ((PackageFragmentRoot) root).setSourceAttachmentProperty(null);// loose info - will be recomputed } } } @@ -335,7 +333,6 @@ } catch (JavaModelException e) { // ignore } - ((PackageFragmentRoot) root).setSourceAttachmentProperty(null);// loose info - will be recomputed } } } Index: model/org/eclipse/jdt/internal/core/DeltaProcessingState.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java,v retrieving revision 1.41 diff -u -r1.41 DeltaProcessingState.java --- model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 10 Apr 2007 17:01:55 -0000 1.41 +++ model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 12 Apr 2007 15:05:31 -0000 @@ -235,19 +235,19 @@ // source attachment path if (entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY) continue; - QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + path.toOSString()); //$NON-NLS-1$; - String propertyString = null; - try { - propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName); - } catch (CoreException e) { - continue; - } - IPath sourceAttachmentPath; - if (propertyString != null) { - int index= propertyString.lastIndexOf(PackageFragmentRoot.ATTACHMENT_PROPERTY_DELIMITER); - sourceAttachmentPath = (index < 0) ? new Path(propertyString) : new Path(propertyString.substring(0, index)); - } else { - sourceAttachmentPath = entry.getSourceAttachmentPath(); + IPath sourceAttachmentPath = entry.getSourceAttachmentPath(); + if (sourceAttachmentPath == null) { + QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + path.toOSString()); //$NON-NLS-1$; + String propertyString = null; + try { + propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName); + } catch (CoreException e) { + continue; + } + if (propertyString != null) { + int index= propertyString.lastIndexOf(PackageFragmentRoot.ATTACHMENT_PROPERTY_DELIMITER); + sourceAttachmentPath = (index < 0) ? new Path(propertyString) : new Path(propertyString.substring(0, index)); + } } if (sourceAttachmentPath != null) { newSourceAttachments.put(sourceAttachmentPath, path);