vcs: Refactored "ChangesUtil" - used lambdas

This commit is contained in:
Konstantin Kolosovsky
2017-01-13 15:23:38 +03:00
parent bfa0784302
commit 8d9c6a50bd
@@ -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 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<VirtualFile>)() -> {
return ReadAction.compute(() -> {
VirtualFile result = null;
FilePath parent = filePath;
LocalFileSystem lfs = LocalFileSystem.getInstance();
@@ -289,11 +288,10 @@ public class ChangesUtil {
public static <T> void processItemsByVcs(@NotNull Collection<T> items,
@NotNull VcsSeparator<T> separator,
@NotNull PerVcsProcessor<T> processor) {
Map<AbstractVcs, List<T>> changesByVcs = ApplicationManager.getApplication().runReadAction(
(NotNullComputable<Map<AbstractVcs, List<T>>>)() ->
items.stream()
.filter(it -> separator.getVcsFor(it) != null)
.collect(groupingBy(separator::getVcsFor)));
Map<AbstractVcs, List<T>> changesByVcs = ReadAction.compute(
() -> items.stream()
.filter(it -> separator.getVcsFor(it) != null)
.collect(groupingBy(separator::getVcsFor)));
changesByVcs.forEach((vcs, vcsItems) -> {
if (vcs != null) {