DESCRIPTION

Only return existing IFile from getFileForLocation

In a nested project layout, e.g.:

  root/
    .project
    sub/
      .project
      a.txt

"sub" is not necessarily excluded from root with resource filters.

So when calling ResourceUtil.getFileForLocation for a.txt,
IWorkspaceRoot#getFileForLocation (before this change) would return an
IFile belonging to the root project, even when it was closed. When the
project is closed, IFile returns false from exists() and later results
in the RepositoryMapping not being found.

One way to fix this would be to only return the IFile if it exists(),
and return null otherwise.

But in the above case, we can return an IFile that exists, from the sub
project. To find this, we call findFilesForLocationURI and then return
the first file which exists.

This fixes the reported problem while also including linked resources,
which is desired in the future.

Bug: 397396
Change-Id: I04cbcea45f110a60410229333c180fe997927c5b


COMMENTS

author: Brenden Conley
date: 2013-01-05 15:52:09.000000000

Patch Set 1:

Build Started https://hudson.eclipse.org/sandbox/job/egit.gerrit/3934/ 

-------------------------------------
author: Brenden Conley
date: 2013-01-05 15:59:29.000000000

Patch Set 1: Verified

Build Successful 

https://hudson.eclipse.org/sandbox/job/egit.gerrit/3934/ : SUCCESS

-------------------------------------
