mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs]: add annotations to avoid wrong thread external usages
* getting current repo based on getting current editor->calledInAwt
This commit is contained in:
@@ -60,6 +60,7 @@ import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcsUtil.VcsImplUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.intellij.images.editor.ImageFileEditor;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -165,6 +166,7 @@ public class DvcsUtil {
|
||||
* Returns the currently selected file, based on which VcsBranch or StatusBar components will identify the current repository root.
|
||||
*/
|
||||
@Nullable
|
||||
@CalledInAwt
|
||||
public static VirtualFile getSelectedFile(@NotNull Project project) {
|
||||
StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
|
||||
final FileEditor fileEditor = StatusBarUtil.getCurrentFileEditor(project, statusBar);
|
||||
@@ -328,6 +330,7 @@ public class DvcsUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@CalledInAwt
|
||||
public static <T extends Repository> T guessCurrentRepositoryQuick(@NotNull Project project,
|
||||
@NotNull AbstractRepositoryManager<T> manager,
|
||||
@Nullable String defaultRootPathValue) {
|
||||
|
||||
@@ -185,6 +185,7 @@ public abstract class DvcsStatusWidget<T extends Repository> extends EditorBased
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@CalledInAwt
|
||||
private String getToolTip(@NotNull Project project) {
|
||||
T currentRepository = guessCurrentRepository(project);
|
||||
if (currentRepository == null) return null;
|
||||
|
||||
@@ -37,6 +37,7 @@ import git4idea.branch.GitBranchUtil;
|
||||
import git4idea.i18n.GitBundle;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryManager;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -80,6 +81,7 @@ public abstract class GitRepositoryAction extends DumbAwareAction {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@CalledInAwt
|
||||
private static VirtualFile getDefaultRoot(@NotNull Project project, @NotNull List<VirtualFile> roots, @Nullable VirtualFile[] vFiles) {
|
||||
if (vFiles != null) {
|
||||
for (VirtualFile file : vFiles) {
|
||||
@@ -120,6 +122,7 @@ public abstract class GitRepositoryAction extends DumbAwareAction {
|
||||
return true;
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
protected static boolean isRebasing(AnActionEvent e) {
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
if (project != null) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import git4idea.repo.GitRemote;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.ui.branch.GitMultiRootBranchConfig;
|
||||
import git4idea.validators.GitNewBranchNameValidator;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -319,6 +320,7 @@ public class GitBranchUtil {
|
||||
* or if the current Git root couldn't be determined.
|
||||
*/
|
||||
@Nullable
|
||||
@CalledInAwt
|
||||
public static GitRepository getCurrentRepository(@NotNull Project project) {
|
||||
return getRepositoryOrGuess(project, DvcsUtil.getSelectedFile(project));
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import git4idea.branch.GitBranchUtil;
|
||||
import git4idea.config.GitVcsSettings;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryChangeListener;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -47,6 +48,7 @@ public class GitBranchWidget extends DvcsStatusWidget<GitRepository> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@CalledInAwt
|
||||
protected GitRepository guessCurrentRepository(@NotNull Project project) {
|
||||
return DvcsUtil.guessCurrentRepositoryQuick(project, GitUtil.getRepositoryManager(project), mySettings.getRecentRootPath());
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.repo.HgRepository;
|
||||
@@ -45,6 +46,7 @@ public class HgActionUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@CalledInAwt
|
||||
public static HgRepository getSelectedRepositoryFromEvent(AnActionEvent e) {
|
||||
final DataContext dataContext = e.getDataContext();
|
||||
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.zmlx.hg4idea.action;
|
||||
|
||||
import com.intellij.dvcs.repo.Repository;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.zmlx.hg4idea.repo.HgRepository;
|
||||
|
||||
public abstract class HgProcessStateAction extends HgAbstractGlobalSingleRepoAction {
|
||||
@@ -26,6 +27,7 @@ public abstract class HgProcessStateAction extends HgAbstractGlobalSingleRepoAct
|
||||
myState = state;
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
protected boolean isRebasing(AnActionEvent e) {
|
||||
HgRepository repository = HgActionUtil.getSelectedRepositoryFromEvent(e);
|
||||
return repository != null && repository.getState() == myState;
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.StatusBarWidget;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.HgProjectSettings;
|
||||
@@ -52,6 +53,7 @@ public class HgStatusWidget extends DvcsStatusWidget<HgRepository> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@CalledInAwt
|
||||
protected HgRepository guessCurrentRepository(@NotNull Project project) {
|
||||
return DvcsUtil.guessCurrentRepositoryQuick(project, HgUtil.getRepositoryManager(project),
|
||||
HgProjectSettings.getInstance(project).getRecentRootPath());
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.intellij.ui.GuiUtils;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.*;
|
||||
@@ -498,6 +499,7 @@ public abstract class HgUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@CalledInAwt
|
||||
public static HgRepository getCurrentRepository(@NotNull Project project) {
|
||||
if (project.isDisposed()) return null;
|
||||
return DvcsUtil.guessRepositoryForFile(project, getRepositoryManager(project),
|
||||
|
||||
Reference in New Issue
Block a user