Pages

Wednesday, October 31, 2012

How to get file path information from ICompilationUnit?

When you have ICompilationUnit, you can get the java file path for the unit using this code.
IResource resource = iCompilationUnit.getUnderlyingResource();
if (resource.getType() == IResource.FILE) {
    IFile ifile = (IFile) resource;
    String path = ifile.getRawLocation().toString();
}

References

No comments:

Post a Comment