Search code examples
rascal

Convert logical to physical location


I have this logical location: |project://testProject/src/style.css| which I would like to convert to its related physical location. The location is first passed on to a Java file, where I try to convert it using the URIResolverRegistry.getInstance().logicalToPhysical(theLoc); method. The only problem is that it returns the exact location I passed it (the logical location). So it does not get converted. How come? Am I missing something? Or is there maybe another way to solve this?


Solution

  • Actually, project is supposed to be a "physical" URI already. If you want to convert it to an absolute path on the file system, then this is not supported directly.

    However, if you are in an Eclipse context and you are free to depend on it, then rascal-eclipse offers this API:

    IFile file = new ProjectURIResolver().resolveFile(myLoc);
    String absolutePath = file.getLocation().toOSString();