mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prohibit scheduling startup activities in default project
they won't be run anyway
This commit is contained in:
+3
-1
@@ -91,7 +91,9 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
|
||||
}
|
||||
}, project);
|
||||
|
||||
startupManager.registerStartupActivity(() -> myStartupActivityPerformed = true);
|
||||
if (!myProject.isDefault()) {
|
||||
startupManager.registerStartupActivity(() -> myStartupActivityPerformed = true);
|
||||
}
|
||||
|
||||
myHandler = new BatchUpdateListener() {
|
||||
@Override
|
||||
|
||||
@@ -77,20 +77,27 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
private void checkNonDefaultProject() {
|
||||
LOG.assertTrue(!myProject.isDefault(), "Please don't register startup activities for the default project: they won't ever be run");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPreStartupActivity(@NotNull Runnable runnable) {
|
||||
checkNonDefaultProject();
|
||||
LOG.assertTrue(!myPreStartupActivitiesPassed, "Registering pre startup activity that will never be run");
|
||||
myPreStartupActivities.add(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStartupActivity(@NotNull Runnable runnable) {
|
||||
checkNonDefaultProject();
|
||||
LOG.assertTrue(!myStartupActivitiesPassed, "Registering startup activity that will never be run");
|
||||
myStartupActivities.add(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void registerPostStartupActivity(@NotNull Runnable runnable) {
|
||||
checkNonDefaultProject();
|
||||
LOG.assertTrue(!myPostStartupActivitiesPassed, "Registering post-startup activity that will never be run:" +
|
||||
" disposed=" + myProject.isDisposed() + "; open=" + myProject.isOpen() + "; passed=" + myStartupActivitiesPassed);
|
||||
(DumbService.isDumbAware(runnable) ? myDumbAwarePostStartupActivities : myNotDumbAwarePostStartupActivities).add(runnable);
|
||||
@@ -372,7 +379,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
synchronized (this) {
|
||||
// in tests which simulate project opening, post-startup activities could have been run already.
|
||||
// Then we should act as if the project was initialized
|
||||
boolean initialized = myProject.isInitialized() || application.isUnitTestMode() && myPostStartupActivitiesPassed;
|
||||
boolean initialized = myProject.isInitialized() || myProject.isDefault() || application.isUnitTestMode() && myPostStartupActivitiesPassed;
|
||||
if (!initialized) {
|
||||
registerPostStartupActivity(action);
|
||||
return;
|
||||
|
||||
@@ -106,6 +106,8 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
}
|
||||
});
|
||||
|
||||
if (project.isDefault()) return;
|
||||
|
||||
startupManager.registerPreStartupActivity(() -> {
|
||||
DocumentAdapter documentListener = new DocumentAdapter() {
|
||||
@Override
|
||||
@@ -123,12 +125,7 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
factory.getEventMulticaster().addDocumentListener(documentListener, myProject);
|
||||
}
|
||||
});
|
||||
startupManager.registerPostStartupActivity(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fileStatusesChanged();
|
||||
}
|
||||
});
|
||||
startupManager.registerPostStartupActivity((DumbAwareRunnable)() -> fileStatusesChanged());
|
||||
}
|
||||
|
||||
public void setFileStatusProvider(final FileStatusProvider fileStatusProvider) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class VcsInitialization implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.impl.VcsInitialization");
|
||||
|
||||
private final List<Pair<VcsInitObject, Runnable>> myList = new ArrayList<>();
|
||||
private final Object myLock;
|
||||
private final Object myLock = new Object();
|
||||
@NotNull private final Project myProject;
|
||||
|
||||
// the initialization lifecycle: IDLE -(on startup completion)-> RUNNING -(on all tasks executed or project canceled)-> FINISHED
|
||||
@@ -55,7 +55,7 @@ public class VcsInitialization implements Disposable {
|
||||
|
||||
VcsInitialization(@NotNull final Project project) {
|
||||
myProject = project;
|
||||
myLock = new Object();
|
||||
if (project.isDefault()) return;
|
||||
|
||||
StartupManager.getInstance(project).registerPostStartupActivity((DumbAwareRunnable)() -> {
|
||||
if (project.isDisposed()) return;
|
||||
|
||||
Reference in New Issue
Block a user