From 8d9c6a50bd78ae32d6408e49907d096ff39b8b54 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Fri, 16 Dec 2016 19:34:13 +0300 Subject: [PATCH] vcs: Refactored "ChangesUtil" - used lambdas --- .../openapi/vcs/changes/ChangesUtil.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangesUtil.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangesUtil.java index f52397b69f91..62193dc06c2e 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangesUtil.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangesUtil.java @@ -17,12 +17,11 @@ package com.intellij.openapi.vcs.changes; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.NotNullComputable; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.AbstractVcs; @@ -201,7 +200,7 @@ public class ChangesUtil { public static FilePath getLocalPath(@NotNull Project project, FilePath filePath) { // check if the file has just been renamed (IDEADEV-15494) - Change change = ApplicationManager.getApplication().runReadAction((Computable)() -> { + Change change = ReadAction.compute(() -> { if (project.isDisposed()) throw new ProcessCanceledException(); return ChangeListManager.getInstance(project).getChange(filePath); }); @@ -238,7 +237,7 @@ public class ChangesUtil { @Nullable private static VirtualFile getValidParentUnderReadAction(@NotNull FilePath filePath) { - return ApplicationManager.getApplication().runReadAction((Computable)() -> { + return ReadAction.compute(() -> { VirtualFile result = null; FilePath parent = filePath; LocalFileSystem lfs = LocalFileSystem.getInstance(); @@ -289,11 +288,10 @@ public class ChangesUtil { public static void processItemsByVcs(@NotNull Collection items, @NotNull VcsSeparator separator, @NotNull PerVcsProcessor processor) { - Map> changesByVcs = ApplicationManager.getApplication().runReadAction( - (NotNullComputable>>)() -> - items.stream() - .filter(it -> separator.getVcsFor(it) != null) - .collect(groupingBy(separator::getVcsFor))); + Map> changesByVcs = ReadAction.compute( + () -> items.stream() + .filter(it -> separator.getVcsFor(it) != null) + .collect(groupingBy(separator::getVcsFor))); changesByVcs.forEach((vcs, vcsItems) -> { if (vcs != null) {