Java Code Examples for org.eclipse.core.resources.IFile#getRawLocation()

The following examples show how to use org.eclipse.core.resources.IFile#getRawLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bug486584Test.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFullBuildWhenClasspathChanged_3() throws CoreException, IOException, InterruptedException {
	IJavaProject project = setupProject();
	IFile libaryFile = copyAndGetXtendExampleJar(project);
	IPath rawLocation = libaryFile.getRawLocation();
	File file = rawLocation.toFile();
	Assert.assertTrue(file.setLastModified(10));
	IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(rawLocation, null, null);
	addToClasspath(project, libraryEntry);
	build();
	assertFalse(getEvents().isEmpty());
	getEvents().clear();
	Assert.assertTrue(file.setLastModified(System.currentTimeMillis()));
	project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
	build();
	assertEquals(1, getEvents().size());
}
 
Example 2
Source File: Bug486584Test.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFullBuildWhenClasspathChanged_4() throws CoreException, IOException, InterruptedException {
	IJavaProject project = setupProject();
	IFile libraryFile = copyAndGetXtendExampleJar(project);
	IPath rawLocation = libraryFile.getRawLocation();
	libraryFile.setLocalTimeStamp(10L);
	IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(rawLocation, null, null);
	addToClasspath(project, libraryEntry);
	build();
	assertFalse(getEvents().isEmpty());
	getEvents().clear();
	libraryFile.setLocalTimeStamp(System.currentTimeMillis());
	project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
	// refresh -> full build
	build();
	assertEquals(1, getEvents().size());
}
 
Example 3
Source File: Bug486584Test.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testNoFullBuildWhenClasspathNotReallyChanged_1() throws CoreException, IOException, InterruptedException {
	IJavaProject project = setupProject();
	IFile libaryFile = copyAndGetXtendExampleJar(project);
	IPath rawLocation = libaryFile.getRawLocation();
	IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(rawLocation, null, null);
	addToClasspath(project, libraryEntry);
	build();
	assertFalse(getEvents().isEmpty());
	getEvents().clear();
	project.setRawClasspath(project.getRawClasspath(), null);
	project.getProject().getFile("src/dummy.txt").create(new StringInputStream(""), false, null);
	project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
	build();
	assertEquals(0, getEvents().size());
}
 
Example 4
Source File: Bug486584Test.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testNoFullBuildWhenClasspathNotReallyChanged_2() throws CoreException, IOException, InterruptedException {
	IJavaProject project = setupProject();
	IFile libraryFile = copyAndGetXtendExampleJar(project);
	IPath rawLocation = libraryFile.getRawLocation();
	libraryFile.setLocalTimeStamp(10L);
	IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(rawLocation, null, null);
	addToClasspath(project, libraryEntry);
	build();
	assertFalse(getEvents().isEmpty());
	getEvents().clear();
	libraryFile.setLocalTimeStamp(System.currentTimeMillis());
	// no refresh -> no full build
	build();
	assertEquals(0, getEvents().size());
}
 
Example 5
Source File: HierarchicalDataModel.java    From dawnsci with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IHierarchicalDataFileModel getFileModel(IFile file) {
	synchronized (cache) {
		if (file == null)
			return INVALID_FILE_MODEL;
		IPath rawLocation = file.getRawLocation();
		if (rawLocation == null)
			return INVALID_FILE_MODEL;
		final String fullPath = rawLocation.toOSString();
		if (cache.containsKey(fullPath)) {
			return cache.get(fullPath);
		}

		IHierarchicalDataFileModel model = getModel.createFileModel(fullPath);
		cache.put(fullPath, model);
		return model;
	}
}
 
Example 6
Source File: HierarchicalDataModel.java    From dawnsci with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Remove any cached information about a given file.
 * <p>
 * It is expected that this is called on Eclipse resource deltas to remove
 * files that have been modified.
 *
 * @param file
 *            to expunge cache for
 */
public void clearFileCache(IFile file) {
	if (file != null) {
		IPath rawLocation = file.getRawLocation();
		if (rawLocation != null) {
			synchronized (cache) {
				cache.remove(rawLocation.toOSString());
			}
		}
	}
}