deprecate test-only runStartupActivities

GitOrigin-RevId: ab697c5a8a9aa110b8d5887db6726525eb0c2ba9
This commit is contained in:
Vladimir Krivosheev
2020-05-31 10:16:52 +03:00
committed by intellij-monorepo-bot
parent 65845e23cc
commit 735f01ce05
14 changed files with 36 additions and 43 deletions
@@ -14,7 +14,6 @@ import com.intellij.codeInspection.InspectionToolProvider;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.ide.startup.StartupManagerEx;
import com.intellij.ide.startup.impl.StartupManagerImpl;
import com.intellij.lang.ExternalAnnotatorsFilter;
import com.intellij.lang.LanguageAnnotators;
@@ -76,9 +75,6 @@ public abstract class DaemonAnalyzerTestCase extends JavaCodeInsightTestCase {
DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
daemonCodeAnalyzer.prepareForTest();
StartupManagerImpl startupManager = (StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject());
startupManager.runStartupActivities();
startupManager.runPostStartupActivitiesRegisteredDynamically();
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
if (isStressTest()) {
@@ -2,6 +2,7 @@
package com.intellij.openapi.startup;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
@@ -31,9 +32,8 @@ public abstract class StartupManager {
/**
* Registers an activity that is performed during project load while the "Loading Project"
* progress bar is displayed. You may NOT access the PSI structures from the activity.
*
* @param runnable the activity to execute.
*/
@ApiStatus.Internal
public abstract void registerStartupActivity(@NotNull Runnable runnable);
/**
@@ -393,7 +393,7 @@ public final class PerformanceWatcher implements Disposable {
Objects.equals(el1.getFileName(), el2.getFileName());
}
public class Snapshot {
public final class Snapshot {
private final ApdexData myStartGeneralSnapshot = myGeneralApdex;
private final ApdexData myStartSwingSnapshot = mySwingApdex;
private final long myStartMillis = System.currentTimeMillis();
@@ -37,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
@@ -184,7 +185,11 @@ public class StartupManagerImpl extends StartupManagerEx {
});
}
/**
* @deprecated Use {@link com.intellij.testFramework.PlatformTestUtil#loadAndOpenProject(Path)} in tests.
*/
@TestOnly
@Deprecated
public void runStartupActivities() {
if (!myStartupActivitiesPassed) {
doRunStartUpActivities(null);
@@ -53,9 +53,9 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
protected boolean myStartupActivityPerformed;
private boolean myStateLoaded = false;
private final RootProviderChangeListener myRootProviderChangeListener = new RootProviderChangeListener();
private final RootProvider.RootSetChangedListener myRootProviderChangeListener = new RootProviderChangeListener();
protected class BatchSession {
protected final class BatchSession {
private final boolean myFileTypes;
private int myBatchLevel;
private boolean myChanged;
@@ -64,14 +64,14 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
myFileTypes = fileTypes;
}
protected void levelUp() {
void levelUp() {
if (myBatchLevel == 0) {
myChanged = false;
}
myBatchLevel += 1;
}
protected void levelDown() {
void levelDown() {
myBatchLevel -= 1;
if (myChanged && myBatchLevel == 0) {
try {
@@ -180,10 +180,8 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
@Override
public VirtualFile @NotNull [] getContentRootsFromAllModules() {
List<VirtualFile> result = new ArrayList<>();
final Module[] modules = getModuleManager().getSortedModules();
for (Module module : modules) {
final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
ContainerUtil.addAll(result, files);
for (Module module : getModuleManager().getSortedModules()) {
Collections.addAll(result, ModuleRootManager.getInstance(module).getContentRoots());
}
ContainerUtil.addIfNotNull(result, myProject.getBaseDir());
return VfsUtilCore.toVirtualFileArray(result);
@@ -533,7 +531,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
}
}
private class LibraryTableMultiListener extends ListenerContainer<LibraryTable.Listener> implements LibraryTable.Listener {
private final class LibraryTableMultiListener extends ListenerContainer<LibraryTable.Listener> implements LibraryTable.Listener {
private LibraryTableMultiListener() {
super(new LibraryTable.Listener[0]);
}
@@ -158,7 +158,7 @@ class ProjectRule(val projectDescriptor: LightProjectDescriptor = LightProjectDe
}
if (projectOpened.compareAndSet(false, true)) {
runInEdtAndWait { PlatformTestUtil.openTestProject(project) }
runInEdtAndWait { PlatformTestUtil.openProject(project) }
}
return result!!
}
@@ -275,7 +275,7 @@ suspend fun Project.use(task: suspend (Project) -> Unit) {
try {
if (!projectManager.isProjectOpened(this)) {
withContext(AppUIExecutor.onUiThread().coroutineDispatchingContext()) {
PlatformTestUtil.openTestProject(this@use)
PlatformTestUtil.openProject(this@use)
}
}
task(this)
@@ -252,7 +252,7 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
protected void setUpProject() throws Exception {
myProject = doCreateProject(getProjectDirOrFile());
PlatformTestUtil.openTestProject(myProject);
PlatformTestUtil.openProject(myProject);
LocalFileSystem.getInstance().refreshIoFiles(myFilesToDelete);
WriteAction.run(() ->
@@ -281,7 +281,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
Project project = ourProject;
try {
PlatformTestUtil.openTestProject(project);
PlatformTestUtil.openProject(project);
}
catch (Throwable e) {
setProject(null);
@@ -1100,11 +1100,11 @@ public final class PlatformTestUtil {
public static @NotNull Project loadAndOpenProject(@NotNull Path path) {
Project project = ProjectManagerImpl.loadProject(path, null);
openTestProject(project);
openProject(project);
return project;
}
public static void openTestProject(@NotNull Project project) {
public static void openProject(@NotNull Project project) {
assert ApplicationManager.getApplication().isUnitTestMode();
if (!ProjectManagerEx.getInstanceEx().openProject(project)) {
throw new IllegalStateException("openProject returned false");
@@ -182,7 +182,7 @@ final class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTes
});
EdtTestUtil.runInEdtAndWait(() -> {
PlatformTestUtil.openTestProject(myProject);
PlatformTestUtil.openProject(myProject);
for (ModuleFixtureBuilder<?> moduleFixtureBuilder : myModuleFixtureBuilders) {
moduleFixtureBuilder.getFixture().setUp();
@@ -20,10 +20,6 @@ import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar
import com.intellij.openapi.util.Ref
import com.intellij.openapi.util.io.systemIndependentPath
import com.intellij.testFramework.*
import com.intellij.testFramework.DisposableRule
import com.intellij.testFramework.RuleChain
import com.intellij.testFramework.createHeavyProject
import com.intellij.testFramework.runInEdtAndWait
import com.intellij.workspace.api.TypedEntityStorageBuilder
import com.intellij.workspace.ide.WorkspaceModelInitialTestContent
import org.junit.rules.ExternalResource
@@ -47,7 +43,7 @@ class ProjectModelRule(private val forceEnableWorkspaceModel: Boolean = false) :
createHeavyProject(baseProjectDir.root.toPath())
}
runInEdtAndWait {
PlatformTestUtil.openTestProject(project)
PlatformTestUtil.openProject(project)
}
}
@@ -1,8 +1,6 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.vcs
import com.intellij.ide.startup.impl.StartupManagerImpl
import com.intellij.openapi.startup.StartupManager
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
@@ -19,7 +17,6 @@ import com.intellij.testFramework.HeavyPlatformTestCase
import com.intellij.testFramework.PlatformTestUtil
import com.intellij.testFramework.PsiTestUtil
import com.intellij.testFramework.TestLoggerFactory
import com.intellij.util.ui.UIUtil
import com.intellij.vcsUtil.VcsUtil
import org.junit.Assume
import java.io.File
@@ -66,11 +63,7 @@ class DirectoryMappingListTest : HeavyPlatformTestCase() {
mappings = NewMappings(myProject, vcsManager)
mappings.activateActiveVcses()
Disposer.register(testRootDisposable, mappings)
UIUtil.dispatchAllInvocationEvents()
val startupManager = StartupManager.getInstance(myProject) as StartupManagerImpl
startupManager.runStartupActivities()
startupManager.runPostStartupActivitiesRegisteredDynamically()
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
vcsManager.waitForInitialized()
}
@@ -407,7 +407,7 @@ class LegacyBridgeModulesTest {
WorkspaceModelInitialTestContent.withInitialContent(builder.toStorage()) {
val project = ProjectManager.getInstance().createProject("testProject", iprFile.path)!!
invokeAndWaitIfNeeded { PlatformTestUtil.openTestProject(project) }
invokeAndWaitIfNeeded { PlatformTestUtil.openProject(project) }
disposableRule.disposable.attach { invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().forceCloseProject(project) } }
val module = ModuleManager.getInstance(project).findModuleByName("test")
@@ -442,7 +442,7 @@ class LegacyBridgeModulesTest {
WorkspaceModelInitialTestContent.withInitialContent(builder.toStorage()) {
val project = ProjectManager.getInstance().createProject("testProject", iprFile.path)!!
invokeAndWaitIfNeeded { PlatformTestUtil.openTestProject(project) }
invokeAndWaitIfNeeded { PlatformTestUtil.openProject(project) }
disposableRule.disposable.attach { invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().forceCloseProject(project) } }
val projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project)
@@ -658,7 +658,7 @@ internal fun createEmptyTestProject(temporaryDirectory: TemporaryDirectory, disp
val project = WorkspaceModelInitialTestContent.withInitialContent(TypedEntityStorageBuilder.create()) {
ProjectManager.getInstance().createProject("testProject", projectDir.resolve("testProject.ipr").toString())!!
}
invokeAndWaitIfNeeded { PlatformTestUtil.openTestProject(project) }
invokeAndWaitIfNeeded { PlatformTestUtil.openProject(project) }
disposableRule.disposable.attach { invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().forceCloseProject(project) } }
return project
}
@@ -195,7 +195,9 @@ public final class MavenProjectsManager extends MavenSimpleProjectComponent
StartupManager startupManager = StartupManager.getInstance(myProject);
startupManager.registerStartupActivity(() -> {
boolean wasMavenized = !myState.originalFiles.isEmpty();
if (!wasMavenized) return;
if (!wasMavenized) {
return;
}
initMavenized();
});
@@ -267,8 +269,9 @@ public final class MavenProjectsManager extends MavenSimpleProjectComponent
private void initNew(List<VirtualFile> files, MavenExplicitProfiles explicitProfiles) {
myState.originalFiles = MavenUtil.collectPaths(files);
getWorkspaceSettings().setEnabledProfiles(explicitProfiles.getEnabledProfiles());
getWorkspaceSettings().setDisabledProfiles(explicitProfiles.getDisabledProfiles());
MavenWorkspaceSettings workspaceSettings = getWorkspaceSettings();
workspaceSettings.setEnabledProfiles(explicitProfiles.getEnabledProfiles());
workspaceSettings.setDisabledProfiles(explicitProfiles.getDisabledProfiles());
doInit(true);
}
@@ -280,7 +283,9 @@ public final class MavenProjectsManager extends MavenSimpleProjectComponent
private void doInit(final boolean isNew) {
initLock.lock();
try {
if (isInitialized.getAndSet(true)) return;
if (isInitialized.getAndSet(true)) {
return;
}
initProjectsTree(!isNew);