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

The following examples show how to use org.eclipse.core.resources.IFile#getRawLocation() . These examples are extracted from open source projects. 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
@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
@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
@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
@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
@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
/**
 * 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());
			}
		}
	}
}