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;
}
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);
}
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();
}
}
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;
}
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();
}
}
Aggregations