Source:
<code>private Optional<Boolean> maybeGetWorkspaceFileExistence(Environment env, RootedPath directory) throws InterruptedException, LocalRepositoryLookupFunctionException { try { RootedPath workspaceRootedFile = RootedPath.toRootedPath( directory.getRoot(), directory .getRootRelativePath() .getRelative(LabelConstants.WORKSPACE_DOT_BAZEL_FILE_NAME)); if (!workspaceRootedFile.asPath().exists()) { workspaceRootedFile = RootedPath.toRootedPath( directory.getRoot(), directory .getRootRelativePath() <START> .getRelative(LabelConstants.WORKSPACE_FILE_NAME)); <END> } FileValue workspaceFileValue = (FileValue) env.getValueOrThrow(FileValue.key(workspaceRootedFile), IOException.class); if (workspaceFileValue == null) { return Optional.absent(); } if (workspaceFileValue.isDirectory()) { return Optional.of(false); } return Optional.of(workspaceFileValue.exists()); } catch (InconsistentFilesystemException e) { throw new LocalRepositoryLookupFunctionException( new ErrorDeterminingRepositoryException( "InconsistentFilesystemException while checking if there is a WORKSPACE file in " + directory.asPath().getPathString(), e), Transience.PERSISTENT); } catch (FileSymlinkException e) { throw new LocalRepositoryLookupFunctionException( new ErrorDeterminingRepositoryException( "FileSymlinkException while checking if there is a WORKSPACE file in " + directory.asPath().getPathString(), e), Transience.PERSISTENT); } catch (IOException e) { throw new LocalRepositoryLookupFunctionException( new ErrorDeterminingRepositoryException( "IOException while checking if there is a WORKSPACE file in " + directory.asPath().getPathString(), e), Transience.PERSISTENT); } }</code><technical_language>logic in LocalRepositoryFunction. extract a common helper function</technical_language>

Target:
private Optional<Boolean> maybeGetWorkspaceFileExistence(Environment env, RootedPath directory) throws InterruptedException, LocalRepositoryLookupFunctionException { try { RootedPath workspaceRootedFile = WorkspaceFileHelper.getWorkspaceRootedFile(directory, env); if (workspaceRootedFile == null) { return Optional.absent(); } FileValue workspaceFileValue = (FileValue) env.getValueOrThrow(FileValue.key(workspaceRootedFile), IOException.class); if (workspaceFileValue == null) { return Optional.absent(); } if (workspaceFileValue.isDirectory()) { return Optional.of(false); } return Optional.of(workspaceFileValue.exists()); } catch (InconsistentFilesystemException e) { throw new LocalRepositoryLookupFunctionException( new ErrorDeterminingRepositoryException( "InconsistentFilesystemException while checking if there is a WORKSPACE file in " + directory.asPath().getPathString(), e), Transience.PERSISTENT); } catch (FileSymlinkException e) { throw new LocalRepositoryLookupFunctionException( new ErrorDeterminingRepositoryException( "FileSymlinkException while checking if there is a WORKSPACE file in " + directory.asPath().getPathString(), e), Transience.PERSISTENT); } catch (IOException e) { throw new LocalRepositoryLookupFunctionException( new ErrorDeterminingRepositoryException( "IOException while checking if there is a WORKSPACE file in " + directory.asPath().getPathString(), e), Transience.PERSISTENT); } }