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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java (+16 lines)
Lines 1093-1096 Link Here
1093
			}
1093
			}
1094
		} while (wasInterrupted);
1094
		} while (wasInterrupted);
1095
	}	
1095
	}	
1096
	
1097
	public void waitForManualRefresh() {
1098
		checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
1099
		boolean wasInterrupted = false;
1100
		do {
1101
			try {
1102
				Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_REFRESH, null);
1103
				wasInterrupted = false;
1104
			} catch (OperationCanceledException e) {
1105
				handle(e);
1106
			} catch (InterruptedException e) {
1107
				wasInterrupted = true;
1108
			}
1109
		} while (wasInterrupted);
1110
	}	
1111
1096
}
1112
}
(-)src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java (-2 / +3 lines)
Lines 13-18 Link Here
13
import junit.framework.*;
13
import junit.framework.*;
14
14
15
import org.eclipse.core.resources.IMarker;
15
import org.eclipse.core.resources.IMarker;
16
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
19
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
Lines 314-321 Link Here
314
		);
315
		);
315
		new java.io.File(externalClassFile).setLastModified(lastModified + 1000); // to be sure its different
316
		new java.io.File(externalClassFile).setLastModified(lastModified + 1000); // to be sure its different
316
		
317
		
317
		// work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=219566
318
		env.getProject(projectPath).refreshLocal(IResource.DEPTH_INFINITE, null);
318
		JavaModelManager.getExternalManager().refreshReferences(env.getProject(projectPath), null);
319
		env.waitForManualRefresh();
319
320
320
		incrementalBuild(projectPath);
321
		incrementalBuild(projectPath);
321
		expectingProblemsFor(
322
		expectingProblemsFor(
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (-8 / +17 lines)
Lines 2023-2036 Link Here
2023
	}
2023
	}
2024
2024
2025
	public void refresh(final IJavaProject javaProject) throws CoreException {
2025
	public void refresh(final IJavaProject javaProject) throws CoreException {
2026
		ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
2026
		javaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
2027
			public void run(IProgressMonitor pm) throws CoreException {
2027
		waitForManualRefresh();
2028
				// work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=219566
2029
				JavaModelManager.getExternalManager().refreshReferences(javaProject.getProject(), null);
2030
				
2031
				javaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, pm);
2032
			}
2033
		}, null);
2034
	}
2028
	}
2035
2029
2036
	protected void removeJavaNature(String projectName) throws CoreException {
2030
	protected void removeJavaNature(String projectName) throws CoreException {
Lines 2361-2366 Link Here
2361
		try {
2355
		try {
2362
			javaProject.setRawClasspath(classpath, null);
2356
			javaProject.setRawClasspath(classpath, null);
2363
		} catch (JavaModelException e) {
2357
		} catch (JavaModelException e) {
2358
			e.printStackTrace();
2364
			assertTrue("failed to set classpath", false);
2359
			assertTrue("failed to set classpath", false);
2365
		}
2360
		}
2366
	}
2361
	}
Lines 2686-2691 Link Here
2686
		} while (wasInterrupted);
2681
		} while (wasInterrupted);
2687
	}
2682
	}
2688
2683
2684
	public static void waitForManualRefresh() {
2685
		boolean wasInterrupted = false;
2686
		do {
2687
			try {
2688
				Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_REFRESH, null);
2689
				wasInterrupted = false;
2690
			} catch (OperationCanceledException e) {
2691
				e.printStackTrace();
2692
			} catch (InterruptedException e) {
2693
				wasInterrupted = true;
2694
			}
2695
		} while (wasInterrupted);
2696
	}
2697
2689
	public static void waitUntilIndexesReady() {
2698
	public static void waitUntilIndexesReady() {
2690
		// dummy query for waiting until the indexes are ready
2699
		// dummy query for waiting until the indexes are ready
2691
		SearchEngine engine = new SearchEngine();
2700
		SearchEngine engine = new SearchEngine();
(-)model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java (-7 / +24 lines)
Lines 25-32 Link Here
25
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.IPath;
26
import org.eclipse.core.runtime.IPath;
27
import org.eclipse.core.runtime.IProgressMonitor;
27
import org.eclipse.core.runtime.IProgressMonitor;
28
import org.eclipse.core.runtime.IStatus;
29
import org.eclipse.core.runtime.Status;
30
import org.eclipse.core.runtime.jobs.Job;
28
import org.eclipse.jdt.core.IClasspathEntry;
31
import org.eclipse.jdt.core.IClasspathEntry;
29
import org.eclipse.jdt.core.JavaCore;
32
import org.eclipse.jdt.core.JavaCore;
33
import org.eclipse.jdt.internal.core.util.Messages;
30
import org.eclipse.jdt.internal.core.util.Util;
34
import org.eclipse.jdt.internal.core.util.Util;
31
35
32
public class ExternalFoldersManager {
36
public class ExternalFoldersManager {
Lines 221-233 Link Here
221
			HashSet externalFolders = getExternalFolders(JavaCore.create(source).getResolvedClasspath(true));
225
			HashSet externalFolders = getExternalFolders(JavaCore.create(source).getResolvedClasspath(true));
222
			if (externalFolders == null)
226
			if (externalFolders == null)
223
				return;
227
				return;
224
			Iterator iterator = externalFolders.iterator();
228
			final Iterator iterator = externalFolders.iterator();
225
			while (iterator.hasNext()) {
229
				Job refreshJob = new Job(Messages.refreshing_external_folders) { 
226
				IPath externalPath = (IPath) iterator.next();
230
					public boolean belongsTo(Object family) {
227
				IFolder folder = getFolder(externalPath);
231
						return family == ResourcesPlugin.FAMILY_MANUAL_REFRESH;
228
				if (folder != null)
232
					}
229
					folder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
233
					protected IStatus run(IProgressMonitor pm) {
230
			}
234
						try {
235
							while (iterator.hasNext()) {
236
								IPath externalPath = (IPath) iterator.next();
237
								IFolder folder = getFolder(externalPath);
238
								if (folder != null)
239
									folder.refreshLocal(IResource.DEPTH_INFINITE, pm);
240
							}
241
						} catch (CoreException e) {
242
							return e.getStatus();
243
						}
244
						return Status.OK_STATUS;
245
					}
246
				};
247
				refreshJob.schedule();
231
		} catch (CoreException e) {
248
		} catch (CoreException e) {
232
			Util.log(e, "Exception while refreshing external project"); //$NON-NLS-1$
249
			Util.log(e, "Exception while refreshing external project"); //$NON-NLS-1$
233
		}
250
		}
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-9 / +10 lines)
Lines 4269-4281 Link Here
4269
			
4269
			
4270
			// initialize Java model cache
4270
			// initialize Java model cache
4271
			this.cache = new JavaModelCache();
4271
			this.cache = new JavaModelCache();
4272
4272
	
4273
			// request state folder creation (workaround 19885)
4273
			// request state folder creation (workaround 19885)
4274
			JavaCore.getPlugin().getStateLocation();
4274
			JavaCore.getPlugin().getStateLocation();
4275
4275
	
4276
			// Initialize eclipse preferences
4276
			// Initialize eclipse preferences
4277
			initializePreferences();
4277
			initializePreferences();
4278
4278
	
4279
			// Listen to preference changes
4279
			// Listen to preference changes
4280
			this.propertyListener = new Preferences.IPropertyChangeListener() {
4280
			this.propertyListener = new Preferences.IPropertyChangeListener() {
4281
				public void propertyChange(Preferences.PropertyChangeEvent event) {
4281
				public void propertyChange(Preferences.PropertyChangeEvent event) {
Lines 4286-4300 Link Here
4286
			
4286
			
4287
			// Listen to content-type changes
4287
			// Listen to content-type changes
4288
			 Platform.getContentTypeManager().addContentTypeChangeListener(this);
4288
			 Platform.getContentTypeManager().addContentTypeChangeListener(this);
4289
4289
	
4290
			// retrieve variable values
4290
			// retrieve variable values
4291
			long start = -1;
4291
			long start = -1;
4292
			if (VERBOSE)
4292
			if (VERBOSE)
4293
				start = System.currentTimeMillis();
4293
				start = System.currentTimeMillis();
4294
 			loadVariablesAndContainers();
4294
			loadVariablesAndContainers();
4295
 			if (VERBOSE)
4295
			if (VERBOSE)
4296
				traceVariableAndContainers("Loaded", start); //$NON-NLS-1$
4296
				traceVariableAndContainers("Loaded", start); //$NON-NLS-1$
4297
4297
	
4298
			final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4298
			final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4299
			workspace.addResourceChangeListener(
4299
			workspace.addResourceChangeListener(
4300
				this.deltaState,
4300
				this.deltaState,
Lines 4303-4310 Link Here
4303
					| IResourceChangeEvent.POST_BUILD
4303
					| IResourceChangeEvent.POST_BUILD
4304
					| IResourceChangeEvent.POST_CHANGE
4304
					| IResourceChangeEvent.POST_CHANGE
4305
					| IResourceChangeEvent.PRE_DELETE
4305
					| IResourceChangeEvent.PRE_DELETE
4306
					| IResourceChangeEvent.PRE_CLOSE);
4306
					| IResourceChangeEvent.PRE_CLOSE
4307
4307
					| IResourceChangeEvent.PRE_REFRESH);
4308
	
4308
			startIndexing();
4309
			startIndexing();
4309
			
4310
			
4310
			// process deltas since last activated in indexer thread so that indexes are up-to-date.
4311
			// process deltas since last activated in indexer thread so that indexes are up-to-date.
(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (-4 / +8 lines)
Lines 1844-1852 Link Here
1844
	 * @see IResource 
1844
	 * @see IResource 
1845
	 */
1845
	 */
1846
	public void resourceChanged(IResourceChangeEvent event) {
1846
	public void resourceChanged(IResourceChangeEvent event) {
1847
1847
	
1848
		int eventType = this.overridenEventType == -1 ? event.getType() : this.overridenEventType;
1848
		int eventType = this.overridenEventType == -1 ? event.getType() : this.overridenEventType;
1849
		IResource resource = event.getResource();
1849
		final IResource resource = event.getResource();
1850
		IResourceDelta delta = event.getDelta();
1850
		IResourceDelta delta = event.getDelta();
1851
		
1851
		
1852
		switch(eventType){
1852
		switch(eventType){
Lines 1862-1867 Link Here
1862
				}
1862
				}
1863
				return;
1863
				return;
1864
				
1864
				
1865
			case IResourceChangeEvent.PRE_REFRESH:
1866
				JavaModelManager.getExternalManager().refreshReferences((IProject) resource, null);
1867
				return;
1868
				
1865
			case IResourceChangeEvent.POST_CHANGE :
1869
			case IResourceChangeEvent.POST_CHANGE :
1866
				HashSet elementsToRefresh = this.state.removeExternalElementsToRefresh();
1870
				HashSet elementsToRefresh = this.state.removeExternalElementsToRefresh();
1867
				if (isAffectedBy(delta) // avoid populating for SYNC or MARKER deltas
1871
				if (isAffectedBy(delta) // avoid populating for SYNC or MARKER deltas
Lines 1938-1944 Link Here
1938
			case IResourceChangeEvent.PRE_BUILD :
1942
			case IResourceChangeEvent.PRE_BUILD :
1939
				boolean isAffected = isAffectedBy(delta);
1943
				boolean isAffected = isAffectedBy(delta);
1940
				boolean needCycleValidation = isAffected && validateClasspaths(delta);
1944
				boolean needCycleValidation = isAffected && validateClasspaths(delta);
1941
1945
	
1942
				// update external folders if necessary
1946
				// update external folders if necessary
1943
			    ExternalFolderChange[] folderChanges = this.state.removeExternalFolderChanges();
1947
			    ExternalFolderChange[] folderChanges = this.state.removeExternalFolderChanges();
1944
				if (folderChanges != null) {
1948
				if (folderChanges != null) {
Lines 1991-1997 Link Here
1991
				
1995
				
1992
				// does not fire any deltas
1996
				// does not fire any deltas
1993
				return;
1997
				return;
1994
1998
	
1995
			case IResourceChangeEvent.POST_BUILD :
1999
			case IResourceChangeEvent.POST_BUILD :
1996
				JavaBuilder.buildFinished();
2000
				JavaBuilder.buildFinished();
1997
				return;
2001
				return;
(-)model/org/eclipse/jdt/internal/core/util/messages.properties (+1 lines)
Lines 177-182 Link Here
177
path_mustBeAbsolute = Path must be absolute
177
path_mustBeAbsolute = Path must be absolute
178
cache_invalidLoadFactor = Incorrect load factor
178
cache_invalidLoadFactor = Incorrect load factor
179
savedState_jobName = Processing Java changes since last activation
179
savedState_jobName = Processing Java changes since last activation
180
refreshing_external_folders = "Refreshing external folders"
180
181
181
## java model initialization
182
## java model initialization
182
javamodel_initialization = Initializing Java tooling
183
javamodel_initialization = Initializing Java tooling
(-)model/org/eclipse/jdt/internal/core/util/Messages.java (+1 lines)
Lines 178-183 Link Here
178
	public static String path_mustBeAbsolute;
178
	public static String path_mustBeAbsolute;
179
	public static String cache_invalidLoadFactor;
179
	public static String cache_invalidLoadFactor;
180
	public static String savedState_jobName;
180
	public static String savedState_jobName;
181
	public static String refreshing_external_folders;
181
	public static String convention_unit_nullName;
182
	public static String convention_unit_nullName;
182
	public static String convention_unit_notJavaName;
183
	public static String convention_unit_notJavaName;
183
	public static String convention_classFile_nullName;
184
	public static String convention_classFile_nullName;

Return to bug 182537