Search in sources :

Example 71 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)

Example 72 with AccessToken

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

the class GradleStartupActivity method runActivity.

@Override
public void runActivity(@NotNull final Project project) {
    configureBuildClasspath(project);
    showNotificationForUnlinkedGradleProject(project);
    final GradleResourceCompilerConfigurationGenerator buildConfigurationGenerator = new GradleResourceCompilerConfigurationGenerator(project);
    CompilerManager.getInstance(project).addBeforeTask(new CompileTask() {

        @Override
        public boolean execute(CompileContext context) {
            AccessToken token = ReadAction.start();
            try {
                buildConfigurationGenerator.generateBuildConfiguration(context);
            } finally {
                token.finish();
            }
            return true;
        }
    });
}
Also used : GradleResourceCompilerConfigurationGenerator(org.jetbrains.plugins.gradle.config.GradleResourceCompilerConfigurationGenerator) CompileTask(com.intellij.openapi.compiler.CompileTask) AccessToken(com.intellij.openapi.application.AccessToken) CompileContext(com.intellij.openapi.compiler.CompileContext)

Example 73 with AccessToken

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

the class GradleCompilingTestCase method setUpInWriteAction.

@Override
protected void setUpInWriteAction() throws Exception {
    super.setUpInWriteAction();
    final GradleResourceCompilerConfigurationGenerator buildConfigurationGenerator = new GradleResourceCompilerConfigurationGenerator(myProject);
    CompilerManager.getInstance(myProject).addBeforeTask(new CompileTask() {

        @Override
        public boolean execute(CompileContext context) {
            AccessToken token = ReadAction.start();
            try {
                buildConfigurationGenerator.generateBuildConfiguration(context);
            } finally {
                token.finish();
            }
            return true;
        }
    });
}
Also used : GradleResourceCompilerConfigurationGenerator(org.jetbrains.plugins.gradle.config.GradleResourceCompilerConfigurationGenerator) CompileTask(com.intellij.openapi.compiler.CompileTask) AccessToken(com.intellij.openapi.application.AccessToken) CompileContext(com.intellij.openapi.compiler.CompileContext)

Example 74 with AccessToken

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

the class GradleClassFinderTest method testClassesFilter.

@Test
public void testClassesFilter() throws Exception {
    createProjectSubFile("settings.gradle", "rootProject.name = 'multiproject'\n" + "include ':app'");
    // app module files
    createProjectSubFile("app/src/main/groovy/App.groovy", "class App {}");
    // buildSrc module files
    createProjectSubFile("buildSrc/src/main/groovy/org/buildsrc/BuildSrcClass.groovy", "package org.buildsrc;\n" + "import groovy.util.AntBuilder;\n" + "public class BuildSrcClass {}");
    importProject("subprojects {\n" + "    apply plugin: 'groovy'\n" + "}");
    assertModules("multiproject", "app", "app_main", "app_test", "buildSrc", "buildSrc_main", "buildSrc_test");
    Module buildSrcModule = getModule("buildSrc_main");
    assertNotNull(buildSrcModule);
    final AccessToken accessToken = ReadAction.start();
    try {
        PsiClass[] appClasses = JavaPsiFacade.getInstance(myProject).findClasses("App", GlobalSearchScope.allScope(myProject));
        assertEquals(1, appClasses.length);
        PsiClass[] buildSrcClasses = JavaPsiFacade.getInstance(myProject).findClasses("org.buildsrc.BuildSrcClass", GlobalSearchScope.moduleScope(buildSrcModule));
        assertEquals(1, buildSrcClasses.length);
    } finally {
        accessToken.finish();
    }
}
Also used : AccessToken(com.intellij.openapi.application.AccessToken) PsiClass(com.intellij.psi.PsiClass) Module(com.intellij.openapi.module.Module) Test(org.junit.Test)

Example 75 with AccessToken

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

the class MavenRunner method runBatch.

public boolean runBatch(List<MavenRunnerParameters> commands, @Nullable MavenGeneralSettings coreSettings, @Nullable MavenRunnerSettings runnerSettings, @Nullable final String action, @Nullable ProgressIndicator indicator) {
    LOG.assertTrue(!ApplicationManager.getApplication().isReadAccessAllowed());
    if (commands.isEmpty())
        return true;
    MavenConsole console;
    AccessToken accessToken = ReadAction.start();
    try {
        if (myProject.isDisposed())
            return false;
        console = createConsole();
    } finally {
        accessToken.finish();
    }
    try {
        int count = 0;
        for (MavenRunnerParameters command : commands) {
            if (indicator != null) {
                indicator.setFraction(((double) count++) / commands.size());
            }
            MavenExecutor executor;
            accessToken = ReadAction.start();
            try {
                if (myProject.isDisposed())
                    break;
                executor = createExecutor(command, coreSettings, runnerSettings, console);
            } finally {
                accessToken.finish();
            }
            executor.setAction(action);
            if (!executor.execute(indicator)) {
                updateTargetFolders();
                return false;
            }
        }
        updateTargetFolders();
    } finally {
        console.finish();
    }
    return true;
}
Also used : AccessToken(com.intellij.openapi.application.AccessToken) MavenConsole(org.jetbrains.idea.maven.project.MavenConsole)

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