Move 'lambda' parameter to the last place in method signature

The calling code is easier to understand and is formatted better in this case.
This commit is contained in:
Kirill Likhodedov
2017-08-24 12:25:28 +03:00
parent a1e15b785c
commit defe987270
9 changed files with 24 additions and 23 deletions
@@ -16,6 +16,7 @@
package com.intellij.openapi.progress.util;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ReadAction;
@@ -216,30 +217,30 @@ public class BackgroundTaskUtil {
*/
@NotNull
@CalledInAny
public static ProgressIndicator executeOnPooledThread(@NotNull Runnable runnable, @NotNull Disposable parent) {
return executeOnPooledThread(indicator -> runnable.run(), parent);
public static ProgressIndicator executeOnPooledThread(@NotNull Disposable parent, @NotNull Runnable runnable) {
return executeOnPooledThread(parent, indicator -> runnable.run());
}
@NotNull
@CalledInAny
public static ProgressIndicator executeOnPooledThread(@NotNull Consumer<ProgressIndicator> task, @NotNull Disposable parent) {
public static ProgressIndicator executeOnPooledThread(@NotNull Disposable parent, @NotNull Consumer<ProgressIndicator> task) {
ModalityState modalityState = ModalityState.defaultModalityState();
return executeOnPooledThread(task, parent, modalityState);
return executeOnPooledThread(parent, modalityState, task);
}
@NotNull
@CalledInAny
public static ProgressIndicator executeOnPooledThread(@NotNull Consumer<ProgressIndicator> task,
@NotNull Disposable parent,
@NotNull ModalityState modalityState) {
return runUnderDisposeAwareIndicator(task, parent, modalityState, true);
public static ProgressIndicator executeOnPooledThread(@NotNull Disposable parent,
@NotNull ModalityState modalityState,
@NotNull Consumer<ProgressIndicator> task) {
return runUnderDisposeAwareIndicator(parent, modalityState, true, task);
}
@CalledInAny
private static ProgressIndicator runUnderDisposeAwareIndicator(@NotNull Consumer<ProgressIndicator> task,
@NotNull Disposable parent,
private static ProgressIndicator runUnderDisposeAwareIndicator(@NotNull Disposable parent,
@NotNull ModalityState modalityState,
boolean onPooledThread) {
boolean onPooledThread,
@NotNull Consumer<ProgressIndicator> task) {
ProgressIndicator indicator = new EmptyProgressIndicator(modalityState);
Disposable disposable = new Disposable() {
@@ -278,7 +279,7 @@ public class BackgroundTaskUtil {
@CalledInAny
public static void runUnderDisposeAwareIndicator(@NotNull Disposable parent, @NotNull Runnable task) {
runUnderDisposeAwareIndicator(indicator -> task.run(), parent, ModalityState.defaultModalityState(), false);
runUnderDisposeAwareIndicator(parent, ModalityState.defaultModalityState(), false, indicator -> task.run());
}
/**
@@ -163,7 +163,7 @@ public class AnnotateDiffViewerAction {
annotator.getBackgroundableLock().lock();
if (diffContext != null) diffContext.showProgressBar(true);
BackgroundTaskUtil.executeOnPooledThread(indicator -> {
BackgroundTaskUtil.executeOnPooledThread(viewer, indicator -> {
try {
loader.run();
}
@@ -187,7 +187,7 @@ public class AnnotateDiffViewerAction {
annotator.showAnnotation(loader.getResult());
}, indicator.getModalityState());
}
}, viewer);
});
}
@Nullable
@@ -551,7 +551,7 @@ public class VcsSelectionHistoryDialog extends FrameWrapper implements DataProvi
}
public void start(@NotNull Disposable disposable) {
BackgroundTaskUtil.executeOnPooledThread((indicator) -> {
BackgroundTaskUtil.executeOnPooledThread(disposable, (indicator) -> {
try {
// first block is loaded in constructor
for (int index = 1; index < myRevisions.size(); index++) {
@@ -586,7 +586,7 @@ public class VcsSelectionHistoryDialog extends FrameWrapper implements DataProvi
}
notifyUpdate();
}
}, disposable);
});
}
@CalledInBackground
@@ -107,7 +107,7 @@ public class GitUserRegistry implements Disposable, VcsListener {
getOrReadUser(root);
}
};
BackgroundTaskUtil.executeOnPooledThread(task, myProject);
BackgroundTaskUtil.executeOnPooledThread(myProject, task);
}
}
}
+1 -1
View File
@@ -534,7 +534,7 @@ public class GitVcs extends AbstractVcs<CommittedChangeList> {
Collection<VcsRoot> roots = ServiceManager.getService(myProject, VcsRootDetector.class).detect();
new GitIntegrationEnabler(this, myGit).enable(roots);
};
BackgroundTaskUtil.executeOnPooledThread(task, myProject);
BackgroundTaskUtil.executeOnPooledThread(myProject, task);
}
@Override
@@ -261,7 +261,7 @@ public class GitConflictResolver {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && event.getDescription().equals("resolve")) {
notification.expire();
Runnable task = () -> mergeNoProceed();
BackgroundTaskUtil.executeOnPooledThread(task, myProject);
BackgroundTaskUtil.executeOnPooledThread(myProject, task);
}
}
}
@@ -202,9 +202,9 @@ class GitRewordOperation(private val repository: GitRepository,
val connection = project.messageBus.connect()
notification.whenExpired { connection.disconnect() }
connection.subscribe(GitRepository.GIT_REPO_CHANGE, GitRepositoryChangeListener {
BackgroundTaskUtil.executeOnPooledThread(Runnable {
BackgroundTaskUtil.executeOnPooledThread(repository, Runnable {
if (checkUndoPossibility(project) !is UndoPossibility.Possible) notification.expire()
}, repository)
})
})
notifier.notify(notification)
@@ -233,7 +233,7 @@ public class GitRepositoryImpl extends RepositoryImpl implements GitRepository {
Runnable task = () -> {
syncPublisher(repository.getProject(), GIT_REPO_CHANGE).repositoryChanged(repository);
};
BackgroundTaskUtil.executeOnPooledThread(task, repository);
BackgroundTaskUtil.executeOnPooledThread(repository, task);
}
@NotNull
@@ -388,7 +388,7 @@ public abstract class HgUtil {
@NotNull
public static ProgressIndicator executeOnPooledThread(@NotNull Runnable runnable, @NotNull Disposable parentDisposable) {
return BackgroundTaskUtil.executeOnPooledThread(runnable, parentDisposable);
return BackgroundTaskUtil.executeOnPooledThread(parentDisposable, runnable);
}
/**