CacheQueryHandlerImpl implements CacheQueryHandler { @NotNull @Override public Collection<P4LocalFile> getCachedOpenedFiles(@NotNull ClientConfig config) { Map<FilePath, P4LocalFileImpl.Builder> files = new HashMap<>(); try { cache.read(config, (store) -> store.getFiles() .forEach((file) -> files.put(file.getFilePath(), new P4LocalFileImpl.Builder().withLocalFile(file)))); if (LOG.isDebugEnabled()) { LOG.debug("cached opened files: " + files.keySet()); } pendingClientActions(config, (action) -> { switch (action.getCmd()) { case MOVE_FILE: { MoveFileAction a = toMoveFileAction(action); P4LocalFileImpl.Builder srcBuilder = files.get(a.getSourceFile()); P4LocalFileImpl.Builder tgtBuilder = files.get(a.getTargetFile()); if (srcBuilder == null) { srcBuilder = new P4LocalFileImpl.Builder() .withLocal(a.getSourceFile()) .withHave(new P4Revision(-1)); files.put(a.getSourceFile(), srcBuilder); } srcBuilder .withAction(P4FileAction.MOVE_DELETE) .withResolveType(P4ResolveType.NO_RESOLVE) .withChangelist(a.getChangelistId()); if (tgtBuilder == null) { tgtBuilder = new P4LocalFileImpl.Builder() .withLocal(a.getTargetFile()) .withHave(new P4Revision(-1)); files.put(a.getTargetFile(), tgtBuilder); } tgtBuilder .withAction(P4FileAction.MOVE_ADD_EDIT) .withIntegrateFrom(srcBuilder.getDepot()) .withResolveType(P4ResolveType.NO_RESOLVE) .withChangelist(a.getChangelistId()); break; } case ADD_EDIT_FILE: { AddEditAction a = toAddEditAction(action); P4LocalFileImpl.Builder builder = files.get(a.getFile()); if (builder == null) { builder = new P4LocalFileImpl.Builder() .withLocal(a.getFile()) .withHave(new P4Revision(-1)); files.put(a.getFile(), builder); } builder .withAction(P4FileAction.ADD_EDIT) .withResolveType(P4ResolveType.NO_RESOLVE) .withChangelist(a.getChangelistId()); break; } case DELETE_FILE: { DeleteFileAction a = toDeleteFileAction(action); P4LocalFileImpl.Builder builder = files.get(a.getFile()); if (builder == null) { builder = new P4LocalFileImpl.Builder() .withLocal(a.getFile()) .withHave(new P4Revision(-1)); files.put(a.getFile(), builder); } builder .withAction(P4FileAction.DELETE) .withResolveType(P4ResolveType.NO_RESOLVE) .withChangelist(a.getChangelistId()); break; } case REVERT_FILE: { RevertFileAction a = toRevertFileAction(action); files.remove(a.getFile()); break; } case MOVE_FILES_TO_CHANGELIST: { MoveFilesToChangelistAction a = toMoveFilesToChangelistAction(action); for (FilePath affectedFile : a.getAffectedFiles()) { P4LocalFileImpl.Builder builder = files.get(affectedFile); if (builder != null) { builder.withChangelist(a.getChangelistId()); } else { LOG.warn("Encountered Move Files to Changelist pending action with not open file: " + affectedFile); } } } } }); if (LOG.isDebugEnabled()) { LOG.debug("final evaluated cached opened files: " + files.keySet()); } } catch (InterruptedException e) { reportCacheWaitError(e); } return files.values().stream().map(P4LocalFileImpl.Builder::build).collect(Collectors.toList()); } CacheQueryHandlerImpl(@Nullable Project project, @NotNull ProjectCacheStore cache); @NotNull @Override Collection<P4LocalChangelist> getCachedOpenedChangelists(@NotNull ClientConfig config); @NotNull @Override Collection<P4LocalFile> getCachedOpenedFiles(@NotNull ClientConfig config); @Nullable @Override P4RemoteChangelist getCachedChangelist(P4ServerName serverName, P4ChangelistId changelistId); @Nullable @Override P4JobSpec getCachedJobSpec(P4ServerName serverName); @NotNull @Override Collection<P4WorkspaceSummary> getCachedClientsForUser(@NotNull P4ServerName serverName,
            @NotNull String username); @Override int getEstimateSize();  }
@Test void getCachedOpenedFiles() { }