mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
allow isUpToDate() to be called from EDT;
return false if another compilation session is in progress
This commit is contained in:
@@ -220,18 +220,8 @@ public class CompileDriver {
|
||||
if (!useOutOfProcessBuild()) {
|
||||
scope = addAdditionalRoots(scope, ALL_EXCEPT_SOURCE_PROCESSING);
|
||||
}
|
||||
else {
|
||||
final Application app = ApplicationManager.getApplication();
|
||||
if (!app.isUnitTestMode()) {
|
||||
final boolean isDispatchThread = app.isDispatchThread();
|
||||
LOG.assertTrue(!isDispatchThread, "Calling isUpToDate() from Event Dispatch Thread may cause deadlocks");
|
||||
if (isDispatchThread) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final CompilerTask task = new CompilerTask(myProject, "Classes up-to-date check", true, false);
|
||||
final CompilerTask task = new CompilerTask(myProject, "Classes up-to-date check", true, false, false);
|
||||
final DependencyCache cache = useOutOfProcessBuild()? null : createDependencyCache();
|
||||
final CompileContextImpl compileContext = new CompileContextImpl(myProject, task, scope, cache, true, false);
|
||||
|
||||
@@ -640,7 +630,7 @@ public class CompileDriver {
|
||||
|
||||
final String contentName =
|
||||
forceCompile ? CompilerBundle.message("compiler.content.name.compile") : CompilerBundle.message("compiler.content.name.make");
|
||||
final CompilerTask compileTask = new CompilerTask(myProject, contentName, ApplicationManager.getApplication().isUnitTestMode(), true);
|
||||
final CompilerTask compileTask = new CompilerTask(myProject, contentName, ApplicationManager.getApplication().isUnitTestMode(), true, true);
|
||||
|
||||
StatusBar.Info.set("", myProject, "Compiler");
|
||||
if (useExtProcessBuild) {
|
||||
@@ -2282,8 +2272,7 @@ public class CompileDriver {
|
||||
}
|
||||
|
||||
public void executeCompileTask(final CompileTask task, final CompileScope scope, final String contentName, final Runnable onTaskFinished) {
|
||||
final CompilerTask progressManagerTask =
|
||||
new CompilerTask(myProject, contentName, false, false);
|
||||
final CompilerTask progressManagerTask = new CompilerTask(myProject, contentName, false, false, true);
|
||||
final CompileContextImpl compileContext = new CompileContextImpl(myProject, progressManagerTask, scope, null, false, false);
|
||||
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
|
||||
@@ -80,6 +80,7 @@ public class CompilerTask extends Task.Backgroundable {
|
||||
private final String myContentName;
|
||||
private final boolean myHeadlessMode;
|
||||
private final boolean myForceAsyncExecution;
|
||||
private final boolean myWaitForPreviousSession;
|
||||
private int myErrorCount = 0;
|
||||
private int myWarningCount = 0;
|
||||
private boolean myMessagesAutoActivated = false;
|
||||
@@ -89,11 +90,12 @@ public class CompilerTask extends Task.Backgroundable {
|
||||
private final AtomicBoolean myMessageViewWasPrepared = new AtomicBoolean(false);
|
||||
private Runnable myRestartWork;
|
||||
|
||||
public CompilerTask(@NotNull Project project, String contentName, final boolean headlessMode, boolean forceAsync) {
|
||||
public CompilerTask(@NotNull Project project, String contentName, final boolean headlessMode, boolean forceAsync, boolean waitForPreviousSession) {
|
||||
super(project, contentName);
|
||||
myContentName = contentName;
|
||||
myHeadlessMode = headlessMode;
|
||||
myForceAsyncExecution = forceAsync;
|
||||
myWaitForPreviousSession = waitForPreviousSession;
|
||||
}
|
||||
|
||||
public void setContentIdKey(Key<Key<?>> contentIdKey) {
|
||||
@@ -136,7 +138,10 @@ public class CompilerTask extends Task.Backgroundable {
|
||||
|
||||
try {
|
||||
while (!acquired) {
|
||||
acquired = semaphore.tryAcquire(500, TimeUnit.MILLISECONDS);
|
||||
acquired = semaphore.tryAcquire(300, TimeUnit.MILLISECONDS);
|
||||
if (!acquired && !myWaitForPreviousSession) {
|
||||
return;
|
||||
}
|
||||
if (indicator.isCanceled()) {
|
||||
// give up obtaining the semaphore,
|
||||
// let compile work begin in order to stop gracefuly on cancel event
|
||||
|
||||
Reference in New Issue
Block a user