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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (-1 / +1 lines)
Lines 261-267 Link Here
261
*/
261
*/
262
		p1.close();
262
		p1.close();
263
		JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(p1.getProject(), true/*create if missing*/);
263
		JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(p1.getProject(), true/*create if missing*/);
264
		perProjectInfo.setClasspath(null, null, null, null, null, null);
264
		perProjectInfo.setClasspath(null, null, null, null, null, null, null);
265
265
266
		// shouldn't fail 
266
		// shouldn't fail 
267
		p1.getExpandedClasspath();
267
		p1.getExpandedClasspath();
(-)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/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 path to 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/PackageFragmentRoot.java (-75 / +58 lines)
Lines 38-48 Link Here
38
	 * attachment server property.
38
	 * attachment server property.
39
	 */
39
	 */
40
	protected final static char ATTACHMENT_PROPERTY_DELIMITER= '*';
40
	protected final static char ATTACHMENT_PROPERTY_DELIMITER= '*';
41
	/*
42
	 * No source attachment property
43
	 */
44
	protected final static String NO_SOURCE_ATTACHMENT = ""; //$NON-NLS-1$
45
46
	/**
41
	/**
47
	 * The resource associated with this root.
42
	 * The resource associated with this root.
48
	 * (an IResource or a java.io.File (for external jar only))
43
	 * (an IResource or a java.io.File (for external jar only))
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 607-658 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
	
602
	// 1) look source attachment property (set iff attachSource(...) was called
610
	String serverPathString= getSourceAttachmentProperty();
603
	String serverPathString= getSourceAttachmentProperty();
611
	if (serverPathString == null) {
604
	if (serverPathString != null) {
612
		return null;
605
		int index= serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
606
		if (index < 0) {
607
			// no root path specified
608
			return new Path(serverPathString);
609
		} else {
610
			String serverSourcePathString= serverPathString.substring(0, index);
611
			return new Path(serverSourcePathString);
612
		}
613
	}
613
	}
614
	int index= serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
614
615
	if (index < 0) {
615
	// 2) look at classpath entry
616
		// no root path specified
616
	IClasspathEntry entry = ((JavaProject) getParent()).getClasspathEntryFor(getPath());
617
		return new Path(serverPathString);
617
	IPath sourceAttachmentPath;
618
	} else {
618
	if (entry != null && (sourceAttachmentPath = entry.getSourceAttachmentPath()) != null)
619
		String serverSourcePathString= serverPathString.substring(0, index);
619
		return sourceAttachmentPath;
620
		return new Path(serverSourcePathString);
620
	
621
	// 3) look for a recommendation
622
	entry = findSourceAttachmentRecommendation();
623
	if (entry != null && (sourceAttachmentPath = entry.getSourceAttachmentPath()) != null) {
624
		return sourceAttachmentPath;
621
	}
625
	}
626
	
627
	return null;	
622
}
628
}
623
629
624
/**
630
/**
625
 * Returns the server property for this package fragment root's
631
 * Returns the server property for this package fragment root's
626
 * source attachement.
632
 * source attachement.
627
 */
633
 */
628
protected String getSourceAttachmentProperty() throws JavaModelException {
634
private String getSourceAttachmentProperty() throws JavaModelException {
629
	String propertyString = null;
630
	QualifiedName qName= getSourceAttachmentPropertyName();
631
	try {
635
	try {
632
		propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
636
		QualifiedName qName= getSourceAttachmentPropertyName();
633
		
637
		return ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
634
		// if no existing source attachment information, then lookup a recommendation from classpath entries
638
	} catch (CoreException e) {
635
		if (propertyString == null) {
639
		throw new JavaModelException(e);
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
		}
653
		return propertyString;
654
	} catch (CoreException ce) {
655
		throw new JavaModelException(ce);
656
	}
640
	}
657
}
641
}
658
	
642
	
Lines 660-666 Link Here
660
 * Returns the qualified name for the source attachment property
644
 * Returns the qualified name for the source attachment property
661
 * of this root.
645
 * of this root.
662
 */
646
 */
663
protected QualifiedName getSourceAttachmentPropertyName() {
647
private QualifiedName getSourceAttachmentPropertyName() {
664
	return new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + this.getPath().toOSString()); //$NON-NLS-1$
648
	return new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + this.getPath().toOSString()); //$NON-NLS-1$
665
}
649
}
666
650
Lines 688-704 Link Here
688
public IPath getSourceAttachmentRootPath() throws JavaModelException {
672
public IPath getSourceAttachmentRootPath() throws JavaModelException {
689
	if (getKind() != K_BINARY) return null;
673
	if (getKind() != K_BINARY) return null;
690
	
674
	
675
	// 1) look source attachment property (set iff attachSource(...) was called
691
	String serverPathString= getSourceAttachmentProperty();
676
	String serverPathString= getSourceAttachmentProperty();
692
	if (serverPathString == null) {
677
	if (serverPathString != null) {
693
		return null;
678
		int index = serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
694
	}
679
		if (index == -1) return null;
695
	int index = serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
680
		String serverRootPathString= IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH;
696
	if (index == -1) return null;
681
		if (index != serverPathString.length() - 1) {
697
	String serverRootPathString= IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH;
682
			serverRootPathString= serverPathString.substring(index + 1);
698
	if (index != serverPathString.length() - 1) {
683
		}
699
		serverRootPathString= serverPathString.substring(index + 1);
684
		return new Path(serverRootPathString);
700
	}
685
	}
701
	return new Path(serverRootPathString);
686
687
	// 2) look at classpath entry
688
	IClasspathEntry entry = ((JavaProject) getParent()).getClasspathEntryFor(getPath());
689
	IPath sourceAttachmentRootPath;
690
	if (entry != null && (sourceAttachmentRootPath = entry.getSourceAttachmentRootPath()) != null)
691
		return sourceAttachmentRootPath;
692
	
693
	// 3) look for a recomendation
694
	entry = findSourceAttachmentRecommendation();
695
	if (entry != null && (sourceAttachmentRootPath = entry.getSourceAttachmentRootPath()) != null)
696
		return sourceAttachmentRootPath;
697
	
698
	return null;	
702
}
699
}
703
700
704
/**
701
/**
Lines 717-733 Link Here
717
				mapper = createSourceMapper(getPath(), rootPath); // attach root to itself
714
				mapper = createSourceMapper(getPath(), rootPath); // attach root to itself
718
			else
715
			else
719
				mapper = createSourceMapper(sourcePath, rootPath);
716
				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);
717
			rootInfo.setSourceMapper(mapper);
732
		}
718
		}
733
	} catch (JavaModelException e) {
719
	} catch (JavaModelException e) {
Lines 780-791 Link Here
780
	try {
766
	try {
781
		// check package fragment root on classpath of its project
767
		// check package fragment root on classpath of its project
782
		JavaProject project = (JavaProject) getJavaProject();
768
		JavaProject project = (JavaProject) getJavaProject();
783
		IClasspathEntry[] classpath = project.getResolvedClasspath();	
769
		IClasspathEntry entry = project.getClasspathEntryFor(path);	
784
		for (int i = 0, length = classpath.length; i < length; i++) {
770
		if (entry != null) {
785
			IClasspathEntry entry = classpath[i];
771
			return Status.OK_STATUS;
786
			if (entry.getPath().equals(path)) {
787
				return Status.OK_STATUS;
788
			}
789
		}
772
		}
790
	} catch(JavaModelException e){
773
	} catch(JavaModelException e){
791
		// could not read classpath, then assume it is outside
774
		// could not read classpath, then assume it is outside
(-)model/org/eclipse/jdt/internal/core/JavaProject.java (-25 / +15 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 pathToResolvedEntry = perProjectInfo.pathToResolvedEntry;
1363
				return entries[i];
1349
		if (pathToResolvedEntry == null)
1364
			}
1350
			return null;
1365
		}
1351
		return (IClasspathEntry) pathToResolvedEntry.get(path);
1366
		return null;
1367
	}
1352
	}
1368
	
1353
	
1369
	/*
1354
	/*
Lines 2554-2559 Link Here
2554
			HashMap rawReverseMap = new HashMap();
2539
			HashMap rawReverseMap = new HashMap();
2555
			
2540
			
2556
			ArrayList resolvedEntries = new ArrayList();
2541
			ArrayList resolvedEntries = new ArrayList();
2542
			Map pathToResolvedEntry = new HashMap();
2557
			int length = rawClasspath.length;
2543
			int length = rawClasspath.length;
2558
			for (int i = 0; i < length; i++) {
2544
			for (int i = 0; i < length; i++) {
2559
	
2545
	
Lines 2579-2584 Link Here
2579
								if (rawReverseMap.get(resolvedPath = resolvedEntry.getPath()) == null) rawReverseMap.put(resolvedPath , rawEntry);
2565
								if (rawReverseMap.get(resolvedPath = resolvedEntry.getPath()) == null) rawReverseMap.put(resolvedPath , rawEntry);
2580
							}
2566
							}
2581
							resolvedEntries.add(resolvedEntry);
2567
							resolvedEntries.add(resolvedEntry);
2568
							pathToResolvedEntry.put(resolvedEntry.getPath(), resolvedEntry);
2582
						}
2569
						}
2583
						break; 
2570
						break; 
2584
	
2571
	
Lines 2607-2612 Link Here
2607
								if (rawReverseMap.get(resolvedPath = cEntry.getPath()) == null) rawReverseMap.put(resolvedPath , rawEntry);
2594
								if (rawReverseMap.get(resolvedPath = cEntry.getPath()) == null) rawReverseMap.put(resolvedPath , rawEntry);
2608
							}
2595
							}
2609
							resolvedEntries.add(cEntry);
2596
							resolvedEntries.add(cEntry);
2597
							pathToResolvedEntry.put(cEntry.getPath(), cEntry);
2610
						}
2598
						}
2611
						break;
2599
						break;
2612
											
2600
											
Lines 2615-2627 Link Here
2615
							if (rawReverseMap.get(resolvedPath = rawEntry.getPath()) == null) rawReverseMap.put(resolvedPath , rawEntry);
2603
							if (rawReverseMap.get(resolvedPath = rawEntry.getPath()) == null) rawReverseMap.put(resolvedPath , rawEntry);
2616
						}
2604
						}
2617
						resolvedEntries.add(rawEntry);
2605
						resolvedEntries.add(rawEntry);
2606
						pathToResolvedEntry.put(rawEntry.getPath(), 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, pathToResolvedEntry, 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/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/JavaModelManager.java (-10 / +8 lines)
Lines 862-874 Link Here
862
		// Create a jar package fragment root only if on the classpath
862
		// Create a jar package fragment root only if on the classpath
863
		IPath resourcePath = file.getFullPath();
863
		IPath resourcePath = file.getFullPath();
864
		try {
864
		try {
865
			IClasspathEntry[] entries = ((JavaProject)project).getResolvedClasspath();
865
			IClasspathEntry entry = ((JavaProject)project).getClasspathEntryFor(resourcePath);
866
			for (int i = 0, length = entries.length; i < length; i++) {
866
			if (entry != null) {
867
				IClasspathEntry entry = entries[i];
867
				return project.getPackageFragmentRoot(file);
868
				IPath rootPath = entry.getPath();
869
				if (rootPath.equals(resourcePath)) {
870
					return project.getPackageFragmentRoot(file);
871
				}
872
			}
868
			}
873
		} catch (JavaModelException e) {
869
		} catch (JavaModelException e) {
874
			// project doesn't exist: return null
870
			// project doesn't exist: return null
Lines 985-990 Link Here
985
		public IClasspathEntry[] resolvedClasspath;
981
		public IClasspathEntry[] resolvedClasspath;
986
		public IJavaModelStatus unresolvedEntryStatus;
982
		public IJavaModelStatus unresolvedEntryStatus;
987
		public Map resolvedPathToRawEntries; // reverse map from resolved path to raw entries
983
		public Map resolvedPathToRawEntries; // reverse map from resolved path to raw entries
984
		public Map pathToResolvedEntry; // map from an entry's path to the entry
988
		public IPath outputLocation;
985
		public IPath outputLocation;
989
		
986
		
990
		public IEclipsePreferences preferences;
987
		public IEclipsePreferences preferences;
Lines 1022-1031 Link Here
1022
		
1019
		
1023
		public synchronized void resetResolvedClasspath() {
1020
		public synchronized void resetResolvedClasspath() {
1024
			// null out resolved information
1021
			// null out resolved information
1025
			setClasspath(this.rawClasspath, this.outputLocation, this.rawClasspathStatus, null, null, null);
1022
			setClasspath(this.rawClasspath, this.outputLocation, this.rawClasspathStatus, null, null, null, null);
1026
		}
1023
		}
1027
		
1024
		
1028
		public synchronized void setClasspath(IClasspathEntry[] newRawClasspath, IPath newOutputLocation, IJavaModelStatus newRawClasspathStatus, IClasspathEntry[] newResolvedClasspath, Map newResolvedPathToRawEntries, IJavaModelStatus newUnresolvedEntryStatus) {
1025
		public synchronized void setClasspath(IClasspathEntry[] newRawClasspath, IPath newOutputLocation, IJavaModelStatus newRawClasspathStatus, IClasspathEntry[] newResolvedClasspath, Map newResolvedPathToRawEntries, Map newPathToResolvedEntry, IJavaModelStatus newUnresolvedEntryStatus) {
1029
			// remember old info
1026
			// remember old info
1030
			JavaModelManager manager = JavaModelManager.getJavaModelManager();
1027
			JavaModelManager manager = JavaModelManager.getJavaModelManager();
1031
			DeltaProcessor deltaProcessor = manager.deltaState.getDeltaProcessor();
1028
			DeltaProcessor deltaProcessor = manager.deltaState.getDeltaProcessor();
Lines 1036-1041 Link Here
1036
			this.rawClasspathStatus = newRawClasspathStatus;
1033
			this.rawClasspathStatus = newRawClasspathStatus;
1037
			this.resolvedClasspath = newResolvedClasspath;
1034
			this.resolvedClasspath = newResolvedClasspath;
1038
			this.resolvedPathToRawEntries = newResolvedPathToRawEntries;
1035
			this.resolvedPathToRawEntries = newResolvedPathToRawEntries;
1036
			this.pathToResolvedEntry = newPathToResolvedEntry;
1039
			this.unresolvedEntryStatus = newUnresolvedEntryStatus;
1037
			this.unresolvedEntryStatus = newUnresolvedEntryStatus;
1040
			this.javadocCache = new LRUCache(JAVADOC_CACHE_INITIAL_SIZE);
1038
			this.javadocCache = new LRUCache(JAVADOC_CACHE_INITIAL_SIZE);
1041
		}
1039
		}
Lines 1090-1096 Link Here
1090
			}
1088
			}
1091
			
1089
			
1092
			// store new raw classpath, new output and new status, and null out resolved info
1090
			// store new raw classpath, new output and new status, and null out resolved info
1093
			setClasspath(classpath, output, status, null, null, null);
1091
			setClasspath(classpath, output, status, null, null, null, null);
1094
			
1092
			
1095
			return classpath;
1093
			return classpath;
1096
		}
1094
		}
(-)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/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/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 181900