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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClasspathChange.java (-1 / +11 lines)
Lines 28-33 Link Here
28
import org.eclipse.jdt.core.IPackageFragmentRoot;
28
import org.eclipse.jdt.core.IPackageFragmentRoot;
29
import org.eclipse.jdt.core.JavaModelException;
29
import org.eclipse.jdt.core.JavaModelException;
30
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
30
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
31
import org.eclipse.jdt.internal.core.DeltaProcessor.RootInfo;
31
import org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo;
32
import org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo;
32
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
33
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
33
import org.eclipse.jdt.internal.core.util.Util;
34
import org.eclipse.jdt.internal.core.util.Util;
Lines 304-316 Link Here
304
					result |= HAS_LIBRARY_CHANGE;
305
					result |= HAS_LIBRARY_CHANGE;
305
				}
306
				}
306
307
307
				PackageFragmentRoot[] pkgFragmentRoots = null;
308
				IPackageFragmentRoot[] pkgFragmentRoots = null;
308
				if (removedRoots != null) {
309
				if (removedRoots != null) {
309
					PackageFragmentRoot oldRoot = (PackageFragmentRoot)  removedRoots.get(this.oldResolvedClasspath[i].getPath());
310
					PackageFragmentRoot oldRoot = (PackageFragmentRoot)  removedRoots.get(this.oldResolvedClasspath[i].getPath());
310
					if (oldRoot != null) { // use old root if any (could be none if entry wasn't bound)
311
					if (oldRoot != null) { // use old root if any (could be none if entry wasn't bound)
311
						pkgFragmentRoots = new PackageFragmentRoot[] { oldRoot };
312
						pkgFragmentRoots = new PackageFragmentRoot[] { oldRoot };
312
					}
313
					}
313
				}
314
				}
315
				else {
316
					// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335986
317
					// When removedRoots doesn't have the package fragment roots, recover them from the cache 
318
					RootInfo rootInfo = (RootInfo)state.oldRoots.get(this.oldResolvedClasspath[i].getPath());
319
					if (rootInfo != null && rootInfo.cache != null) {
320
						IPackageFragmentRoot oldRoot = rootInfo.cache;
321
						pkgFragmentRoots = new IPackageFragmentRoot[] { oldRoot };
322
					}
323
				}
314
				if (pkgFragmentRoots == null) {
324
				if (pkgFragmentRoots == null) {
315
					try {
325
					try {
316
						ObjectVector accumulatedRoots = new ObjectVector();
326
						ObjectVector accumulatedRoots = new ObjectVector();
(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (-9 / +15 lines)
Lines 102-107 Link Here
102
		public JavaProject project;
102
		public JavaProject project;
103
		IPath rootPath;
103
		IPath rootPath;
104
		int entryKind;
104
		int entryKind;
105
		IPackageFragmentRoot cache;
105
		IPackageFragmentRoot root;
106
		IPackageFragmentRoot root;
106
		RootInfo(JavaProject project, IPath rootPath, char[][] inclusionPatterns, char[][] exclusionPatterns, int entryKind) {
107
		RootInfo(JavaProject project, IPath rootPath, char[][] inclusionPatterns, char[][] exclusionPatterns, int entryKind) {
107
			this.project = project;
108
			this.project = project;
Lines 109-127 Link Here
109
			this.inclusionPatterns = inclusionPatterns;
110
			this.inclusionPatterns = inclusionPatterns;
110
			this.exclusionPatterns = exclusionPatterns;
111
			this.exclusionPatterns = exclusionPatterns;
111
			this.entryKind = entryKind;
112
			this.entryKind = entryKind;
113
			this.cache = getPackageFragmentRoot();
114
		}
115
		private IPackageFragmentRoot getPackageFragmentRoot(){
116
			IPackageFragmentRoot tRoot = null;
117
			Object target = JavaModel.getTarget(this.rootPath, false/*don't check existence*/);
118
			if (target instanceof IResource) {
119
				tRoot = this.project.getPackageFragmentRoot((IResource)target);
120
			} else {
121
				tRoot = this.project.getPackageFragmentRoot(this.rootPath.toOSString());
122
			}
123
			return tRoot;
112
		}
124
		}
113
		public IPackageFragmentRoot getPackageFragmentRoot(IResource resource) {
125
		public IPackageFragmentRoot getPackageFragmentRoot(IResource resource) {
114
			if (this.root == null) {
126
			if (this.root == null) {
115
				if (resource != null) {
127
				if (resource == null) {
116
					this.root = this.project.getPackageFragmentRoot(resource);
128
					return this.cache;
117
				} else {
118
					Object target = JavaModel.getTarget(this.rootPath, false/*don't check existence*/);
119
					if (target instanceof IResource) {
120
						this.root = this.project.getPackageFragmentRoot((IResource)target);
121
					} else {
122
						this.root = this.project.getPackageFragmentRoot(this.rootPath.toOSString());
123
					}
124
				}
129
				}
130
				this.root = this.project.getPackageFragmentRoot(resource);
125
			}
131
			}
126
			return this.root;
132
			return this.root;
127
		}
133
		}

Return to bug 335986