Search in sources :

Example 61 with AccessToken

use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.

the class HgGraftCommand method graft.

@Nullable
private HgCommandResult graft(@NotNull List<String> params) {
    List<String> args = new ArrayList<>();
    args.add("--log");
    args.addAll(params);
    AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
    try {
        HgCommandResult result = new HgCommandExecutor(myProject).executeInCurrentThread(myRepository.getRoot(), "graft", args);
        myRepository.update();
        return result;
    } finally {
        token.finish();
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) AccessToken(com.intellij.openapi.application.AccessToken) ArrayList(java.util.ArrayList) Nullable(org.jetbrains.annotations.Nullable)

Example 62 with AccessToken

use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.

the class HgMergeCommand method executeInCurrentThread.

@Nullable
private HgCommandResult executeInCurrentThread() {
    HgPromptCommandExecutor commandExecutor = new HgPromptCommandExecutor(project);
    commandExecutor.setShowOutput(true);
    List<String> arguments = new LinkedList<>();
    if (!StringUtil.isEmptyOrSpaces(revision)) {
        arguments.add("--rev");
        arguments.add(revision);
    }
    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        HgCommandResult result = commandExecutor.executeInCurrentThread(repo.getRoot(), "merge", arguments);
        repo.update();
        return result;
    } finally {
        token.finish();
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgPromptCommandExecutor(org.zmlx.hg4idea.execution.HgPromptCommandExecutor) AccessToken(com.intellij.openapi.application.AccessToken) LinkedList(java.util.LinkedList) Nullable(org.jetbrains.annotations.Nullable)

Example 63 with AccessToken

use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.

the class HgRebaseCommand method performRebase.

@Nullable
private HgCommandResult performRebase(@NotNull String... args) {
    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        final List<String> list = ContainerUtil.newArrayList(args);
        list.add("--config");
        list.add("extensions.rebase=");
        HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(repo.getRoot(), "rebase", list);
        repo.update();
        return result;
    } finally {
        token.finish();
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) AccessToken(com.intellij.openapi.application.AccessToken) Nullable(org.jetbrains.annotations.Nullable)

Example 64 with AccessToken

use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.

the class ConfigurationUtil method addAnnotatedMethodsAnSubclasses.

private static boolean addAnnotatedMethodsAnSubclasses(final GlobalSearchScope scope, final TestClassFilter testClassFilter, @Nullable final Module module, final Set<PsiClass> found, final Set<PsiClass> processed, final String annotation, final Project project) {
    final Ref<Boolean> isJUnit4 = new Ref<>(Boolean.FALSE);
    // annotated with @Test
    final PsiClass testAnnotation = ReadAction.compute(() -> JavaPsiFacade.getInstance(project).findClass(annotation, GlobalSearchScope.allScope(project)));
    if (testAnnotation != null) {
        //allScope is used to find all abstract test cases which probably have inheritors in the current 'scope'
        GlobalSearchScope allScope = module == null ? GlobalSearchScope.allScope(project) : module.getModuleRuntimeScope(true);
        ClassesWithAnnotatedMembersSearch.search(testAnnotation, allScope).forEach(annotated -> {
            AccessToken token = ReadAction.start();
            try {
                if (!processed.add(annotated)) {
                    return true;
                }
                final VirtualFile file = PsiUtilCore.getVirtualFile(annotated);
                if (file != null && scope.contains(file) && testClassFilter.isAccepted(annotated)) {
                    if (!found.add(annotated)) {
                        return true;
                    }
                    isJUnit4.set(Boolean.TRUE);
                }
            } finally {
                token.finish();
            }
            ClassInheritorsSearch.search(annotated, scope, true, true, false).forEach(new ReadActionProcessor<PsiClass>() {

                @Override
                public boolean processInReadAction(PsiClass aClass) {
                    if (testClassFilter.isAccepted(aClass)) {
                        found.add(aClass);
                        processed.add(aClass);
                        isJUnit4.set(Boolean.TRUE);
                    }
                    return true;
                }
            });
            return true;
        });
    }
    return isJUnit4.get().booleanValue();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Ref(com.intellij.openapi.util.Ref) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) AccessToken(com.intellij.openapi.application.AccessToken)

Example 65 with AccessToken

use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.

the class GithubRebaseAction method rebaseCurrentBranch.

private static void rebaseCurrentBranch(@NotNull final Project project, @NotNull final GitRepository gitRepository, @NotNull final ProgressIndicator indicator) {
    final Git git = ServiceManager.getService(project, Git.class);
    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        List<VirtualFile> rootsToSave = Collections.singletonList(gitRepository.getRoot());
        GitPreservingProcess process = new GitPreservingProcess(project, git, rootsToSave, "Rebasing", "upstream/master", GitVcsSettings.UpdateChangesPolicy.STASH, indicator, () -> {
            doRebaseCurrentBranch(project, gitRepository.getRoot(), indicator);
        });
        process.execute();
    } finally {
        token.finish();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AccessToken(com.intellij.openapi.application.AccessToken) GitPreservingProcess(git4idea.util.GitPreservingProcess)

Aggregations

AccessToken (com.intellij.openapi.application.AccessToken)89 VirtualFile (com.intellij.openapi.vfs.VirtualFile)25 Nullable (org.jetbrains.annotations.Nullable)15 Module (com.intellij.openapi.module.Module)12 Document (com.intellij.openapi.editor.Document)10 Project (com.intellij.openapi.project.Project)10 GitRepository (git4idea.repo.GitRepository)9 ArrayList (java.util.ArrayList)8 PsiElement (com.intellij.psi.PsiElement)7 NotNull (org.jetbrains.annotations.NotNull)6 File (java.io.File)5 IOException (java.io.IOException)5 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)4 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)4 CompileContext (com.intellij.openapi.compiler.CompileContext)3 CompileTask (com.intellij.openapi.compiler.CompileTask)3 PsiFile (com.intellij.psi.PsiFile)3 List (java.util.List)3 ProjectComponentReferenceCounter (com.intellij.flex.uiDesigner.mxml.ProjectComponentReferenceCounter)2 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)2