Allow .index files to be regenerated for eclipse open projects.

This should solve issue where the build an eclipse open project from the
command line and the .index file gets deleted.
Fixed bug if project not imported into eclipse and .index is deleted

There was a null pointer that was masked by a careless null check,
which should have been an error condition. Rearranging the code
allowed for the correct code path to happen when a project is not
imported.