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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/util/HandleFactory.java (-16 / +11 lines)
Lines 258-270 Link Here
258
			//        is NOT on the classpath of org.eclipse.swt.win32
258
			//        is NOT on the classpath of org.eclipse.swt.win32
259
			IFile jarFile = (IFile)target;
259
			IFile jarFile = (IFile)target;
260
			JavaProject javaProject = (JavaProject) this.javaModel.getJavaProject(jarFile);
260
			JavaProject javaProject = (JavaProject) this.javaModel.getJavaProject(jarFile);
261
			IClasspathEntry[] classpathEntries;
262
			try {
261
			try {
263
				classpathEntries = javaProject.getResolvedClasspath();
262
				IClasspathEntry entry = javaProject.getClasspathEntryFor(jarPath);
264
				for (int j= 0, entryCount= classpathEntries.length; j < entryCount; j++) {
263
				if (entry != null) {
265
					if (classpathEntries[j].getPath().equals(jarPath)) {
264
					return javaProject.getPackageFragmentRoot(jarFile);
266
						return javaProject.getPackageFragmentRoot(jarFile);
267
					}
268
				}
265
				}
269
			} catch (JavaModelException e) {
266
			} catch (JavaModelException e) {
270
				// ignore and try to find another project
267
				// ignore and try to find another project
Lines 310-325 Link Here
310
		for (int i= 0, projectCount= projects.length; i < projectCount; i++) {
307
		for (int i= 0, projectCount= projects.length; i < projectCount; i++) {
311
			try {
308
			try {
312
				JavaProject javaProject= (JavaProject)projects[i];
309
				JavaProject javaProject= (JavaProject)projects[i];
313
				IClasspathEntry[] classpathEntries= javaProject.getResolvedClasspath();
310
				IClasspathEntry classpathEnty = javaProject.getClasspathEntryFor(jarPath);
314
				for (int j= 0, entryCount= classpathEntries.length; j < entryCount; j++) {
311
				if (classpathEnty != null) {
315
					if (classpathEntries[j].getPath().equals(jarPath)) {
312
					if (target instanceof IFile) {
316
						if (target instanceof IFile) {
313
						// internal jar
317
							// internal jar
314
						return javaProject.getPackageFragmentRoot((IFile)target);
318
							return javaProject.getPackageFragmentRoot((IFile)target);
315
					} else {
319
						} else {
316
						// external jar
320
							// external jar
317
						return javaProject.getPackageFragmentRoot0(jarPath);
321
							return javaProject.getPackageFragmentRoot0(jarPath);
322
						}
323
					}
318
					}
324
				}
319
				}
325
			} catch (JavaModelException e) {
320
			} catch (JavaModelException e) {
(-)model/org/eclipse/jdt/internal/core/util/Util.java (+37 lines)
Lines 1081-1086 Link Here
1081
	}
1081
	}
1082
	
1082
	
1083
	/*
1083
	/*
1084
	 * Returns the source attachment property for this package fragment root's path
1085
	 */
1086
	public static String getSourceAttachmentProperty(IPath path) throws JavaModelException {
1087
		Map rootPathToAttachments = JavaModelManager.getJavaModelManager().rootPathToAttachments;
1088
		String property = (String) rootPathToAttachments.get(path);
1089
		if (property == null) {
1090
			try {
1091
				property = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(getSourceAttachmentPropertyName(path));
1092
				if (property == null) {
1093
					rootPathToAttachments.put(path, PackageFragmentRoot.NO_SOURCE_ATTACHMENT);
1094
					return null;
1095
				}
1096
				rootPathToAttachments.put(path, property);
1097
				return property;
1098
			} catch (CoreException e)  {
1099
				throw new JavaModelException(e);
1100
			}
1101
		} else if (property.equals(PackageFragmentRoot.NO_SOURCE_ATTACHMENT)) {
1102
			return null;
1103
		} else
1104
			return property;
1105
	}
1106
	
1107
	private static QualifiedName getSourceAttachmentPropertyName(IPath path) {
1108
		return new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + path.toOSString()); //$NON-NLS-1$
1109
	}
1110
1111
	public static void setSourceAttachmentProperty(IPath path, String property) {
1112
		JavaModelManager.getJavaModelManager().rootPathToAttachments.put(path, property);
1113
		try {
1114
			ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(getSourceAttachmentPropertyName(path), property);
1115
		} catch (CoreException e) {
1116
			e.printStackTrace();
1117
		}
1118
	}
1119
	
1120
	/*
1084
	 * Returns the declaring type signature of the element represented by the given binding key.
1121
	 * Returns the declaring type signature of the element represented by the given binding key.
1085
	 * Returns the signature of the element if it is a type.
1122
	 * Returns the signature of the element if it is a type.
1086
	 * 
1123
	 * 
(-)model/org/eclipse/jdt/internal/core/ExternalJavaProject.java (-1 / +1 lines)
Lines 27-33 Link Here
27
	public ExternalJavaProject(IClasspathEntry[] rawClasspath) {
27
	public ExternalJavaProject(IClasspathEntry[] rawClasspath) {
28
		super(ResourcesPlugin.getWorkspace().getRoot().getProject(EXTERNAL_PROJECT_NAME), JavaModelManager.getJavaModelManager().getJavaModel());
28
		super(ResourcesPlugin.getWorkspace().getRoot().getProject(EXTERNAL_PROJECT_NAME), JavaModelManager.getJavaModelManager().getJavaModel());
29
		try {
29
		try {
30
			getPerProjectInfo().setClasspath(rawClasspath, defaultOutputLocation(), JavaModelStatus.VERIFIED_OK/*no .classpath format problem*/, null/*no resolved claspath*/, null/*no reverse map*/, null/*no resolved status*/);
30
			getPerProjectInfo().setClasspath(rawClasspath, defaultOutputLocation(), JavaModelStatus.VERIFIED_OK/*no .classpath format problem*/, null/*no resolved claspath*/, null/*no reverse map*/, null/*no resolve entry map*/, null/*no resolved status*/);
31
		} catch (JavaModelException e) {
31
		} catch (JavaModelException e) {
32
			// getPerProjectInfo() never throws JavaModelException for an ExternalJavaProject
32
			// getPerProjectInfo() never throws JavaModelException for an ExternalJavaProject
33
		}
33
		}
(-)model/org/eclipse/jdt/internal/core/SetClasspathOperation.java (-1 / +1 lines)
Lines 50-56 Link Here
50
		checkCanceled();
50
		checkCanceled();
51
		try {
51
		try {
52
			// set raw classpath and null out resolved info
52
			// set raw classpath and null out resolved info
53
			this.project.getPerProjectInfo().setClasspath(this.newRawClasspath, this.newOutputLocation, JavaModelStatus.VERIFIED_OK/*format is ok*/, null, null, null);
53
			this.project.getPerProjectInfo().setClasspath(this.newRawClasspath, this.newOutputLocation, JavaModelStatus.VERIFIED_OK/*format is ok*/, null, null, null, null);
54
			
54
			
55
			// if needed, generate delta, update project ref, create markers, ...
55
			// if needed, generate delta, update project ref, create markers, ...
56
			classpathChanged(this.project);
56
			classpathChanged(this.project);
(-)model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java (-107 / +63 lines)
Lines 15-27 Link Here
15
import java.util.Map;
15
import java.util.Map;
16
16
17
import org.eclipse.core.resources.*;
17
import org.eclipse.core.resources.*;
18
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.core.resources.IFolder;
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.*;
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.jdt.core.*;
19
import org.eclipse.jdt.core.*;
26
import org.eclipse.jdt.core.compiler.CharOperation;
20
import org.eclipse.jdt.core.compiler.CharOperation;
27
import org.eclipse.jdt.internal.core.util.MementoTokenizer;
21
import org.eclipse.jdt.internal.core.util.MementoTokenizer;
Lines 41-47 Link Here
41
	/*
35
	/*
42
	 * No source attachment property
36
	 * No source attachment property
43
	 */
37
	 */
44
	protected final static String NO_SOURCE_ATTACHMENT = ""; //$NON-NLS-1$
38
	public final static String NO_SOURCE_ATTACHMENT = ""; //$NON-NLS-1$
45
39
46
	/**
40
	/**
47
	 * The resource associated with this root.
41
	 * The resource associated with this root.
Lines 119-128 Link Here
119
			setSourceMapper(mapper);
113
			setSourceMapper(mapper);
120
		}
114
		}
121
		if (sourcePath == null) {
115
		if (sourcePath == null) {
122
			setSourceAttachmentProperty(null); //remove the property
116
			Util.setSourceAttachmentProperty(getPath(), null); //remove the property
123
		} else {
117
		} else {
124
			//set the property to the path of the mapped source
118
			//set the property to the path of the mapped source
125
			setSourceAttachmentProperty(
119
			Util.setSourceAttachmentProperty(
120
				getPath(),
126
				sourcePath.toString() 
121
				sourcePath.toString() 
127
				+ (rootPath == null ? "" : (ATTACHMENT_PROPERTY_DELIMITER + rootPath.toString()))); //$NON-NLS-1$
122
				+ (rootPath == null ? "" : (ATTACHMENT_PROPERTY_DELIMITER + rootPath.toString()))); //$NON-NLS-1$
128
		}
123
		}
Lines 144-150 Link Here
144
			}
139
			}
145
		}
140
		}
146
	} catch (JavaModelException e) {
141
	} catch (JavaModelException e) {
147
		setSourceAttachmentProperty(null); // loose info - will be recomputed
142
		Util.setSourceAttachmentProperty(getPath(), null); // loose info - will be recomputed
148
		throw e;
143
		throw e;
149
	} finally {
144
	} finally {
150
		if (monitor != null) {
145
		if (monitor != null) {
Lines 316-327 Link Here
316
 * 		not exist.
311
 * 		not exist.
317
 */
312
 */
318
protected int determineKind(IResource underlyingResource) throws JavaModelException {
313
protected int determineKind(IResource underlyingResource) throws JavaModelException {
319
	IClasspathEntry[] entries= ((JavaProject)getJavaProject()).getResolvedClasspath();
314
	IClasspathEntry entry = ((JavaProject)getJavaProject()).getClasspathEntryFor(underlyingResource.getFullPath());
320
	for (int i= 0; i < entries.length; i++) {
315
	if (entry != null) {
321
		IClasspathEntry entry= entries[i];
316
		return entry.getContentKind();
322
		if (entry.getPath().equals(underlyingResource.getFullPath())) {
323
			return entry.getContentKind();
324
		}
325
	}
317
	}
326
	return IPackageFragmentRoot.K_SOURCE;
318
	return IPackageFragmentRoot.K_SOURCE;
327
}
319
}
Lines 349-355 Link Here
349
	return super.exists() && validateOnClasspath().isOK();
341
	return super.exists() && validateOnClasspath().isOK();
350
}
342
}
351
343
352
public IClasspathEntry findSourceAttachmentRecommendation() {
344
private IClasspathEntry findSourceAttachmentRecommendation() {
353
	try {
345
	try {
354
		IPath rootPath = this.getPath();
346
		IPath rootPath = this.getPath();
355
		IClasspathEntry entry;
347
		IClasspathEntry entry;
Lines 587-595 Link Here
587
	IClasspathEntry rawEntry = null;
579
	IClasspathEntry rawEntry = null;
588
	JavaProject project = (JavaProject)this.getJavaProject();
580
	JavaProject project = (JavaProject)this.getJavaProject();
589
	project.getResolvedClasspath(); // force the reverse rawEntry cache to be populated
581
	project.getResolvedClasspath(); // force the reverse rawEntry cache to be populated
590
	Map resolvedPathToRawEntries = project.getPerProjectInfo().resolvedPathToRawEntries;
582
	Map rootPathToRawEntries = project.getPerProjectInfo().rootPathToRawEntries;
591
	if (resolvedPathToRawEntries != null) {
583
	if (rootPathToRawEntries != null) {
592
		rawEntry = (IClasspathEntry) resolvedPathToRawEntries.get(this.getPath());
584
		rawEntry = (IClasspathEntry) rootPathToRawEntries.get(this.getPath());
593
	}
585
	}
594
	return rawEntry;
586
	return rawEntry;
595
}
587
}
Lines 607-675 Link Here
607
public IPath getSourceAttachmentPath() throws JavaModelException {
599
public IPath getSourceAttachmentPath() throws JavaModelException {
608
	if (getKind() != K_BINARY) return null;
600
	if (getKind() != K_BINARY) return null;
609
	
601
	
610
	String serverPathString= getSourceAttachmentProperty();
602
	// 1) look source attachment property (set iff attachSource(...) was called
611
	if (serverPathString == null) {
603
	IPath path = getPath();
612
		return null;
604
	String serverPathString= Util.getSourceAttachmentProperty(path);
613
	}
605
	if (serverPathString != null) {
614
	int index= serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
606
		int index= serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
615
	if (index < 0) {
607
		if (index < 0) {
616
		// no root path specified
608
			// no root path specified
617
		return new Path(serverPathString);
609
			return new Path(serverPathString);
618
	} else {
610
		} else {
619
		String serverSourcePathString= serverPathString.substring(0, index);
611
			String serverSourcePathString= serverPathString.substring(0, index);
620
		return new Path(serverSourcePathString);
612
			return new Path(serverSourcePathString);
621
	}
622
}
623
624
/**
625
 * Returns the server property for this package fragment root's
626
 * source attachement.
627
 */
628
protected String getSourceAttachmentProperty() throws JavaModelException {
629
	String propertyString = null;
630
	QualifiedName qName= getSourceAttachmentPropertyName();
631
	try {
632
		propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
633
		
634
		// if no existing source attachment information, then lookup a recommendation from classpath entries
635
		if (propertyString == null) {
636
			IClasspathEntry recommendation = findSourceAttachmentRecommendation();
637
			if (recommendation != null) {
638
				IPath rootPath = recommendation.getSourceAttachmentRootPath();
639
				propertyString = 
640
					recommendation.getSourceAttachmentPath().toString() 
641
						+ ((rootPath == null) 
642
							? "" : //$NON-NLS-1$
643
							(ATTACHMENT_PROPERTY_DELIMITER + rootPath.toString())); 
644
				setSourceAttachmentProperty(propertyString);
645
			} else {
646
				// mark as being already looked up
647
				setSourceAttachmentProperty(NO_SOURCE_ATTACHMENT);
648
			}
649
		} else if (NO_SOURCE_ATTACHMENT.equals(propertyString)) {
650
			// already looked up and no source attachment found
651
			return null;
652
		}
613
		}
653
		return propertyString;
654
	} catch (CoreException ce) {
655
		throw new JavaModelException(ce);
656
	}
614
	}
657
}
658
	
659
/**
660
 * Returns the qualified name for the source attachment property
661
 * of this root.
662
 */
663
protected QualifiedName getSourceAttachmentPropertyName() {
664
	return new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + this.getPath().toOSString()); //$NON-NLS-1$
665
}
666
615
667
public void setSourceAttachmentProperty(String property) {
616
	// 2) look at classpath entry
668
	try {
617
	IClasspathEntry entry = ((JavaProject) getParent()).getClasspathEntryFor(path);
669
		ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(this.getSourceAttachmentPropertyName(), property);
618
	IPath sourceAttachmentPath;
670
	} catch (CoreException ce) {
619
	if (entry != null && (sourceAttachmentPath = entry.getSourceAttachmentPath()) != null)
671
		// ignore
620
		return sourceAttachmentPath;
621
	
622
	// 3) look for a recommendation
623
	entry = findSourceAttachmentRecommendation();
624
	if (entry != null && (sourceAttachmentPath = entry.getSourceAttachmentPath()) != null) {
625
		return sourceAttachmentPath;
672
	}
626
	}
627
	
628
	return null;	
673
}
629
}
674
630
675
/**
631
/**
Lines 688-704 Link Here
688
public IPath getSourceAttachmentRootPath() throws JavaModelException {
644
public IPath getSourceAttachmentRootPath() throws JavaModelException {
689
	if (getKind() != K_BINARY) return null;
645
	if (getKind() != K_BINARY) return null;
690
	
646
	
691
	String serverPathString= getSourceAttachmentProperty();
647
	// 1) look source attachment property (set iff attachSource(...) was called
692
	if (serverPathString == null) {
648
	IPath path = getPath();
693
		return null;
649
	String serverPathString= Util.getSourceAttachmentProperty(path);
694
	}
650
	if (serverPathString != null) {
695
	int index = serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
651
		int index = serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
696
	if (index == -1) return null;
652
		if (index == -1) return null;
697
	String serverRootPathString= IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH;
653
		String serverRootPathString= IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH;
698
	if (index != serverPathString.length() - 1) {
654
		if (index != serverPathString.length() - 1) {
699
		serverRootPathString= serverPathString.substring(index + 1);
655
			serverRootPathString= serverPathString.substring(index + 1);
700
	}
656
		}
701
	return new Path(serverRootPathString);
657
		return new Path(serverRootPathString);
658
	}
659
660
	// 2) look at classpath entry
661
	IClasspathEntry entry = ((JavaProject) getParent()).getClasspathEntryFor(path);
662
	IPath sourceAttachmentRootPath;
663
	if (entry != null && (sourceAttachmentRootPath = entry.getSourceAttachmentRootPath()) != null)
664
		return sourceAttachmentRootPath;
665
	
666
	// 3) look for a recomendation
667
	entry = findSourceAttachmentRecommendation();
668
	if (entry != null && (sourceAttachmentRootPath = entry.getSourceAttachmentRootPath()) != null)
669
		return sourceAttachmentRootPath;
670
	
671
	return null;	
702
}
672
}
703
673
704
/**
674
/**
Lines 717-733 Link Here
717
				mapper = createSourceMapper(getPath(), rootPath); // attach root to itself
687
				mapper = createSourceMapper(getPath(), rootPath); // attach root to itself
718
			else
688
			else
719
				mapper = createSourceMapper(sourcePath, rootPath);
689
				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);
690
			rootInfo.setSourceMapper(mapper);
732
		}
691
		}
733
	} catch (JavaModelException e) {
692
	} catch (JavaModelException e) {
Lines 780-791 Link Here
780
	try {
739
	try {
781
		// check package fragment root on classpath of its project
740
		// check package fragment root on classpath of its project
782
		JavaProject project = (JavaProject) getJavaProject();
741
		JavaProject project = (JavaProject) getJavaProject();
783
		IClasspathEntry[] classpath = project.getResolvedClasspath();	
742
		IClasspathEntry entry = project.getClasspathEntryFor(path);	
784
		for (int i = 0, length = classpath.length; i < length; i++) {
743
		if (entry != null) {
785
			IClasspathEntry entry = classpath[i];
744
			return Status.OK_STATUS;
786
			if (entry.getPath().equals(path)) {
787
				return Status.OK_STATUS;
788
			}
789
		}
745
		}
790
	} catch(JavaModelException e){
746
	} catch(JavaModelException e){
791
		// could not read classpath, then assume it is outside
747
		// could not read classpath, then assume it is outside
(-)model/org/eclipse/jdt/internal/core/JavaProject.java (-31 / +21 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
Lines 1354-1369 Link Here
1354
	 * @return IClasspathEntry
1340
	 * @return IClasspathEntry
1355
	 * @throws JavaModelException
1341
	 * @throws JavaModelException
1356
	 */
1342
	 */
1357
	public IClasspathEntry getClasspathEntryFor(IPath path)
1343
	public IClasspathEntry getClasspathEntryFor(IPath path) throws JavaModelException {
1358
		throws JavaModelException {
1344
		getResolvedClasspath(); // force resolution
1359
1345
		PerProjectInfo perProjectInfo = getPerProjectInfo();
1360
		IClasspathEntry[] entries = getExpandedClasspath();
1346
		if (perProjectInfo == null)
1361
		for (int i = 0; i < entries.length; i++) {
1347
			return null;
1362
			if (entries[i].getPath().equals(path)) {
1348
		Map rootPathToResolvedEntries = perProjectInfo.rootPathToResolvedEntries;
1363
				return entries[i];
1349
		if (rootPathToResolvedEntries == null)
1364
			}
1350
			return null;
1365
		}
1351
		return (IClasspathEntry) rootPathToResolvedEntries.get(path);
1366
		return null;
1367
	}
1352
	}
1368
	
1353
	
1369
	/*
1354
	/*
Lines 2552-2557 Link Here
2552
			 			
2537
			 			
2553
			IJavaModelStatus unresolvedEntryStatus = JavaModelStatus.VERIFIED_OK;
2538
			IJavaModelStatus unresolvedEntryStatus = JavaModelStatus.VERIFIED_OK;
2554
			HashMap rawReverseMap = new HashMap();
2539
			HashMap rawReverseMap = new HashMap();
2540
			Map rootPathToResolvedEntries = new HashMap();
2555
			
2541
			
2556
			ArrayList resolvedEntries = new ArrayList();
2542
			ArrayList resolvedEntries = new ArrayList();
2557
			int length = rawClasspath.length;
2543
			int length = rawClasspath.length;
Lines 2575-2582 Link Here
2575
						if (resolvedEntry == null) {
2561
						if (resolvedEntry == null) {
2576
							unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND, this, rawEntry.getPath());
2562
							unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND, this, rawEntry.getPath());
2577
						} else {
2563
						} else {
2578
							if (rawReverseMap != null) {
2564
							if (rawReverseMap.get(resolvedPath = resolvedEntry.getPath()) == null) {
2579
								if (rawReverseMap.get(resolvedPath = resolvedEntry.getPath()) == null) rawReverseMap.put(resolvedPath , rawEntry);
2565
								rawReverseMap.put(resolvedPath , rawEntry);
2566
								rootPathToResolvedEntries.put(resolvedPath, resolvedEntry);
2580
							}
2567
							}
2581
							resolvedEntries.add(resolvedEntry);
2568
							resolvedEntries.add(resolvedEntry);
2582
						}
2569
						}
Lines 2603-2627 Link Here
2603
							}
2590
							}
2604
							// if container is exported or restricted, then its nested entries must in turn be exported  (21749) and/or propagate restrictions
2591
							// if container is exported or restricted, then its nested entries must in turn be exported  (21749) and/or propagate restrictions
2605
							cEntry = cEntry.combineWith((ClasspathEntry) rawEntry);
2592
							cEntry = cEntry.combineWith((ClasspathEntry) rawEntry);
2606
							if (rawReverseMap != null) {
2593
							if (rawReverseMap.get(resolvedPath = cEntry.getPath()) == null) {
2607
								if (rawReverseMap.get(resolvedPath = cEntry.getPath()) == null) rawReverseMap.put(resolvedPath , rawEntry);
2594
								rawReverseMap.put(resolvedPath , rawEntry);
2595
								rootPathToResolvedEntries.put(resolvedPath, cEntry);
2608
							}
2596
							}
2609
							resolvedEntries.add(cEntry);
2597
							resolvedEntries.add(cEntry);
2610
						}
2598
						}
2611
						break;
2599
						break;
2612
											
2600
											
2613
					default :
2601
					default :
2614
						if (rawReverseMap != null) {
2602
						if (rawReverseMap.get(resolvedPath = rawEntry.getPath()) == null) {
2615
							if (rawReverseMap.get(resolvedPath = rawEntry.getPath()) == null) rawReverseMap.put(resolvedPath , rawEntry);
2603
							rawReverseMap.put(resolvedPath , rawEntry);
2604
							rootPathToResolvedEntries.put(resolvedPath, rawEntry);
2616
						}
2605
						}
2617
						resolvedEntries.add(rawEntry);
2606
						resolvedEntries.add(rawEntry);
2607
2618
				}					
2608
				}					
2619
			}
2609
			}
2620
	
2610
	
2621
			// store resolved info along with the raw info to ensure consistency
2611
			// store resolved info along with the raw info to ensure consistency
2622
			IClasspathEntry[] resolvedClasspath = new IClasspathEntry[resolvedEntries.size()];
2612
			IClasspathEntry[] resolvedClasspath = new IClasspathEntry[resolvedEntries.size()];
2623
			resolvedEntries.toArray(resolvedClasspath);
2613
			resolvedEntries.toArray(resolvedClasspath);
2624
			perProjectInfo.setClasspath(rawClasspath, outputLocation, rawClasspathStatus, resolvedClasspath, rawReverseMap, unresolvedEntryStatus);
2614
			perProjectInfo.setClasspath(rawClasspath, outputLocation, rawClasspathStatus, resolvedClasspath, rawReverseMap, rootPathToResolvedEntries, unresolvedEntryStatus);
2625
		} finally {
2615
		} finally {
2626
			manager.setClasspathBeingResolved(this, false);
2616
			manager.setClasspathBeingResolved(this, false);
2627
		}
2617
		}
(-)model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java (-10 / +6 lines)
Lines 100-118 Link Here
100
		boolean binIsProject = false;
100
		boolean binIsProject = false;
101
		char[][] inclusionPatterns = null;
101
		char[][] inclusionPatterns = null;
102
		char[][] exclusionPatterns = null;
102
		char[][] exclusionPatterns = null;
103
		IClasspathEntry[] classpath = null;
104
		IPath projectOutput = null;
103
		IPath projectOutput = null;
105
		boolean isClasspathResolved = true;
104
		boolean isClasspathResolved = true;
106
		try {
105
		try {
107
			classpath = project.getResolvedClasspath();
106
			IClasspathEntry entry = project.getClasspathEntryFor(projectPath);
108
			for (int i = 0; i < classpath.length; i++) {
107
			if (entry != null) {
109
				IClasspathEntry entry = classpath[i];
108
				srcIsProject = true;
110
				if (projectPath.equals(entry.getPath())) {
109
				inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars();
111
					srcIsProject = true;
110
				exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
112
					inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars();
113
					exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
114
					break;
115
				}
116
			}
111
			}
117
			projectOutput = project.getOutputLocation();
112
			projectOutput = project.getOutputLocation();
118
			binIsProject = projectPath.equals(projectOutput);
113
			binIsProject = projectPath.equals(projectOutput);
Lines 128-133 Link Here
128
			if (length > 0) {
123
			if (length > 0) {
129
				String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
124
				String sourceLevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
130
				String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
125
				String complianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
126
				IClasspathEntry[] classpath = project.getResolvedClasspath();
131
				for (int i = 0; i < length; i++) {
127
				for (int i = 0; i < length; i++) {
132
					IResource res = members[i];
128
					IResource res = members[i];
133
					switch (res.getType()) {
129
					switch (res.getType()) {
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-12 / +15 lines)
Lines 123-128 Link Here
123
	 * Extension used to construct Java 6 annotation processor managers
123
	 * Extension used to construct Java 6 annotation processor managers
124
	 */
124
	 */
125
	private IConfigurationElement annotationProcessorManagerFactory = null;
125
	private IConfigurationElement annotationProcessorManagerFactory = null;
126
	
127
	/* 
128
	 * Map from a package fragment root's path to a source attachment property (source path + ATTACHMENT_PROPERTY_DELIMITER + source root path)
129
	 */
130
	public Map rootPathToAttachments = new HashMap();
126
131
127
	public final static String CP_VARIABLE_PREFERENCES_PREFIX = JavaCore.PLUGIN_ID+".classpathVariable."; //$NON-NLS-1$
132
	public final static String CP_VARIABLE_PREFERENCES_PREFIX = JavaCore.PLUGIN_ID+".classpathVariable."; //$NON-NLS-1$
128
	public final static String CP_CONTAINER_PREFERENCES_PREFIX = JavaCore.PLUGIN_ID+".classpathContainer."; //$NON-NLS-1$
133
	public final static String CP_CONTAINER_PREFERENCES_PREFIX = JavaCore.PLUGIN_ID+".classpathContainer."; //$NON-NLS-1$
Lines 862-874 Link Here
862
		// Create a jar package fragment root only if on the classpath
867
		// Create a jar package fragment root only if on the classpath
863
		IPath resourcePath = file.getFullPath();
868
		IPath resourcePath = file.getFullPath();
864
		try {
869
		try {
865
			IClasspathEntry[] entries = ((JavaProject)project).getResolvedClasspath();
870
			IClasspathEntry entry = ((JavaProject)project).getClasspathEntryFor(resourcePath);
866
			for (int i = 0, length = entries.length; i < length; i++) {
871
			if (entry != null) {
867
				IClasspathEntry entry = entries[i];
872
				return project.getPackageFragmentRoot(file);
868
				IPath rootPath = entry.getPath();
869
				if (rootPath.equals(resourcePath)) {
870
					return project.getPackageFragmentRoot(file);
871
				}
872
			}
873
			}
873
		} catch (JavaModelException e) {
874
		} catch (JavaModelException e) {
874
			// project doesn't exist: return null
875
			// project doesn't exist: return null
Lines 984-990 Link Here
984
		public IJavaModelStatus rawClasspathStatus;
985
		public IJavaModelStatus rawClasspathStatus;
985
		public IClasspathEntry[] resolvedClasspath;
986
		public IClasspathEntry[] resolvedClasspath;
986
		public IJavaModelStatus unresolvedEntryStatus;
987
		public IJavaModelStatus unresolvedEntryStatus;
987
		public Map resolvedPathToRawEntries; // reverse map from resolved path to raw entries
988
		public Map rootPathToRawEntries; // reverse map from a package fragment root's path to the raw entry
989
		public Map rootPathToResolvedEntries; // map from a package fragment root's path to the resolved entry
988
		public IPath outputLocation;
990
		public IPath outputLocation;
989
		
991
		
990
		public IEclipsePreferences preferences;
992
		public IEclipsePreferences preferences;
Lines 1022-1031 Link Here
1022
		
1024
		
1023
		public synchronized void resetResolvedClasspath() {
1025
		public synchronized void resetResolvedClasspath() {
1024
			// null out resolved information
1026
			// null out resolved information
1025
			setClasspath(this.rawClasspath, this.outputLocation, this.rawClasspathStatus, null, null, null);
1027
			setClasspath(this.rawClasspath, this.outputLocation, this.rawClasspathStatus, null, null, null, null);
1026
		}
1028
		}
1027
		
1029
		
1028
		public synchronized void setClasspath(IClasspathEntry[] newRawClasspath, IPath newOutputLocation, IJavaModelStatus newRawClasspathStatus, IClasspathEntry[] newResolvedClasspath, Map newResolvedPathToRawEntries, IJavaModelStatus newUnresolvedEntryStatus) {
1030
		public synchronized void setClasspath(IClasspathEntry[] newRawClasspath, IPath newOutputLocation, IJavaModelStatus newRawClasspathStatus, IClasspathEntry[] newResolvedClasspath, Map newRootPathToRawEntries, Map newRootPathToResolvedEntries, IJavaModelStatus newUnresolvedEntryStatus) {
1029
			// remember old info
1031
			// remember old info
1030
			JavaModelManager manager = JavaModelManager.getJavaModelManager();
1032
			JavaModelManager manager = JavaModelManager.getJavaModelManager();
1031
			DeltaProcessor deltaProcessor = manager.deltaState.getDeltaProcessor();
1033
			DeltaProcessor deltaProcessor = manager.deltaState.getDeltaProcessor();
Lines 1035-1041 Link Here
1035
			this.outputLocation = newOutputLocation;
1037
			this.outputLocation = newOutputLocation;
1036
			this.rawClasspathStatus = newRawClasspathStatus;
1038
			this.rawClasspathStatus = newRawClasspathStatus;
1037
			this.resolvedClasspath = newResolvedClasspath;
1039
			this.resolvedClasspath = newResolvedClasspath;
1038
			this.resolvedPathToRawEntries = newResolvedPathToRawEntries;
1040
			this.rootPathToRawEntries = newRootPathToRawEntries;
1041
			this.rootPathToResolvedEntries = newRootPathToResolvedEntries;
1039
			this.unresolvedEntryStatus = newUnresolvedEntryStatus;
1042
			this.unresolvedEntryStatus = newUnresolvedEntryStatus;
1040
			this.javadocCache = new LRUCache(JAVADOC_CACHE_INITIAL_SIZE);
1043
			this.javadocCache = new LRUCache(JAVADOC_CACHE_INITIAL_SIZE);
1041
		}
1044
		}
Lines 1090-1096 Link Here
1090
			}
1093
			}
1091
			
1094
			
1092
			// store new raw classpath, new output and new status, and null out resolved info
1095
			// store new raw classpath, new output and new status, and null out resolved info
1093
			setClasspath(classpath, output, status, null, null, null);
1096
			setClasspath(classpath, output, status, null, null, null, null);
1094
			
1097
			
1095
			return classpath;
1098
			return classpath;
1096
		}
1099
		}
(-)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 (-4 / +3 lines)
Lines 235-246 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$;
239
						String propertyString = null;
238
						String propertyString = null;
240
						try {
239
						try {
241
							propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
240
							propertyString = Util.getSourceAttachmentProperty(path);
242
						} catch (CoreException e) {
241
						} catch (JavaModelException e) {
243
							continue;
242
							e.printStackTrace();
244
						}
243
						}
245
						IPath sourceAttachmentPath;
244
						IPath sourceAttachmentPath;
246
						if (propertyString != null) {
245
						if (propertyString != null) {
(-)model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java (-6 / +3 lines)
Lines 930-941 Link Here
930
					for (int i = 0; i < elements.length; i++) {
930
					for (int i = 0; i < elements.length; i++) {
931
						JavaProject javaProject = (JavaProject)elements[i];
931
						JavaProject javaProject = (JavaProject)elements[i];
932
						try {
932
						try {
933
							IClasspathEntry[] classpath = javaProject.getResolvedClasspath();
933
							IClasspathEntry entry = javaProject.getClasspathEntryFor(rootPath);
934
							for (int j = 0; j < classpath.length; j++) {
934
							if (entry != null) {
935
								IClasspathEntry entry = classpath[j];
935
								return true;
936
								if (entry.getPath().equals(rootPath)) {
937
									return true;
938
								}
939
							}
936
							}
940
						} catch (JavaModelException e) {
937
						} catch (JavaModelException e) {
941
							// igmore this project
938
							// igmore this project
(-)search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java (-3 / +3 lines)
Lines 129-137 Link Here
129
		switch (entry.getEntryKind()) {
129
		switch (entry.getEntryKind()) {
130
			case IClasspathEntry.CPE_LIBRARY:
130
			case IClasspathEntry.CPE_LIBRARY:
131
				IClasspathEntry rawEntry = null;
131
				IClasspathEntry rawEntry = null;
132
				Map resolvedPathToRawEntries = perProjectInfo.resolvedPathToRawEntries;
132
				Map rootPathToRawEntries = perProjectInfo.rootPathToRawEntries;
133
				if (resolvedPathToRawEntries != null) {
133
				if (rootPathToRawEntries != null) {
134
					rawEntry = (IClasspathEntry) resolvedPathToRawEntries.get(entry.getPath());
134
					rawEntry = (IClasspathEntry) rootPathToRawEntries.get(entry.getPath());
135
				}
135
				}
136
				if (rawEntry == null) break;
136
				if (rawEntry == null) break;
137
				switch (rawEntry.getEntryKind()) {
137
				switch (rawEntry.getEntryKind()) {
(-)search/org/eclipse/jdt/internal/core/search/IndexSelector.java (-7 / +5 lines)
Lines 64-76 Link Here
64
		IJavaProject[] allProjects = model.getJavaProjects();
64
		IJavaProject[] allProjects = model.getJavaProjects();
65
		for (int i = 0, length = allProjects.length; i < length; i++) {
65
		for (int i = 0, length = allProjects.length; i < length; i++) {
66
			JavaProject otherProject = (JavaProject) allProjects[i];
66
			JavaProject otherProject = (JavaProject) allProjects[i];
67
			IClasspathEntry[] entries = otherProject.getResolvedClasspath();
67
			IClasspathEntry entry = otherProject.getClasspathEntryFor(projectOrJarPath);
68
			for (int j = 0, length2 = entries.length; j < length2; j++) {
68
			if (entry != null 
69
				IClasspathEntry entry = entries[j];
69
					&& entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY 
70
				if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && entry.getPath().equals(projectOrJarPath))
70
					&& canSeeFocus(focus, otherProject, focusEntries))
71
					if (canSeeFocus(focus, otherProject, focusEntries))
71
				return true;
72
						return true;
73
			}
74
		}
72
		}
75
		return false;
73
		return false;
76
	} catch (JavaModelException e) {
74
	} catch (JavaModelException e) {
(-)search/org/eclipse/jdt/internal/core/search/HierarchyScope.java (-14 / +11 lines)
Lines 162-183 Link Here
162
			HashSet visited = new HashSet();
162
			HashSet visited = new HashSet();
163
			for (int i = 0; i < projects.length; i++) {
163
			for (int i = 0; i < projects.length; i++) {
164
				JavaProject project = (JavaProject) projects[i];
164
				JavaProject project = (JavaProject) projects[i];
165
				IClasspathEntry[] classpath = project.getResolvedClasspath();
165
				IClasspathEntry entry = project.getClasspathEntryFor(rootPath);
166
				for (int j = 0; j < classpath.length; j++) {
166
				if (entry != null) {
167
					if (rootPath.equals(classpath[j].getPath())) {
167
					// add the project and its binary pkg fragment roots
168
						// add the project and its binary pkg fragment roots
168
					IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
169
						IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
169
					set.add(project.getPath());
170
						set.add(project.getPath());
170
					for (int k = 0; k < roots.length; k++) {
171
						for (int k = 0; k < roots.length; k++) {
171
						IPackageFragmentRoot pkgFragmentRoot = roots[k];
172
							IPackageFragmentRoot pkgFragmentRoot = roots[k];
172
						if (pkgFragmentRoot.getKind() == IPackageFragmentRoot.K_BINARY) {
173
							if (pkgFragmentRoot.getKind() == IPackageFragmentRoot.K_BINARY) {
173
							set.add(pkgFragmentRoot.getPath());
174
								set.add(pkgFragmentRoot.getPath());
175
							}
176
						}
174
						}
177
						// add the dependent projects
178
						this.computeDependents(project, set, visited);
179
						break;
180
					}
175
					}
176
					// add the dependent projects
177
					this.computeDependents(project, set, visited);
181
				}
178
				}
182
			}
179
			}
183
		} else {
180
		} else {

Return to bug 145329