View | Details | Raw Unified | Return to bug 181900 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java (-11 / +20 lines)
Lines 461-466 Link Here
461
		return null;
461
		return null;
462
	}
462
	}
463
}		
463
}		
464
private IClasspathEntry getClasspathEntry() throws JavaModelException {
465
	IPath path = getPath();
466
	IClasspathEntry[] resolvedClasspath = ((JavaProject) getParent()).getResolvedClasspath(true);
467
	for (int i = 0, length = resolvedClasspath.length; i < length; i++) {
468
		IClasspathEntry entry = resolvedClasspath[i];
469
		if (path.equals(entry.getPath())) 
470
			return entry;
471
	}
472
	return null;
473
}
464
public String getElementName() {
474
public String getElementName() {
465
	if (this.resource instanceof IFolder)
475
	if (this.resource instanceof IFolder)
466
		return ((IFolder) this.resource).getName();
476
		return ((IFolder) this.resource).getName();
Lines 607-612 Link Here
607
public IPath getSourceAttachmentPath() throws JavaModelException {
617
public IPath getSourceAttachmentPath() throws JavaModelException {
608
	if (getKind() != K_BINARY) return null;
618
	if (getKind() != K_BINARY) return null;
609
	
619
	
620
	IClasspathEntry entry = getClasspathEntry();
621
	IPath sourceAttachmentPath;
622
	if (entry != null && (sourceAttachmentPath = entry.getSourceAttachmentPath()) != null)
623
		return sourceAttachmentPath;
624
610
	String serverPathString= getSourceAttachmentProperty();
625
	String serverPathString= getSourceAttachmentProperty();
611
	if (serverPathString == null) {
626
	if (serverPathString == null) {
612
		return null;
627
		return null;
Lines 688-693 Link Here
688
public IPath getSourceAttachmentRootPath() throws JavaModelException {
703
public IPath getSourceAttachmentRootPath() throws JavaModelException {
689
	if (getKind() != K_BINARY) return null;
704
	if (getKind() != K_BINARY) return null;
690
	
705
	
706
	IClasspathEntry entry = getClasspathEntry();
707
	IPath sourceAttachmentRootPath;
708
	if (entry != null && (sourceAttachmentRootPath = entry.getSourceAttachmentRootPath()) != null)
709
		return sourceAttachmentRootPath;
710
691
	String serverPathString= getSourceAttachmentProperty();
711
	String serverPathString= getSourceAttachmentProperty();
692
	if (serverPathString == null) {
712
	if (serverPathString == null) {
693
		return null;
713
		return null;
Lines 717-733 Link Here
717
				mapper = createSourceMapper(getPath(), rootPath); // attach root to itself
737
				mapper = createSourceMapper(getPath(), rootPath); // attach root to itself
718
			else
738
			else
719
				mapper = createSourceMapper(sourcePath, rootPath);
739
				mapper = createSourceMapper(sourcePath, rootPath);
720
			if (rootPath == null && mapper.rootPath != null) {
721
				// as a side effect of calling the SourceMapper constructor, the root path was computed
722
				rootPath = new Path(mapper.rootPath);
723
				
724
				//set the property to the path of the mapped source
725
				if (sourcePath != null)
726
					setSourceAttachmentProperty(
727
						sourcePath.toString() 
728
						+ ATTACHMENT_PROPERTY_DELIMITER 
729
						+ rootPath.toString());
730
			}
731
			rootInfo.setSourceMapper(mapper);
740
			rootInfo.setSourceMapper(mapper);
732
		}
741
		}
733
	} catch (JavaModelException e) {
742
	} catch (JavaModelException e) {
(-)model/org/eclipse/jdt/internal/core/JavaProject.java (-14 lines)
Lines 402-421 Link Here
402
		return true;
402
		return true;
403
	}
403
	}
404
404
405
	protected void closing(Object info) {
406
		
407
		// forget source attachment recommendations
408
		Object[] children = ((JavaElementInfo)info).children;
409
		for (int i = 0, length = children.length; i < length; i++) {
410
			Object child = children[i];
411
			if (child instanceof JarPackageFragmentRoot){
412
				((JarPackageFragmentRoot)child).setSourceAttachmentProperty(null); 
413
			}
414
		}
415
		
416
		super.closing(info);
417
	}
418
419
	/**
405
	/**
420
	 * Computes the collection of package fragment roots (local ones) and set it on the given info.
406
	 * Computes the collection of package fragment roots (local ones) and set it on the given info.
421
	 * Need to check *all* package fragment roots in order to reset NameLookup
407
	 * Need to check *all* package fragment roots in order to reset NameLookup
(-)model/org/eclipse/jdt/internal/core/ClasspathChange.java (-3 lines)
Lines 61-68 Link Here
61
				} catch (JavaModelException e) {
61
				} catch (JavaModelException e) {
62
					// ignore
62
					// ignore
63
				}
63
				}
64
				// force detach source on jar package fragment roots (source will be lazily computed when needed)
65
				((PackageFragmentRoot) root).setSourceAttachmentProperty(null);// loose info - will be recomputed
66
			}
64
			}
67
		}
65
		}
68
	}
66
	}
Lines 335-341 Link Here
335
							} catch (JavaModelException e) {
333
							} catch (JavaModelException e) {
336
								// ignore
334
								// ignore
337
							}
335
							}
338
							((PackageFragmentRoot) root).setSourceAttachmentProperty(null);// loose info - will be recomputed
339
						}
336
						}
340
					}
337
					}
341
				}
338
				}
(-)model/org/eclipse/jdt/internal/core/DeltaProcessingState.java (-13 / +13 lines)
Lines 235-253 Link Here
235
						
235
						
236
						// source attachment path
236
						// source attachment path
237
						if (entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY) continue;
237
						if (entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY) continue;
238
						QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + path.toOSString()); //$NON-NLS-1$;
238
						IPath sourceAttachmentPath = entry.getSourceAttachmentPath();
239
						String propertyString = null;
239
						if (sourceAttachmentPath == null) {
240
						try {
240
							QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + path.toOSString()); //$NON-NLS-1$;
241
							propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
241
							String propertyString = null;
242
						} catch (CoreException e) {
242
							try {
243
							continue;
243
								propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
244
						}
244
							} catch (CoreException e) {
245
						IPath sourceAttachmentPath;
245
								continue;
246
						if (propertyString != null) {
246
							}
247
							int index= propertyString.lastIndexOf(PackageFragmentRoot.ATTACHMENT_PROPERTY_DELIMITER);
247
							if (propertyString != null) {
248
							sourceAttachmentPath = (index < 0) ?  new Path(propertyString) : new Path(propertyString.substring(0, index));
248
								int index= propertyString.lastIndexOf(PackageFragmentRoot.ATTACHMENT_PROPERTY_DELIMITER);
249
						} else {
249
								sourceAttachmentPath = (index < 0) ?  new Path(propertyString) : new Path(propertyString.substring(0, index));
250
							sourceAttachmentPath = entry.getSourceAttachmentPath();
250
							}
251
						}
251
						}
252
						if (sourceAttachmentPath != null) {
252
						if (sourceAttachmentPath != null) {
253
							newSourceAttachments.put(sourceAttachmentPath, path);
253
							newSourceAttachments.put(sourceAttachmentPath, path);

Return to bug 181900