If selected resource is non-workspace, then you'll get first path element from getProject() method, and finally getMapping will return null. With change I929c3c32e getMapping for non-workspace files will return proper RepositoryMapping.