Bug 256082 - Can't load file if project is not in workspace root
Summary: Can't load file if project is not in workspace root
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: IMP (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Robert M. Fuhrer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-21 05:03 EST by Marc Ollier CLA
Modified: 2014-01-09 15:04 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Ollier CLA 2008-11-21 05:03:26 EST
The function org.eclipse.imp.model.internal.CompilationUnitRef.getSource() builds the OS file path for a resource with this piece of code:

String absPath= (fPath.getDevice() != null) ? fPath.toOSString() :
	    (fPath.isAbsolute() ? ResourcesPlugin.getWorkspace().getRoot().getLocation().append(fPath).toOSString() :
		fProject.getRawProject().getLocation().append(fPath).toOSString());
        
This seems to cause problems when a project is not in the workspace root.

In my case I have an absolute fPath = [projectName]/[resourcePathInProject] which leads to [workspaceRoot]/[projectName]/[resourcePathInProject] instead of [projectOSPath]/[resourcePathInProject]
Comment 1 Marc Ollier CLA 2008-11-21 05:13:44 EST
The following code works in my case, but I did not test if I broke something else:

String absPath = (fPath.getDevice() != null) ? fPath.toOSString()
				: (fProject.getRawProject().getLocation().append(
						fPath.isAbsolute() ? fPath.removeFirstSegments(1)
								: fPath).toOSString());