Search in sources :

Example 66 with AccessToken

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

the class MavenImportingTestCase method getModule.

protected Module getModule(final String name) {
    AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
    try {
        Module m = ModuleManager.getInstance(myProject).findModuleByName(name);
        assertNotNull("Module " + name + " not found", m);
        return m;
    } finally {
        accessToken.finish();
    }
}
Also used : AccessToken(com.intellij.openapi.application.AccessToken) Module(com.intellij.openapi.module.Module)

Example 67 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 68 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 69 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 70 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)

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