Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326906

Summary: FileDocumentProvider is not EFS compatible
Product: [Eclipse Project] Platform Reporter: Knut Wannheden <knut.wannheden>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, remy.suen
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Knut Wannheden CLA 2010-10-04 07:06:05 EDT
We have a problem with an editor implemented using FileDocumentProvider. The document's input is a file loaded from an EFS store and when trying to save the resource the document provider comes to the conclusion that the resource does not exist. This decision is based on the result of the method isDeleted():

    public boolean isDeleted(Object element) {

        if (element instanceof IFileEditorInput) {
            IFileEditorInput input= (IFileEditorInput) element;

            IPath path= input.getFile().getLocation();
            if (path == null)
                return true;  // <<<-----

            return !path.toFile().exists();
        }

        return super.isDeleted(element);
    }


Our EFS-stored resource returns null for getLocation(). The workaround is to
let the resource decide whether it exists:

            IPath path= input.getFile().getLocation();
            if (path == null)
                return !input.getFile().exists();

Shouldn't also always the getLocationURI() method be used in Eclipse projects? See http://wiki.eclipse.org/EFS_for_Platform_Committers.
Comment 1 Dani Megert CLA 2010-10-04 09:29:46 EDT
This class has never been updated for EFS and there are no plans to do so. The much more powerful TextFileDocumentProvider should be used which is able to handle EFS.
Comment 2 Knut Wannheden CLA 2010-10-05 02:11:45 EDT
Hi Dani,

Thanks for the clarification. I've added a corresponding ticket to Xtext (bug 326961) where we currently still use the FileDocumentProvider.