Search in sources :

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

Example 57 with AccessToken

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

the class FormReferencesSearcher method processReferencesInUIForms.

private static boolean processReferencesInUIForms(Processor<PsiReference> processor, PsiManager psiManager, PsiField field, GlobalSearchScope scope1, LocalSearchScope filterScope) {
    GlobalSearchScope scope = GlobalSearchScope.projectScope(psiManager.getProject()).intersectWith(scope1);
    final AccessToken token = ReadAction.start();
    PsiClass containingClass = field.getContainingClass();
    if (containingClass == null)
        return true;
    String fieldName;
    try {
        fieldName = field.getName();
    } finally {
        token.finish();
    }
    final List<PsiFile> files = FormClassIndex.findFormsBoundToClass(psiManager.getProject(), containingClass, scope);
    return processReferencesInFiles(files, psiManager, fieldName, field, filterScope, processor);
}
Also used : AccessToken(com.intellij.openapi.application.AccessToken)

Example 58 with AccessToken

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

the class HgRollbackEnvironment method rollbackChanges.

public void rollbackChanges(List<Change> changes, List<VcsException> vcsExceptions, @NotNull RollbackProgressListener listener) {
    if (changes == null || changes.isEmpty()) {
        return;
    }
    List<FilePath> toDelete = new ArrayList<>();
    List<FilePath> filePaths = new LinkedList<>();
    for (Change change : changes) {
        ContentRevision contentRevision;
        if (Change.Type.DELETED == change.getType()) {
            contentRevision = change.getBeforeRevision();
        } else {
            contentRevision = change.getAfterRevision();
        }
        if (contentRevision != null) {
            filePaths.add(contentRevision.getFile());
            if (Change.Type.MOVED == change.getType()) {
                toDelete.add(contentRevision.getFile());
            }
        }
    }
    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        revert(filePaths);
        for (FilePath file : toDelete) {
            listener.accept(file);
            try {
                final File ioFile = file.getIOFile();
                if (ioFile.exists()) {
                    if (!ioFile.delete()) {
                        //noinspection ThrowableInstanceNeverThrown
                        vcsExceptions.add(new VcsException("Unable to delete file: " + file));
                    }
                }
            } catch (Exception e) {
                //noinspection ThrowableInstanceNeverThrown
                vcsExceptions.add(new VcsException("Unable to delete file: " + file, e));
            }
        }
    } finally {
        token.finish();
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) AccessToken(com.intellij.openapi.application.AccessToken) VcsException(com.intellij.openapi.vcs.VcsException) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VcsException(com.intellij.openapi.vcs.VcsException)

Example 59 with AccessToken

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

the class HgUpdateCommand method execute.

@Nullable
public HgCommandResult execute() {
    List<String> arguments = new LinkedList<>();
    if (clean) {
        arguments.add("--clean");
    }
    if (!StringUtil.isEmptyOrSpaces(revision)) {
        arguments.add("--rev");
        arguments.add(revision);
    }
    final HgPromptCommandExecutor executor = new HgPromptCommandExecutor(project);
    executor.setShowOutput(true);
    HgCommandResult result;
    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        result = executor.executeInCurrentThread(repo, "update", arguments);
        if (!clean && hasUncommittedChangesConflict(result)) {
            final String message = "<html>Your uncommitted changes couldn't be merged into the requested changeset.<br>" + "Would you like to perform force update and discard them?";
            if (showDiscardChangesConfirmation(project, message) == Messages.OK) {
                arguments.add("-C");
                result = executor.executeInCurrentThread(repo, "update", arguments);
            }
        }
    } finally {
        token.finish();
    }
    VfsUtil.markDirtyAndRefresh(false, true, false, repo);
    return result;
}
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 60 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)

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