View | Details | Raw Unified | Return to bug 250083
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-3 / +6 lines)
Lines 1057-1066 Link Here
1057
			return this.resolvedClasspath;
1057
			return this.resolvedClasspath;
1058
		}
1058
		}
1059
		
1059
		
1060
		public void forgetExternalTimestamps() {
1060
		public void forgetExternalTimestampsAndIndexes() {
1061
			IClasspathEntry[] classpath = this.resolvedClasspath;
1061
			IClasspathEntry[] classpath = this.resolvedClasspath;
1062
			if (classpath == null) return;
1062
			if (classpath == null) return;
1063
			Map externalTimeStamps = JavaModelManager.getJavaModelManager().deltaState.getExternalLibTimeStamps();
1063
			JavaModelManager manager = JavaModelManager.getJavaModelManager();
1064
			IndexManager indexManager = manager.indexManager;
1065
			Map externalTimeStamps = manager.deltaState.getExternalLibTimeStamps();
1064
			HashMap rootInfos = JavaModelManager.getDeltaState().otherRoots;
1066
			HashMap rootInfos = JavaModelManager.getDeltaState().otherRoots;
1065
			for (int i = 0, length = classpath.length; i < length; i++) {
1067
			for (int i = 0, length = classpath.length; i < length; i++) {
1066
				IClasspathEntry entry = classpath[i];
1068
				IClasspathEntry entry = classpath[i];
Lines 1068-1073 Link Here
1068
					IPath path = entry.getPath();
1070
					IPath path = entry.getPath();
1069
					if (rootInfos.get(path) == null) {
1071
					if (rootInfos.get(path) == null) {
1070
						externalTimeStamps.remove(path);
1072
						externalTimeStamps.remove(path);
1073
						indexManager.removeIndex(path); // force reindexing on next reference (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 )
1071
					}
1074
					}
1072
				}
1075
				}
1073
			}
1076
			}
Lines 3421-3427 Link Here
3421
			PerProjectInfo info= (PerProjectInfo) this.perProjectInfos.get(project);
3424
			PerProjectInfo info= (PerProjectInfo) this.perProjectInfos.get(project);
3422
			if (info != null) {
3425
			if (info != null) {
3423
				this.perProjectInfos.remove(project);
3426
				this.perProjectInfos.remove(project);
3424
				info.forgetExternalTimestamps();
3427
				info.forgetExternalTimestampsAndIndexes();
3425
			}
3428
			}
3426
		}
3429
		}
3427
	}
3430
	}
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (+50 lines)
Lines 13-18 Link Here
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.HashMap;
16
import java.util.List;
17
import java.util.List;
17
18
18
import junit.framework.Test;
19
import junit.framework.Test;
Lines 26-31 Link Here
26
import org.eclipse.jdt.core.*;
27
import org.eclipse.jdt.core.*;
27
import org.eclipse.jdt.core.compiler.CharOperation;
28
import org.eclipse.jdt.core.compiler.CharOperation;
28
import org.eclipse.jdt.core.search.*;
29
import org.eclipse.jdt.core.search.*;
30
import org.eclipse.jdt.core.tests.util.Util;
29
31
30
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
32
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
31
import org.eclipse.jdt.internal.core.ClassFile;
33
import org.eclipse.jdt.internal.core.ClassFile;
Lines 10226-10229 Link Here
10226
		deleteProject("P");
10228
		deleteProject("P");
10227
	}
10229
	}
10228
}
10230
}
10231
10232
/**
10233
 * @bug 250083: Search indexes are not correctly updated
10234
 * @test Ensure that a library that is no longer referenced, modified, and referenced again is re-indexed
10235
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083"
10236
 */
10237
public void testBug250083() throws Exception {
10238
	String libPath = getExternalResourcePath("lib250083.jar");
10239
	try {
10240
		Util.createJar(
10241
			new String[] {
10242
				"p250083/Y250083.java",
10243
				"package p250083;\n" +
10244
				"public class Y250083 {}"
10245
			},
10246
			new HashMap(),
10247
			libPath);
10248
		createJavaProject("P", new String[0], new String[] {libPath}, "");
10249
		waitUntilIndexesReady();
10250
		deleteExternalFile(libPath);
10251
		deleteProject("P");
10252
		
10253
		Util.createJar(
10254
			new String[] {
10255
				"p250083/X250083.java",
10256
				"package p250083;\n" +
10257
				"public class X250083 {}"
10258
			},
10259
			new HashMap(),
10260
			libPath);
10261
		createJavaProject("P", new String[0], new String[] {libPath}, "");
10262
		TypeNameMatchCollector collector = new TypeNameMatchCollector();
10263
		new SearchEngine().searchAllTypeNames(
10264
			null,
10265
			new char[][] {"X250083".toCharArray()},
10266
			SearchEngine.createWorkspaceScope(),
10267
			collector,
10268
			IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
10269
			null);
10270
		assertSearchResults(
10271
			"X250083 (not open) [in X250083.class [in p250083 [in "+ getExternalPath() + "lib250083.jar]]]",
10272
			collector);
10273
	} finally {
10274
		deleteExternalFile(libPath);
10275
		deleteProject("P");
10276
	}
10277
}
10278
10229
}
10279
}

Return to bug 250083