Alexey Kudravtsev
2014-10-07 13:38:20 +04:00
parent f49ec72513
commit b1eb1477f8
2 changed files with 24 additions and 10 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import com.intellij.concurrency.JobLauncher;
import com.intellij.injected.editor.DocumentWindow;
import com.intellij.lang.Language;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -145,6 +146,7 @@ public class InjectedGeneralHighlightingPass extends GeneralHighlightingPass imp
private Set<PsiFile> getInjectedPsiFiles(@NotNull final List<PsiElement> elements1,
@NotNull final List<PsiElement> elements2,
@NotNull final ProgressIndicator progress) {
ApplicationManager.getApplication().assertReadAccessAllowed();
final Set<PsiFile> outInjected = new THashSet<PsiFile>();
List<DocumentWindow> injected = InjectedLanguageUtil.getCachedInjectedDocuments(myFile);
@@ -16,6 +16,7 @@
package com.intellij.concurrency;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
@@ -129,19 +130,30 @@ public class JobLauncherImpl extends JobLauncher {
if (things.size() <= 1 || JobSchedulerImpl.CORES_COUNT <= CORES_FORK_THRESHOLD) {
final AtomicBoolean result = new AtomicBoolean(true);
ProgressManager.getInstance().executeProcessUnderProgress(new Runnable() {
Runnable runnable = new Runnable() {
@Override
public void run() {
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < things.size(); i++) {
T thing = things.get(i);
if (!thingProcessor.process(thing)) {
result.set(false);
break;
ProgressManager.getInstance().executeProcessUnderProgress(new Runnable() {
@Override
public void run() {
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < things.size(); i++) {
T thing = things.get(i);
if (!thingProcessor.process(thing)) {
result.set(false);
break;
}
}
}
}
}, wrapper);
}
}, wrapper);
};
if (runInReadAction) {
if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(runnable)) return false;
}
else {
runnable.run();
}
return result.get();
}