remove unused ProjectLoadListener, add StartupManagerTest

GitOrigin-RevId: 4b1e8ed408b44f7b25d99ba2a4a4bccde3a8444d
This commit is contained in:
Vladimir Krivosheev
2020-05-31 09:38:46 +03:00
committed by intellij-monorepo-bot
parent fedf5828ff
commit 65845e23cc
60 changed files with 462 additions and 592 deletions
@@ -128,9 +128,13 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
if (!project.isDefault()) {
// initial state
StartupManager.getInstance(project).runAfterOpened(() -> {myRegisteredCompilers = collectCompilers();});
StartupManager.getInstance(project).runAfterOpened(() -> {
myRegisteredCompilers = collectCompilers();
});
}
BackendCompiler.EP_NAME.getPoint(project).addChangeListener(() -> {myRegisteredCompilers = collectCompilers();}, project);
BackendCompiler.EP_NAME.getPoint(project).addChangeListener(() -> {
myRegisteredCompilers = collectCompilers();
}, project);
}
// Overridden in Upsource
@@ -165,15 +165,10 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
protected void setUpProject() throws Exception {
super.setUpProject();
ProjectManagerEx.getInstanceEx().openProject(getProject());
super.runStartupActivities();
UIUtil.dispatchAllInvocationEvents(); // startup activities
EditorMouseHoverPopupManager.getInstance(); // treat listeners added there as not leaks
}
@Override
protected void runStartupActivities() {
}
private static void typeInAlienEditor(@NotNull Editor alienEditor, char c) {
EditorActionManager.getInstance();
TypedAction action = TypedAction.getInstance();
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.java.codeInsight.daemon.quickFix;
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
@@ -13,13 +13,13 @@ import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
@@ -28,9 +28,6 @@ import java.nio.file.Paths;
import java.util.Collection;
import java.util.List;
/**
* @author cdr
*/
public class OrderEntryTest extends DaemonAnalyzerTestCase {
@NonNls public static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/";
@@ -43,8 +40,7 @@ public class OrderEntryTest extends DaemonAnalyzerTestCase {
VirtualFile projectFile = tempProjectRootDir.findChild("orderEntry.ipr");
myProject = ProjectManagerEx.getInstanceEx().loadProject(Paths.get(projectFile.getPath()));
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
myProject = PlatformTestUtil.loadAndOpenProject(Paths.get(projectFile.getPath()));
UIUtil.dispatchAllInvocationEvents(); // startup activities
setUpJdk();
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.java.navigation;
import com.intellij.JavaTestUtil;
@@ -7,7 +7,6 @@ import com.intellij.codeInsight.navigation.ClassImplementationsSearch;
import com.intellij.codeInsight.navigation.MethodImplementationsSearch;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -15,6 +14,7 @@ import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.CommonProcessors;
import java.nio.file.Paths;
@@ -37,13 +37,9 @@ public class GotoImplementationTest extends JavaCodeInsightTestCase {
@Override
protected void setUpProject() {
final String root = JavaTestUtil.getJavaTestDataPath() + "/codeInsight/navigation/alexProject";
String root = JavaTestUtil.getJavaTestDataPath() + "/codeInsight/navigation/alexProject";
VirtualFile vfsRoot = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(root));
VirtualFile projectFile = vfsRoot.findChild("test.ipr");
myProject = ProjectManagerEx.getInstanceEx().loadProject(Paths.get(projectFile.getPath()));
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
myProject = PlatformTestUtil.loadAndOpenProject(Paths.get(vfsRoot.findChild("test.ipr").getPath()));
}
public void test() {
@@ -83,7 +79,5 @@ public class GotoImplementationTest extends JavaCodeInsightTestCase {
myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module3))
));
assertEquals(expectedImpls3, new HashSet<>(getClassImplementations(test3)));
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.java.psi.search;
import com.intellij.JavaTestUtil;
@@ -7,7 +7,6 @@ import com.intellij.ide.todo.TodoConfiguration;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.projectRoots.impl.ProjectRootUtil;
import com.intellij.openapi.roots.ModuleRootManager;
@@ -33,22 +32,25 @@ import com.intellij.util.ArrayUtilRt;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
@HeavyPlatformTestCase.WrapInCommand
public class UpdateCacheTest extends JavaPsiTestCase {
@Override
protected void setUpProject() throws Exception {
loadAndSetupProject(getProjectDirOrFile().toString());
loadAndSetupProject(getProjectDirOrFile());
}
private void loadAndSetupProject(String path) throws Exception {
private void loadAndSetupProject(@NotNull Path path) throws Exception {
LocalFileSystem.getInstance().refreshIoFiles(myFilesToDelete);
myProject = ProjectManager.getInstance().loadAndOpenProject(path);
myProject = PlatformTestUtil.loadAndOpenProject(path);
setUpModule();
@@ -56,9 +58,6 @@ public class UpdateCacheTest extends JavaPsiTestCase {
createTestProjectStructure( root);
setUpJdk();
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
runStartupActivities();
}
public void testFileCreation() {
@@ -121,10 +120,10 @@ public class UpdateCacheTest extends JavaPsiTestCase {
checkUsages(objectClass, ArrayUtil.EMPTY_STRING_ARRAY);
FileBasedIndex.getInstance().getContainingFiles(TodoIndex.NAME, new TodoIndexEntry("todo", true), GlobalSearchScope.allScope(getProject()));
final String projectLocation = myProject.getPresentableUrl();
String projectLocation = myProject.getPresentableUrl();
assert projectLocation != null : myProject;
PlatformTestUtil.saveProject(myProject);
final VirtualFile content = ModuleRootManager.getInstance(getModule()).getContentRoots()[0];
VirtualFile content = ModuleRootManager.getInstance(getModule()).getContentRoots()[0];
Project project = myProject;
ProjectManagerEx.getInstanceEx().forceCloseProject(project);
myProject = null;
@@ -141,15 +140,13 @@ public class UpdateCacheTest extends JavaPsiTestCase {
LocalFileSystem.getInstance().refresh(false);
myProject = ProjectManager.getInstance().loadAndOpenProject(projectLocation);
myProject = PlatformTestUtil.loadAndOpenProject(Paths.get(projectLocation));
InjectedLanguageManagerImpl.pushInjectors(getProject());
setUpModule();
setUpJdk();
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
UIUtil.dispatchAllInvocationEvents(); // startup activities
runStartupActivities();
PsiTestUtil.addSourceContentToRoots(getModule(), content);
assertNotNull(myProject);
@@ -1,14 +1,16 @@
// Copyright 2000-2019 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.
// 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.roots.ui.configuration;
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.LightPlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import java.nio.file.Paths;
import static com.intellij.testFramework.assertions.Assertions.assertThat;
@@ -19,7 +21,7 @@ public class LanguageLevelComboTest extends LightPlatformTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
myProject = ProjectManager.getInstance().loadAndOpenProject(PathManagerEx.getTestDataPath("/ide/project"));
myProject = PlatformTestUtil.loadAndOpenProject(Paths.get(PathManagerEx.getTestDataPath("/ide/project")));
myCombo = new LanguageLevelCombo("default") {
@Override
protected LanguageLevel getDefaultLevel() {
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.project;
import com.intellij.codeHighlighting.Pass;
@@ -11,7 +11,6 @@ import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.LocalFileSystem;
@@ -21,16 +20,19 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.testFramework.HeavyPlatformTestCase;
import com.intellij.testFramework.LeakHunter;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.ServiceContainerUtil;
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
import java.nio.file.Paths;
import static com.intellij.testFramework.RunAll.runAll;
public class LoadProjectTest extends HeavyPlatformTestCase {
@Override
protected void setUpProject() throws Exception {
String projectPath = PathManagerEx.getTestDataPath() + "/model/model.ipr";
myProject = ProjectManager.getInstance().loadAndOpenProject(projectPath);
myProject = PlatformTestUtil.loadAndOpenProject(Paths.get(projectPath));
ServiceContainerUtil.registerComponentImplementation(myProject, FileEditorManager.class, FileEditorManagerImpl.class);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.roots
import com.intellij.openapi.Disposable
@@ -24,6 +24,7 @@ import org.junit.ClassRule
import org.junit.Rule
import org.junit.Test
import java.io.File
import java.nio.file.Paths
@RunsInEdt
class AutomaticModuleUnloaderTest {
@@ -190,7 +191,7 @@ class AutomaticModuleUnloaderTest {
}
JDOMUtil.write(rootElement, modulesXmlFile)
beforeReload()
val reloaded = ProjectManager.getInstance().loadAndOpenProject(project.basePath!!)!!
val reloaded = PlatformTestUtil.loadAndOpenProject(Paths.get(project.basePath!!))
Disposer.register(disposableRule.disposable, Disposable { ProjectManagerEx.getInstanceEx().forceCloseProject(reloaded) })
return reloaded
}
@@ -1,11 +1,10 @@
// Copyright 2000-2019 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.
// 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.roots;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.JavaModuleType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.vfs.LocalFileSystem;
@@ -15,12 +14,10 @@ import com.intellij.testFramework.PlatformTestUtil;
import kotlin.Unit;
import java.io.File;
import java.nio.file.Paths;
/**
* @author Dmitry Avdeev
*/
public class ModuleLoadingStressTest extends HeavyPlatformTestCase {
public void testContentEntryExchange() throws Exception {
public void testContentEntryExchange() {
String path = myProject.getBasePath();
int count = 100;
for (int i = 0; i < count; i++) {
@@ -40,7 +37,7 @@ public class ModuleLoadingStressTest extends HeavyPlatformTestCase {
String moduleName = myModule.getName();
PlatformTestUtil.forceCloseProjectWithoutSaving(myProject);
myProject = ProjectManager.getInstance().loadAndOpenProject(projectFilePath);
myProject = PlatformTestUtil.loadAndOpenProject(Paths.get(projectFilePath));
Module[] modules = ModuleManager.getInstance(myProject).getModules();
assertEquals(count * 2 + 1, modules.length);
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.roots
import com.intellij.openapi.application.ex.PathManagerEx
@@ -13,12 +13,14 @@ import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.testFramework.JavaModuleTestCase
import com.intellij.testFramework.PlatformTestUtil
import java.io.File
import java.nio.file.Paths
class UnloadedModulesConfigurationTest : JavaModuleTestCase() {
fun `test load project`() {
val projectPath = FileUtilRt.toSystemIndependentName(File(PathManagerEx.getTestDataPath(), "moduleRootManager/unloadedModules").absolutePath)
val project = getProjectManager().loadAndOpenProject(projectPath)!!
val project = PlatformTestUtil.loadAndOpenProject(Paths.get(projectPath))
try {
val moduleManager = ModuleManager.getInstance(project)
assertEquals(3, moduleManager.allModuleDescriptions.size)
@@ -41,7 +41,7 @@ public abstract class JavaPsiTestCase extends JavaModuleTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
myPsiManager = (PsiManagerImpl) PsiManager.getInstance(myProject);
myPsiManager = (PsiManagerImpl)PsiManager.getInstance(myProject);
}
@Override
@@ -14,14 +14,12 @@ import org.jetbrains.annotations.NotNull;
* See https://github.com/JetBrains/intellij-community/blob/master/platform/service-container/overview.md#startup-activity.
*/
public interface StartupActivity {
ExtensionPointName<StartupActivity> POST_STARTUP_ACTIVITY = ExtensionPointName.create("com.intellij.postStartupActivity");
ExtensionPointName<StartupActivity> POST_STARTUP_ACTIVITY = new ExtensionPointName<>("com.intellij.postStartupActivity");
/**
* Please see https://github.com/JetBrains/intellij-community/blob/master/platform/service-container/overview.md#startup-activity
*/
ExtensionPointName<StartupActivity.Background> BACKGROUND_POST_STARTUP_ACTIVITY = ExtensionPointName.create("com.intellij.backgroundPostStartupActivity");
ExtensionPointName<StartupActivity.RequiredForSmartMode> REQUIRED_FOR_SMART_MODE_STARTUP_ACTIVITY = ExtensionPointName.create("com.intellij.requiredForSmartModeStartupActivity");
ExtensionPointName<StartupActivity.Background> BACKGROUND_POST_STARTUP_ACTIVITY = new ExtensionPointName<>("com.intellij.backgroundPostStartupActivity");
void runActivity(@NotNull Project project);
@@ -1,7 +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.startup;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
@@ -18,7 +17,7 @@ public abstract class StartupManager {
* @return the startup manager instance.
*/
public static StartupManager getInstance(Project project) {
return ServiceManager.getService(project, StartupManager.class);
return project.getService(StartupManager.class);
}
/**
@@ -827,9 +827,7 @@ open class RunManagerImpl @JvmOverloads constructor(val project: Project, shared
if (selectedConfiguration == null) {
selectedConfiguration = allSettings.firstOrNull { it.type.isManaged }
}
},
ModalityState.NON_MODAL,
project.disposed)
}, ModalityState.NON_MODAL, project.disposed)
}
}
}
@@ -1,23 +1,11 @@
/*
* Copyright 2000-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 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.module.impl;
import com.intellij.CommonBundle;
import com.intellij.notification.*;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.module.ConfigurationErrorDescription;
import com.intellij.openapi.module.ConfigurationErrorType;
import com.intellij.openapi.module.ProjectLoadingErrorsNotifier;
@@ -33,7 +21,9 @@ import javax.swing.event.HyperlinkEvent;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
// overridden in Rider
public class ProjectLoadingErrorsNotifierImpl extends ProjectLoadingErrorsNotifier {
private final MultiMap<ConfigurationErrorType, ConfigurationErrorDescription> myErrors = new MultiMap<>();
private final Object myLock = new Object();
@@ -50,7 +40,9 @@ public class ProjectLoadingErrorsNotifierImpl extends ProjectLoadingErrorsNotifi
@Override
public void registerErrors(@NotNull Collection<? extends ConfigurationErrorDescription> errorDescriptions) {
if (myProject.isDisposed() || myProject.isDefault() || errorDescriptions.isEmpty()) return;
if (myProject.isDisposed() || myProject.isDefault() || errorDescriptions.isEmpty()) {
return;
}
boolean first;
synchronized (myLock) {
@@ -63,49 +55,48 @@ public class ProjectLoadingErrorsNotifierImpl extends ProjectLoadingErrorsNotifi
fireNotifications();
}
else if (first) {
StartupManager.getInstance(myProject).registerPostStartupActivity(() -> fireNotifications());
StartupManager.getInstance(myProject).registerPostStartupDumbAwareActivity(() -> fireNotifications());
}
}
private void fireNotifications() {
final MultiMap<ConfigurationErrorType, ConfigurationErrorDescription> descriptionsMap = new MultiMap<>();
Map<ConfigurationErrorType, Collection<ConfigurationErrorDescription>> descriptionMap;
synchronized (myLock) {
if (myErrors.isEmpty()) return;
descriptionsMap.putAllValues(myErrors);
if (myErrors.isEmpty()) {
return;
}
descriptionMap = myErrors.toHashMap();
myErrors.clear();
}
for (final ConfigurationErrorType type : descriptionsMap.keySet()) {
final Collection<ConfigurationErrorDescription> descriptions = descriptionsMap.get(type);
if (descriptions.isEmpty()) continue;
for (Map.Entry<ConfigurationErrorType, Collection<ConfigurationErrorDescription>> entry : descriptionMap.entrySet()) {
Collection<ConfigurationErrorDescription> descriptions = entry.getValue();
if (descriptions.isEmpty()) {
continue;
}
final String invalidElements = getInvalidElementsString(type, descriptions);
final String errorText = ProjectBundle.message("error.message.configuration.cannot.load", invalidElements);
Notifications.Bus.notify(new Notification(NotificationGroup.createIdWithTitle("Project Loading Error", ProjectBundle.message("notification.group.project.loading.error")),
ProjectBundle.message("notification.title.error.loading.project"), errorText, NotificationType.ERROR,
new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification,
@NotNull HyperlinkEvent event) {
final List<ConfigurationErrorDescription> validDescriptions =
ContainerUtil.findAll(descriptions, errorDescription -> errorDescription.isValid());
if (RemoveInvalidElementsDialog.showDialog(myProject, CommonBundle.getErrorTitle(), type,
invalidElements, validDescriptions)) {
notification.expire();
}
}
}), myProject);
ConfigurationErrorType type = entry.getKey();
String invalidElements = getInvalidElementsString(type, descriptions);
String errorText = ProjectBundle.message("error.message.configuration.cannot.load", invalidElements);
new Notification(
NotificationGroup.createIdWithTitle("Project Loading Error", ProjectBundle.message("notification.group.project.loading.error")),
ProjectBundle.message("notification.title.error.loading.project"), errorText, NotificationType.ERROR,
new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
List<ConfigurationErrorDescription> validDescriptions = ContainerUtil.findAll(descriptions, ConfigurationErrorDescription::isValid);
if (RemoveInvalidElementsDialog.showDialog(myProject, CommonBundle.getErrorTitle(), type, invalidElements, validDescriptions)) {
notification.expire();
}
}
}).notify(myProject);
}
}
private static String getInvalidElementsString(ConfigurationErrorType type, Collection<ConfigurationErrorDescription> descriptions) {
if (descriptions.size() == 1) {
final ConfigurationErrorDescription description = ContainerUtil.getFirstItem(descriptions);
return type.getElementKind() + " " + description.getElementName();
return type.getElementKind() + " " + ContainerUtil.getFirstItem(descriptions).getElementName();
}
return descriptions.size() + " " + StringUtil.pluralize(type.getElementKind());
}
}
@@ -1,6 +1,7 @@
// Copyright 2000-2019 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.
// 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.ide;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.SystemIndependent;
@@ -47,7 +48,7 @@ public final class ProjectGroup {
public void addProject(@SystemIndependent String path) {
List<String> projects = new ArrayList<>(StringUtil.split(myProjectPaths, File.pathSeparator));
projects.add(path);
projects.add(FileUtilRt.toSystemIndependentName(path));
save(projects);
}
@@ -71,7 +72,7 @@ public final class ProjectGroup {
}
private void save(@NotNull List<String> projects) {
myProjectPaths = StringUtil.join(projects, File.pathSeparator);
myProjectPaths = String.join(File.pathSeparator, projects);
}
@NotNull
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2011 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 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.fileTypes;
import com.intellij.ide.highlighter.ModuleFileType;
@@ -25,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
*/
@SuppressWarnings("StaticNonFinalField")
@Deprecated
public class StdFileTypes extends FileTypes {
public final class StdFileTypes extends FileTypes {
private StdFileTypes() { }
/**
@@ -21,7 +21,8 @@ data class OpenProjectTask(@JvmField val forceOpenInNewFrame: Boolean = false,
val frame: FrameInfo? = null,
val projectWorkspaceId: String? = null,
val line: Int = -1,
val column: Int = -1) {
val column: Int = -1,
val runConversionsBeforeOpen: Boolean = true) {
constructor(project: Project) : this(false, project = project)
constructor(forceOpenInNewFrame: Boolean = false, projectToClose: Project?) : this(forceOpenInNewFrame = forceOpenInNewFrame, projectToClose = projectToClose, useDefaultProjectAsTemplate = true)
@@ -39,7 +40,4 @@ data class OpenProjectTask(@JvmField val forceOpenInNewFrame: Boolean = false,
@JvmField
var isRefreshVfsNeeded = true
@JvmField
var runConversionsBeforeOpen = true
}
@@ -1,17 +0,0 @@
// 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.ide.startup;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal
public interface ProjectLoadListener {
@Topic.AppLevel
Topic<ProjectLoadListener> TOPIC = new Topic<>(ProjectLoadListener.class, Topic.BroadcastDirection.NONE);
default void postStartUpActivitiesPassed() {
}
default void dumbUnawarePostStartUpActivitiesPassed() {
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.
// 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.ide.startup;
import com.intellij.openapi.progress.ProcessCanceledException;
@@ -7,5 +7,5 @@ import com.intellij.openapi.progress.ProcessCanceledException;
* If thrown during startup process, indicates that a given service (e.g. index) isn't yet available,
* and the query should be re-attempted later.
*/
public class ServiceNotReadyException extends ProcessCanceledException {
public final class ServiceNotReadyException extends ProcessCanceledException {
}
@@ -1,15 +1,12 @@
// 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.ide.startup.impl;
import com.intellij.diagnostic.Activity;
import com.intellij.diagnostic.ActivityCategory;
import com.intellij.diagnostic.PerformanceWatcher;
import com.intellij.diagnostic.StartUpMeasurer;
import com.intellij.codeWithMe.ClientId;
import com.intellij.diagnostic.*;
import com.intellij.diagnostic.StartUpMeasurer.Activities;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.plugins.cl.PluginClassLoader;
import com.intellij.ide.startup.ProjectLoadListener;
import com.intellij.ide.startup.ServiceNotReadyException;
import com.intellij.ide.startup.StartupManagerEx;
import com.intellij.openapi.application.Application;
@@ -35,13 +32,13 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.GuiUtils;
import com.intellij.util.concurrency.AppExecutorUtil;
import com.intellij.codeWithMe.ClientId;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.util.*;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -123,36 +120,28 @@ public class StartupManagerImpl extends StartupManagerEx {
return postStartupActivitiesPassed;
}
public final void projectOpened(@Nullable ProgressIndicator indicator) {
public final @NotNull Future<?> projectOpened(@Nullable ProgressIndicator indicator) {
if (indicator != null && ApplicationManager.getApplication().isInternal()) {
indicator.setText(IdeBundle.message("startup.indicator.text.running.startup.activities"));
}
doRunStartUpActivities(indicator);
// If called in EDT - client expect that work will be done after call, executing in a pooled thread maybe not expected.
// In test mode project opened not under progress, so, execute directly in current thread.
Application app = ApplicationManager.getApplication();
if (app.isUnitTestMode() || app.isDispatchThread()) {
runPostStartupActivities();
if (indicator != null) {
indicator.checkCanceled();
}
else {
if (indicator != null) {
indicator.checkCanceled();
Future<?> future = AppExecutorUtil.getAppExecutorService().submit(() -> {
if (myProject.isDisposed()) {
return;
}
app.executeOnPooledThread(() -> {
if (myProject.isDisposed()) {
return;
}
BackgroundTaskUtil.runUnderDisposeAwareIndicator(myProject, this::runPostStartupActivities);
});
BackgroundTaskUtil.runUnderDisposeAwareIndicator(myProject, () -> {
runPostStartupActivities();
ApplicationManager.getApplication().getMessageBus().syncPublisher(ProjectLoadListener.TOPIC).postStartUpActivitiesPassed();
});
});
}
LoadingState phase = DumbService.isDumb(myProject) ? LoadingState.PROJECT_OPENED : LoadingState.INDEXING_FINISHED;
StartUpMeasurer.compareAndSetCurrentState(LoadingState.COMPONENTS_LOADED, phase);
return future;
}
private void doRunStartUpActivities(@Nullable ProgressIndicator indicator) {
@@ -203,7 +192,7 @@ public class StartupManagerImpl extends StartupManagerEx {
}
// Must be executed in a pooled thread outside of project loading modal task. The only exclusion - test mode.
public final void runPostStartupActivities() {
private void runPostStartupActivities() {
LOG.assertTrue(myStartupActivitiesPassed);
PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot();
@@ -214,7 +203,6 @@ public class StartupManagerImpl extends StartupManagerEx {
AtomicReference<Activity> edtActivity = new AtomicReference<>();
AtomicBoolean uiFreezeWarned = new AtomicBoolean();
AtomicBoolean eventAboutDumbUnawareActivities = new AtomicBoolean();
AtomicInteger counter = new AtomicInteger();
DumbService dumbService = DumbService.getInstance(myProject);
@@ -235,11 +223,11 @@ public class StartupManagerImpl extends StartupManagerEx {
counter.incrementAndGet();
runDumbUnawareActivity(dumbService, () -> {
runActivity(uiFreezeWarned, extension, pluginDescriptor, ProgressIndicatorProvider.getGlobalProgressIndicator());
dumbUnawarePostActivitiesPassed(edtActivity, eventAboutDumbUnawareActivities, counter.decrementAndGet());
dumbUnawarePostActivitiesPassed(edtActivity, counter.decrementAndGet());
});
});
dumbUnawarePostActivitiesPassed(edtActivity, eventAboutDumbUnawareActivities, counter.get());
dumbUnawarePostActivitiesPassed(edtActivity, counter.get());
if (myProject.isDisposed()) {
return;
@@ -266,9 +254,7 @@ public class StartupManagerImpl extends StartupManagerEx {
runDumbUnawarePostStartupActivitiesRegisteredDynamically();
}
private static void dumbUnawarePostActivitiesPassed(@NotNull AtomicReference<Activity> edtActivity,
@NotNull AtomicBoolean eventAboutDumbUnawareActivities,
int count) {
private static void dumbUnawarePostActivitiesPassed(@NotNull AtomicReference<Activity> edtActivity, int count) {
if (count != 0) {
return;
}
@@ -277,11 +263,6 @@ public class StartupManagerImpl extends StartupManagerEx {
if (activity != null) {
activity.end();
}
if (eventAboutDumbUnawareActivities.compareAndSet(false, true)) {
ApplicationManager.getApplication().getMessageBus().syncPublisher(ProjectLoadListener.TOPIC)
.dumbUnawarePostStartUpActivitiesPassed();
}
}
private void runActivity(@Nullable AtomicBoolean uiFreezeWarned, @NotNull StartupActivity extension, @NotNull PluginDescriptor pluginDescriptor, @Nullable ProgressIndicator indicator) {
@@ -338,8 +319,8 @@ public class StartupManagerImpl extends StartupManagerEx {
runDumbUnawareActivity(dumbService, new Runnable() {
@Override
public void run() {
// todo should it be moved out of EDT? Not clear, do we really have a lot of such activities
// myDumbAwarePostStartupActivities might be non-empty if new activities were registered during dumb mode
// todo should it be moved out of EDT? Not clear, do we really have a lot of such activities
runActivities(myDumbAwarePostStartupActivities, null, Activities.PROJECT_DUMB_POST_STARTUP);
while (true) {
@@ -16,6 +16,7 @@ import com.intellij.openapi.application.impl.ApplicationImpl;
import com.intellij.openapi.diagnostic.Attachment;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -24,7 +25,6 @@ import com.intellij.openapi.progress.Task;
import com.intellij.openapi.progress.impl.ProgressManagerImpl;
import com.intellij.openapi.progress.impl.ProgressSuspender;
import com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase;
import com.intellij.openapi.progress.util.ProgressIndicatorBase;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.MessageType;
@@ -55,6 +55,9 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport;
public class DumbServiceImpl extends DumbService implements Disposable, ModificationTracker, DumbServiceBalloon.Service {
private static final ExtensionPointName<StartupActivity.RequiredForSmartMode> REQUIRED_FOR_SMART_MODE_STARTUP_ACTIVITY
= new ExtensionPointName<>("com.intellij.requiredForSmartModeStartupActivity");
private static final Logger LOG = Logger.getInstance(DumbServiceImpl.class);
private static final FrequentErrorLogger ourErrorLogger = FrequentErrorLogger.newInstance(LOG);
private final AtomicReference<State> myState;
@@ -98,13 +101,11 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica
State.RUNNING_PROJECT_SMART_MODE_STARTUP_TASKS),
"actual state: " + myState.get() + ", project " + getProject());
List<StartupActivity.RequiredForSmartMode> activities = StartupActivity
.REQUIRED_FOR_SMART_MODE_STARTUP_ACTIVITY
.getExtensionList();
List<StartupActivity.RequiredForSmartMode> activities = REQUIRED_FOR_SMART_MODE_STARTUP_ACTIVITY.getExtensionList();
if (activities.isEmpty()) {
myState.set(State.SMART);
} else {
}
else {
for (StartupActivity.RequiredForSmartMode activity : activities) {
activity.runActivity(getProject());
}
@@ -4,7 +4,7 @@ package com.intellij.openapi.project;
import com.intellij.openapi.startup.StartupActivity;
import org.jetbrains.annotations.NotNull;
public class DumbServiceStartupActivity implements StartupActivity {
final class DumbServiceStartupActivity implements StartupActivity {
@Override
public void runActivity(@NotNull Project project) {
DumbServiceImpl dumbService = (DumbServiceImpl)DumbService.getInstance(project);
@@ -1,13 +1,10 @@
// 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.project.ex;
import com.intellij.configurationStore.StoreReloadManager;
import com.intellij.ide.impl.OpenProjectTask;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -15,7 +12,7 @@ import org.jetbrains.annotations.TestOnly;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.List;
public abstract class ProjectManagerEx extends ProjectManager {
public static ProjectManagerEx getInstanceEx() {
@@ -33,17 +30,6 @@ public abstract class ProjectManagerEx extends ProjectManager {
@Nullable
public abstract Project newProject(@Nullable String projectName, @NotNull String filePath, boolean useDefaultProjectSettings, boolean isDummy);
@TestOnly
@NotNull
public final Project newProjectForTest(@NotNull Path file, @NotNull Disposable parentDisposable) {
OpenProjectTask options = new OpenProjectTask();
options.useDefaultProjectAsTemplate = false;
options.isNewProject = true;
Project project = Objects.requireNonNull(newProject(file, null, options));
Disposer.register(parentDisposable, () -> forceCloseProject(project));
return project;
}
@Nullable
public abstract Project newProject(@NotNull Path file, @Nullable String projectName, @NotNull OpenProjectTask options);
@@ -53,16 +39,11 @@ public abstract class ProjectManagerEx extends ProjectManager {
@NotNull
@Deprecated
public final Project loadProject(@NotNull String filePath) {
return loadProject(Paths.get(filePath).toAbsolutePath(), null);
return loadProject(Paths.get(filePath).toAbsolutePath());
}
@NotNull
public final Project loadProject(@NotNull Path path) {
return loadProject(path, null);
}
@NotNull
public abstract Project loadProject(@NotNull Path file, @Nullable String projectName);
public abstract Project loadProject(@NotNull Path path);
public abstract boolean openProject(@NotNull Project project);
@@ -73,27 +54,6 @@ public abstract class ProjectManagerEx extends ProjectManager {
public abstract boolean canClose(@NotNull Project project);
/**
* @deprecated Use {@link StoreReloadManager#blockReloadingProjectOnExternalChanges()}
*/
@SuppressWarnings("MethodMayBeStatic")
@Deprecated
public final void blockReloadingProjectOnExternalChanges() {
StoreReloadManager.getInstance().blockReloadingProjectOnExternalChanges();
}
/**
* @deprecated Use {@link StoreReloadManager#blockReloadingProjectOnExternalChanges()}
*/
@SuppressWarnings("MethodMayBeStatic")
@Deprecated
public final void unblockReloadingProjectOnExternalChanges() {
StoreReloadManager.getInstance().unblockReloadingProjectOnExternalChanges();
}
@TestOnly
public abstract void openTestProject(@NotNull Project project);
/**
* The project and the app settings will be not saved.
*/
@@ -118,5 +78,5 @@ public abstract class ProjectManagerEx extends ProjectManager {
public abstract Project findOpenProjectByHash(@Nullable String locationHash);
@ApiStatus.Internal
public abstract String @NotNull [] getAllExcludedUrls();
public abstract @NotNull List<String> getAllExcludedUrls();
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.project.impl;
import com.intellij.openapi.application.ReadAction;
@@ -10,19 +10,16 @@ import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBusConnection;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Collection;
import java.util.*;
// provides list of all excluded folders across all opened projects, fast.
final class ExcludeRootsCache {
private volatile CachedUrls myCache;
private static class CachedUrls {
private final static class CachedUrls {
private final long myModificationCount;
private final String @NotNull [] myUrls;
@@ -46,7 +43,7 @@ final class ExcludeRootsCache {
});
}
String @NotNull [] getExcludedUrls() {
final @NotNull List<String> getExcludedUrls() {
return ReadAction.compute(() -> {
CachedUrls cache = myCache;
long actualModCount = Arrays.stream(ProjectManager.getInstance().getOpenProjects())
@@ -58,18 +55,17 @@ final class ExcludeRootsCache {
urls = cache.myUrls;
}
else {
Collection<String> excludedUrls = new THashSet<>();
Collection<String> excludedUrls = new HashSet<>();
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
for (Module module : ModuleManager.getInstance(project).getModules()) {
urls = ModuleRootManager.getInstance(module).getExcludeRootUrls();
ContainerUtil.addAll(excludedUrls, urls);
Collections.addAll(excludedUrls, ModuleRootManager.getInstance(module).getExcludeRootUrls());
}
}
urls = ArrayUtilRt.toStringArray(excludedUrls);
Arrays.sort(urls);
myCache = new CachedUrls(actualModCount, urls);
}
return urls;
return Arrays.asList(urls);
});
}
}
@@ -3,11 +3,8 @@ package com.intellij.openapi.project.impl;
import com.intellij.configurationStore.StoreReloadManager;
import com.intellij.conversion.CannotConvertException;
import com.intellij.conversion.ConversionResult;
import com.intellij.conversion.ConversionService;
import com.intellij.diagnostic.Activity;
import com.intellij.diagnostic.ActivityCategory;
import com.intellij.diagnostic.LoadingState;
import com.intellij.diagnostic.StartUpMeasurer;
import com.intellij.featureStatistics.fusCollectors.LifecycleUsageTriggerCollector;
import com.intellij.ide.AppLifecycleListener;
@@ -32,7 +29,6 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.*;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.startup.StartupManager;
@@ -46,6 +42,7 @@ import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.impl.ZipHandler;
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame;
import com.intellij.platform.PlatformProjectOpenProcessor;
import com.intellij.serviceContainer.ContainerUtilKt;
import com.intellij.ui.AppUIUtil;
import com.intellij.ui.GuiUtils;
@@ -55,7 +52,6 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.UnsafeWeakList;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ref.GCUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.*;
import java.awt.*;
@@ -67,6 +63,7 @@ import java.nio.file.Paths;
import java.util.List;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@@ -338,14 +335,14 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
}
@Override
public @NotNull Project loadProject(@NotNull Path file, @Nullable String projectName) {
public @NotNull Project loadProject(@NotNull Path file) {
//noinspection TestOnlyProblems
return loadProject(file, projectName, null);
return loadProject(file, null);
}
@TestOnly
public static Project loadProject(@NotNull Path file, @Nullable String projectName, @Nullable Consumer<Project> beforeInit) {
ProjectImpl project = doCreateProject(projectName, file);
public static Project loadProject(@NotNull Path file, @Nullable Consumer<Project> beforeInit) {
ProjectImpl project = doCreateProject(null, file);
if (beforeInit != null) {
beforeInit.accept(project);
}
@@ -417,15 +414,17 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
return false;
}
if (!ApplicationManager.getApplication().isUnitTestMode() && ApplicationManager.getApplication().isDispatchThread()) {
Application app = ApplicationManager.getApplication();
if (!app.isUnitTestMode() && app.isDispatchThread()) {
LOG.warn("Consider to load project under progress");
}
try {
doLoadProject(project, ProgressManager.getInstance().getProgressIndicator());
Future<?> future = doLoadProject(project, ProgressManager.getInstance().getProgressIndicator());
ProjectLoaderKt.waitInTestMode(future);
}
catch (ProcessCanceledException e) {
ApplicationManager.getApplication().invokeAndWait(() -> {
app.invokeAndWait(() -> {
closeProject(project, /* saveProject = */ false, /* dispose = */ true, /* checkCanClose = */ false);
});
notifyProjectOpenFailed();
@@ -434,7 +433,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
return true;
}
private static void doLoadProject(@NotNull Project project, @Nullable ProgressIndicator indicator) {
private static @NotNull Future<?> doLoadProject(@NotNull Project project, @Nullable ProgressIndicator indicator) {
Activity waitEdtActivity = StartUpMeasurer.startMainActivity("placing calling projectOpened on event queue");
if (indicator != null) {
//noinspection HardCodedStringLiteral
@@ -451,12 +450,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
fireProjectOpened(project);
});
((StartupManagerImpl)StartupManager.getInstance(project)).projectOpened(indicator);
GuiUtils.invokeLaterIfNeeded(() -> {
LoadingState phase = DumbService.isDumb(project) ? LoadingState.PROJECT_OPENED : LoadingState.INDEXING_FINISHED;
StartUpMeasurer.compareAndSetCurrentState(LoadingState.COMPONENTS_LOADED, phase);
}, ModalityState.NON_MODAL, project.getDisposed());
return ((StartupManagerImpl)StartupManager.getInstance(project)).projectOpened(indicator);
}
private boolean addToOpened(@NotNull Project project) {
@@ -493,65 +487,9 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
}
@Override
public Project loadAndOpenProject(@NotNull String originalFilePath) {
return loadAndOpenProject(Paths.get(FileUtilRt.toSystemIndependentName(toCanonicalName(originalFilePath))));
}
@Override
public @Nullable Project loadAndOpenProject(@NotNull Path file) {
ConversionResult conversionResult;
try {
conversionResult = ConversionService.getInstance().convert(file);
}
catch (CannotConvertException e) {
conversionResult = null;
LOG.info(e);
showCannotConvertMessage(e, null);
}
ProjectImpl project;
if (conversionResult == null || conversionResult.openingIsCanceled()) {
project = null;
}
else {
project = doCreateProject(null, file);
ConversionResult finalConversionResult = conversionResult;
ProgressManager.getInstance().run(new Task.Modal(project, IdeUICustomization.getInstance().projectMessage("progress.title.loading.project"), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
initProject(file, project, /* isRefreshVfsNeeded = */ true, null, indicator);
}
catch (ProcessCanceledException e) {
return;
}
catch (Throwable e) {
LOG.error(e);
return;
}
if (!finalConversionResult.conversionNotNeeded()) {
StartupManager.getInstance(project).registerPostStartupActivity(() -> finalConversionResult.postStartupActivity(project));
}
openProject(project);
}
});
}
if (project == null) {
WelcomeFrame.showIfNoProjectOpened();
return null;
}
if (!project.isOpen()) {
WelcomeFrame.showIfNoProjectOpened();
ApplicationManager.getApplication().runWriteAction(() -> {
if (!project.isDisposed()) {
Disposer.dispose(project);
}
});
}
return project;
public final Project loadAndOpenProject(@NotNull String originalFilePath) {
Path file = Paths.get(FileUtilRt.toSystemIndependentName(toCanonicalName(originalFilePath)));
return PlatformProjectOpenProcessor.openExistingProject(file, file, new OpenProjectTask());
}
public static void showCannotConvertMessage(@NotNull CannotConvertException e, @Nullable Component component) {
@@ -569,14 +507,6 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
}
}
@Override
@TestOnly
public void openTestProject(final @NotNull Project project) {
assert ApplicationManager.getApplication().isUnitTestMode();
openProject(project);
UIUtil.dispatchAllInvocationEvents(); // post init activities are invokeLatered
}
@Override
public void reloadProject(@NotNull Project project) {
StoreReloadManager.getInstance().reloadProject(project);
@@ -934,7 +864,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
}
@Override
public String @NotNull [] getAllExcludedUrls() {
public @NotNull List<String> getAllExcludedUrls() {
return myExcludeRootsCache.getExcludedUrls();
}
}
@@ -12,9 +12,12 @@ import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.extensions.impl.ExtensionPointImpl
import com.intellij.openapi.extensions.impl.ExtensionsAreaImpl
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.progress.runModalTask
import com.intellij.openapi.project.impl.ProjectImpl
import com.intellij.openapi.project.impl.ProjectLifecycleListener
import org.jetbrains.annotations.ApiStatus
import java.util.concurrent.ExecutionException
import java.util.concurrent.Future
// Code maybe located in a ProjectImpl, but it is not possible due to non-technical reasons to convert ProjectImpl into modern language.
// Wrap into class as it is not possible to use internal modifier for top-level functions from Java (but we have to reduce scope).
@@ -106,4 +109,30 @@ interface ProjectServiceContainerInitializedListener {
* but before components are instantiated.
*/
fun serviceCreated(project: Project)
}
internal fun waitInTestMode(future: Future<*>) {
val app = ApplicationManager.getApplication()
if (!app.isUnitTestMode) {
return
}
fun wait() {
try {
future.get()
}
catch (e: ExecutionException) {
throw e.cause ?: e
}
}
if (app.isDispatchThread) {
// process event queue during waiting
runModalTask("") {
wait()
}
}
else {
wait()
}
}
@@ -15,33 +15,22 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.newvfs.ChildInfoImpl;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.openapi.vfs.newvfs.events.ChildInfo;
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent;
import com.intellij.util.ArrayUtil;
import com.intellij.openapi.vfs.newvfs.events.*;
import com.intellij.util.SmartList;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class VfsEventGenerationHelper {
final class VfsEventGenerationHelper {
static final Logger LOG = Logger.getInstance(RefreshWorker.class);
private final List<VFileEvent> myEvents = new ArrayList<>();
@@ -54,7 +43,9 @@ class VfsEventGenerationHelper {
static boolean checkDirty(@NotNull NewVirtualFile file) {
boolean fileDirty = file.isDirty();
if (LOG.isTraceEnabled()) LOG.trace("file=" + file + " dirty=" + fileDirty);
if (LOG.isTraceEnabled()) {
LOG.trace("file=" + file + " dirty=" + fileDirty);
}
return fileDirty;
}
@@ -73,17 +64,18 @@ class VfsEventGenerationHelper {
@NotNull FileAttributes attributes,
@Nullable String symlinkTarget,
@NotNull ThrowableRunnable<RefreshWorker.RefreshCancelledException> checkCanceled) throws RefreshWorker.RefreshCancelledException {
if (LOG.isTraceEnabled()) LOG.trace("create parent=" + parent + " name=" + childName + " attr=" + attributes);
if (LOG.isTraceEnabled()) {
LOG.trace("create parent=" + parent + " name=" + childName + " attr=" + attributes);
}
ChildInfo[] children = null;
if (attributes.isDirectory() && parent.getFileSystem() instanceof LocalFileSystem && !attributes.isSymLink()) {
try {
Path child = Paths.get(parent.getPath(), childName);
if (shouldScanDirectory(parent, child, childName)) {
Path[] relevantExcluded = ContainerUtil.mapNotNull(ProjectManagerEx.getInstanceEx().getAllExcludedUrls(),
url -> {
Path path = Paths.get(VirtualFileManager.extractPath(url));
return path.startsWith(child) ? path : null;
}, new Path[0]);
List<Path> relevantExcluded = ContainerUtil.mapNotNull(ProjectManagerEx.getInstanceEx().getAllExcludedUrls(), url -> {
Path path = Paths.get(VirtualFileManager.extractPath(url));
return path.startsWith(child) ? path : null;
});
children = scanChildren(child, relevantExcluded, checkCanceled);
}
}
@@ -123,7 +115,7 @@ class VfsEventGenerationHelper {
// scan all children of "root" (except excluded dirs) recursively and return them in the ChildInfo[] array
// null means error during scan
private static ChildInfo @Nullable [] scanChildren(@NotNull Path root,
Path @NotNull [] excluded,
@NotNull List<Path> excluded,
@NotNull ThrowableRunnable<RefreshWorker.RefreshCancelledException> checkCanceled)
throws RefreshWorker.RefreshCancelledException {
// top of the stack contains list of children found so far in the current directory
@@ -138,7 +130,7 @@ class VfsEventGenerationHelper {
visitFile(dir, attrs);
}
// on average, this "excluded" array is very small for any particular root, so linear search it is.
if (ArrayUtil.contains(dir, excluded)) {
if (excluded.contains(dir)) {
// do not drill inside excluded root (just record its attributes nevertheless), even if we have content roots beneath
// stop optimization right here - it's too much pain to track all these nested content/excluded/content otherwise
return FileVisitResult.SKIP_SUBTREE;
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 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.wm.impl.welcomeScreen;
import com.intellij.ide.ProjectGroup;
@@ -22,12 +8,10 @@ import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author Konstantin Bulenkov
*/
public class MoveProjectToGroupAction extends RecentProjectsWelcomeScreenActionBase {
public final class MoveProjectToGroupAction extends RecentProjectsWelcomeScreenActionBase {
private final ProjectGroup myGroup;
public MoveProjectToGroupAction(ProjectGroup group) {
@@ -37,14 +21,15 @@ public class MoveProjectToGroupAction extends RecentProjectsWelcomeScreenActionB
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final List<AnAction> elements = getSelectedElements(e);
for (AnAction element : elements) {
if (element instanceof ReopenProjectAction) {
final String path = ((ReopenProjectAction)element).getProjectPath();
for (ProjectGroup group : RecentProjectsManager.getInstance().getGroups()) {
group.removeProject(path);
myGroup.addProject(path);
}
for (AnAction element : getSelectedElements(e)) {
if (!(element instanceof ReopenProjectAction)) {
continue;
}
String path = ((ReopenProjectAction)element).getProjectPath();
for (ProjectGroup group : RecentProjectsManager.getInstance().getGroups()) {
group.removeProject(path);
myGroup.addProject(path);
}
}
rebuildRecentProjectsList(e);
@@ -16,15 +16,17 @@ import java.util.List;
/**
* @author Konstantin Bulenkov
*/
public class MoveProjectToGroupActionGroup extends DefaultActionGroup implements DumbAware {
final class MoveProjectToGroupActionGroup extends DefaultActionGroup implements DumbAware {
@Override
public void update(@NotNull AnActionEvent e) {
removeAll();
final List<ProjectGroup> groups = new ArrayList<>(RecentProjectsManager.getInstance().getGroups());
List<ProjectGroup> groups = new ArrayList<>(RecentProjectsManager.getInstance().getGroups());
groups.sort((o1, o2) -> StringUtil.naturalCompare(o1.getName(), o2.getName()));
for (ProjectGroup group : groups) {
if(!group.isTutorials())
add(new MoveProjectToGroupAction(group));
if (group.isTutorials()) {
continue;
}
add(new MoveProjectToGroupAction(group));
}
if (groups.size() > 0) {
add(Separator.getInstance());
@@ -21,7 +21,6 @@ import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.fileEditor.OpenFileDescriptor
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ex.ProjectManagerEx
@@ -405,13 +404,7 @@ private fun convertAndLoadProject(path: Path, options: OpenProjectTask): Project
}
val project = ProjectManagerImpl.doCreateProject(options.projectName, path)
try {
ProjectManagerImpl.initProject(path, project, /* isRefreshVfsNeeded = */ true, null, ProgressManager.getInstance().progressIndicator)
}
catch (e: ProcessCanceledException) {
return null
}
ProjectManagerImpl.initProject(path, project, /* isRefreshVfsNeeded = */ true, null, ProgressManager.getInstance().progressIndicator)
if (conversionResult != null && !conversionResult.conversionNotNeeded()) {
StartupManager.getInstance(project).registerPostStartupActivity {
conversionResult.postStartupActivity(project)
@@ -165,4 +165,5 @@ FindBugs-IDEA 1.0.1 1.0.0 0.9.999 0.9.998 0.9.997 0.9.996 0.9.995 0.9.994 0.9.99
CodeHistoryMining "0.1 beta" "0.1.1 beta" "0.1.2 beta" "0.1.3 beta" "0.1.4 beta" "0.1.5 beta" "0.1.7 beta" "0.1.9 beta" "0.2.1 beta" "0.2.2 beta" "0.2.3 beta" "0.2.4 beta" "0.2.8 beta" "0.2.9 beta" "0.3.0 beta" "0.3.1 beta"
ru.crazycoder.plugins.tabdir 1.6.6 1.6.1 1.6
com.jetbrains.php.composer.resolve 1.0
"ev3dev C/C++" "0.7.2 (51324)"
"ev3dev C/C++" "0.7.2 (51324)"
javaFMI 1.0.0
@@ -0,0 +1,66 @@
// 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.ide
import com.intellij.ide.startup.impl.StartupManagerImpl
import com.intellij.openapi.project.DumbAwareRunnable
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.DumbServiceImpl
import com.intellij.openapi.project.ex.ProjectManagerEx
import com.intellij.testFramework.ApplicationRule
import com.intellij.testFramework.PlatformTestUtil
import com.intellij.testFramework.assertions.Assertions.assertThat
import com.intellij.testFramework.createHeavyProject
import com.intellij.testFramework.rules.InMemoryFsRule
import com.intellij.testFramework.runInEdtAndWait
import org.junit.ClassRule
import org.junit.Rule
import org.junit.Test
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
@Suppress("UsePropertyAccessSyntax")
class StartupManagerTest {
companion object {
@JvmField
@ClassRule
val appRule = ApplicationRule()
}
@JvmField
@Rule
val fsRule = InMemoryFsRule()
@Test(timeout = 5_000)
//@Test()
fun runAfterOpenedMustBeDumbAware() {
val project = createHeavyProject(fsRule.fs.getPath("/"))
try {
val startupManager = StartupManagerImpl.getInstance(project) as StartupManagerImpl
assertThat(startupManager.postStartupActivityPassed()).isFalse()
val dumbService = DumbService.getInstance(project) as DumbServiceImpl
startupManager.registerPostStartupActivity(DumbAwareRunnable {
runInEdtAndWait {
dumbService.isDumb = true
}
assertThat(dumbService.isDumb).isTrue()
})
assertThat(startupManager.postStartupActivityPassed()).isFalse()
ProjectManagerEx.getInstanceEx().openProject(project)
val done = CountDownLatch(1)
startupManager.runAfterOpened {
assertThat(dumbService.isDumb).isTrue()
done.countDown()
}
done.await(1, TimeUnit.SECONDS)
}
finally {
runInEdtAndWait {
PlatformTestUtil.forceCloseProjectWithoutSaving(project)
}
}
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.ide.fileTemplates.impl;
import com.intellij.diagnostic.PluginException;
@@ -121,7 +121,7 @@ public class LightFileTemplatesTest extends LightPlatformTestCase {
PlatformTestUtil.saveProject(project, true);
closeProject(project);
reloaded = ProjectManager.getInstance().loadAndOpenProject(foo);
reloaded = PlatformTestUtil.loadAndOpenProject(foo.toPath());
assertNotNull(reloaded);
manager = FileTemplateManager.getInstance(reloaded);
assertThat(manager.getCurrentScheme()).isEqualTo(manager.getProjectScheme());
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.components.impl;
import com.intellij.openapi.Disposable;
@@ -9,7 +9,6 @@ import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleTypeId;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectEx;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.util.Disposer;
import com.intellij.testFramework.HeavyPlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
@@ -30,7 +29,7 @@ public class OverwriteProjectConfigurationTest extends HeavyPlatformTestCase {
public void testOverwriteModulesList() {
Disposable disposable = Disposer.newDisposable();
Project project = ProjectManagerEx.getInstanceEx().newProjectForTest(myProjectDir, disposable);
Project project = PlatformTestUtil.createProject(myProjectDir, disposable);
try {
createModule(project, "module", ModuleTypeId.JAVA_MODULE);
PlatformTestUtil.saveProject(project);
@@ -39,14 +38,14 @@ public class OverwriteProjectConfigurationTest extends HeavyPlatformTestCase {
Disposer.dispose(disposable);
}
Project recreated = ProjectManagerEx.getInstanceEx().newProjectForTest(myProjectDir, ((ProjectEx)myProject).getEarlyDisposable());
Project recreated = PlatformTestUtil.createProject(myProjectDir, ((ProjectEx)myProject).getEarlyDisposable());
PlatformTestUtil.saveProject(recreated);
assertThat(ModuleManager.getInstance(recreated).getModules()).isEmpty();
}
public void testOverwriteModuleType() {
Disposable disposable = Disposer.newDisposable();
Project project = ProjectManagerEx.getInstanceEx().newProjectForTest(myProjectDir, disposable);
Project project = PlatformTestUtil.createProject(myProjectDir, disposable);
try {
Path imlFile = createModule(project, "module", ModuleTypeId.JAVA_MODULE);
PlatformTestUtil.saveProject(project);
@@ -56,7 +55,7 @@ public class OverwriteProjectConfigurationTest extends HeavyPlatformTestCase {
Disposer.dispose(disposable);
}
Project recreated = ProjectManagerEx.getInstanceEx().newProjectForTest(myProjectDir, ((ProjectEx)myProject).getEarlyDisposable());
Project recreated = PlatformTestUtil.createProject(myProjectDir, ((ProjectEx)myProject).getEarlyDisposable());
createModule(recreated, "module", ModuleTypeId.WEB_MODULE);
PlatformTestUtil.saveProject(recreated);
Module module = assertOneElement(ModuleManager.getInstance(recreated).getModules());
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.module;
import com.intellij.configurationStore.StateStorageManagerKt;
@@ -14,7 +14,6 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.testFramework.HeavyPlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -25,26 +24,25 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class ModulesConfigurationTest extends HeavyPlatformTestCase {
public void testAddRemoveModule() throws IOException, JDOMException {
public void testAddRemoveModule() throws IOException {
Pair<File, File> result = createProjectWithModule();
File projectDir = result.getFirst();
ProjectManager projectManager = ProjectManager.getInstance();
Project reloaded = projectManager.loadAndOpenProject(projectDir);
Project reloaded = PlatformTestUtil.loadAndOpenProject(projectDir.toPath());
closeOnTearDown(reloaded);
ModuleManager moduleManager = ModuleManager.getInstance(reloaded);
Module module = assertOneElement(moduleManager.getModules());
moduleManager.disposeModule(module);
closeProject(reloaded, true);
reloaded = projectManager.loadAndOpenProject(projectDir);
reloaded = PlatformTestUtil.loadAndOpenProject(projectDir.toPath());
closeOnTearDown(reloaded);
assertEmpty(ModuleManager.getInstance(reloaded).getModules());
closeProject(reloaded, false);
}
// because of external storage, imls file can be missed on disk and it is not error
public void testRemoveFailedToLoadModule() throws IOException, JDOMException {
public void testRemoveFailedToLoadModule() throws IOException {
Pair<File, File> result = createProjectWithModule();
File projectDir = result.getFirst();
File moduleFile = result.getSecond();
@@ -53,8 +51,7 @@ public class ModulesConfigurationTest extends HeavyPlatformTestCase {
WriteAction.run(() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(moduleFile).delete(this));
List<ConfigurationErrorDescription> errors = new ArrayList<>();
ProjectLoadingErrorsHeadlessNotifier.setErrorHandler(errors::add, getTestRootDisposable());
ProjectManager projectManager = ProjectManager.getInstance();
Project reloaded = projectManager.loadAndOpenProject(projectDir);
Project reloaded = PlatformTestUtil.loadAndOpenProject(projectDir.toPath());
closeOnTearDown(reloaded);
ModuleManager moduleManager = ModuleManager.getInstance(reloaded);
assertThat(moduleManager.getModules()).hasSize(1);
@@ -62,7 +59,7 @@ public class ModulesConfigurationTest extends HeavyPlatformTestCase {
closeProject(reloaded, true);
errors.clear();
reloaded = projectManager.loadAndOpenProject(projectDir);
reloaded = PlatformTestUtil.loadAndOpenProject(projectDir.toPath());
closeOnTearDown(reloaded);
assertEmpty(errors);
closeProject(reloaded, false);
@@ -1,22 +1,24 @@
// Copyright 2000-2019 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.
// 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.project.impl
import com.intellij.configurationStore.StoreUtil
import com.intellij.ide.impl.OpenProjectTask
import com.intellij.ide.impl.ProjectUtil
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
import com.intellij.openapi.progress.runModalTask
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ex.ProjectManagerEx
import com.intellij.openapi.startup.StartupActivity
import com.intellij.openapi.util.Disposer
import com.intellij.platform.PlatformProjectOpenProcessor
import com.intellij.testFramework.*
import com.intellij.testFramework.assertions.Assertions.assertThat
import com.intellij.util.io.createDirectories
import junit.framework.TestCase
import org.junit.ClassRule
import org.junit.Rule
import org.junit.Test
@@ -72,8 +74,7 @@ class ProjectOpeningTest {
@Test
fun cancelOnLoadingModules() {
val foo = tempDir.newPath()
val manager: ProjectManagerEx? = ProjectManagerEx.getInstanceEx()
var project = manager!!.createProject(null, foo.toString())!!
var project = createHeavyProject(foo)
try {
StoreUtil.saveSettings(project, false)
runInEdtAndWait {
@@ -82,14 +83,14 @@ class ProjectOpeningTest {
ApplicationManager.getApplication().messageBus.connect(disposableRule.disposable).subscribe(ProjectLifecycleListener.TOPIC,
object : ProjectLifecycleListener {
override fun projectComponentsInitialized(project: Project) {
val indicator: ProgressIndicator? = ProgressManager.getInstance().progressIndicator
TestCase.assertNotNull(indicator)
val indicator = ProgressManager.getInstance().progressIndicator
assertThat(indicator).isNotNull()
indicator!!.cancel()
indicator.checkCanceled()
}
})
runInEdtAndWait {
project = manager.loadAndOpenProject(foo)!!
runModalTask("") {
project = PlatformProjectOpenProcessor.openExistingProject(foo, foo, OpenProjectTask())!!
}
assertThat(project.isOpen).isFalse()
assertThat(project.isDisposed).isTrue()
@@ -106,7 +107,7 @@ class ProjectOpeningTest {
val projectDir = tempDir.newPath()
projectDir.createDirectories()
val dirBasedProject = ProjectManager.getInstance().createProject("project", projectDir.toAbsolutePath().toString())!!
val dirBasedProject = createHeavyProject(projectDir)
Disposer.register(disposableRule.disposable, Disposable {
runInEdtAndWait { closeProject(dirBasedProject) }
})
@@ -5,7 +5,6 @@ import com.intellij.ide.*
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ex.ProjectManagerEx
import com.intellij.testFramework.*
import com.intellij.testFramework.assertions.Assertions.assertThat
import com.intellij.util.PathUtil
@@ -17,6 +16,8 @@ import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExternalResource
import java.io.IOException
import java.nio.file.Path
import java.nio.file.Paths
@RunsInEdt
class RecentProjectsTest {
@@ -64,9 +65,9 @@ class RecentProjectsTest {
manager.addGroup(g1)
manager.addGroup(g2)
g1.addProject(p1)
g1.addProject(p2)
g2.addProject(p3)
g1.addProject(p1.toString())
g1.addProject(p2.toString())
g2.addProject(p3.toString())
checkGroups(listOf("g2", "g1"))
@@ -82,7 +83,7 @@ class RecentProjectsTest {
val path = tempDir.newPath("z1")
project = HeavyPlatformTestCase.createProject(path)
ProjectOpeningTest.closeProject(project)
project = ProjectManagerEx.getInstanceEx().loadAndOpenProject(path)
project = PlatformTestUtil.loadAndOpenProject(path)
val timestamp = getProjectOpenTimestamp("z1")
RecentProjectsManagerBase.instanceEx.updateLastProjectPath()
// "Timestamp for opened project has not been updated"
@@ -103,16 +104,15 @@ class RecentProjectsTest {
return -1
}
@Throws(IOException::class, JDOMException::class)
private fun doReopenCloseAndCheck(projectPath: String, vararg results: String) {
val project = ProjectManager.getInstance().loadAndOpenProject(projectPath)
private fun doReopenCloseAndCheck(projectPath: Path, vararg results: String) {
val project = PlatformTestUtil.loadAndOpenProject(projectPath)
ProjectOpeningTest.closeProject(project)
checkRecents(*results)
}
@Throws(IOException::class, JDOMException::class)
private fun doReopenCloseAndCheckGroups(projectPath: String, results: List<String>) {
val project = ProjectManager.getInstance().loadAndOpenProject(projectPath)
private fun doReopenCloseAndCheckGroups(projectPath: Path, results: List<String>) {
val project = PlatformTestUtil.loadAndOpenProject(projectPath)
ProjectOpeningTest.closeProject(project)
checkGroups(results)
}
@@ -135,15 +135,15 @@ class RecentProjectsTest {
assertThat(recentGroups).isEqualTo(groups)
}
private fun createAndOpenProject(name: String): String {
private fun createAndOpenProject(name: String): Path {
var project: Project? = null
try {
val path = tempDir.newPath(name)
project = HeavyPlatformTestCase.createProject(path)
PlatformTestUtil.saveProject(project)
ProjectOpeningTest.closeProject(project)
project = ProjectManagerEx.getInstanceEx().loadAndOpenProject(path)
return project!!.basePath!!
project = PlatformTestUtil.loadAndOpenProject(path)
return Paths.get(project.basePath!!)
}
finally {
ProjectOpeningTest.closeProject(project)
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.vfs;
import com.intellij.ide.impl.ProjectUtil;
@@ -327,7 +327,7 @@ public class VfsUtilTest extends BareTestFixtureTestCase {
AtomicBoolean getAllExcludedCalled = new AtomicBoolean();
ProjectManagerImpl test = new ProjectManagerImpl() {
@Override
public String @NotNull [] getAllExcludedUrls() {
public @NotNull List<String> getAllExcludedUrls() {
getAllExcludedCalled.set(true);
assertFalse(ApplicationManager.getApplication().isReadAccessAllowed());
return super.getAllExcludedUrls();
@@ -801,7 +801,7 @@ public class FileEncodingTest extends HeavyPlatformTestCase implements TestDialo
File temp = createTempDirectory();
VirtualFile tempDir = requireNonNull(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(temp));
Project newProject = ProjectManagerEx.getInstanceEx().newProjectForTest(Paths.get(tempDir.getPath()), getTestRootDisposable());
Project newProject = PlatformTestUtil.createProject(Paths.get(tempDir.getPath()), getTestRootDisposable());
PlatformTestUtil.saveProject(newProject);
Charset newProjectEncoding = EncodingProjectManager.getInstance(newProject).getDefaultCharset();
@@ -8,11 +8,8 @@ import org.jdom.JDOMException;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
/**
* Provides project management.
@@ -101,15 +98,6 @@ public abstract class ProjectManager {
*/
public abstract @Nullable Project loadAndOpenProject(@NotNull String filePath) throws IOException, JDOMException;
@ApiStatus.Experimental
@TestOnly
public @Nullable Project loadAndOpenProject(@NotNull File file) throws IOException, JDOMException {
return loadAndOpenProject(file.toPath());
}
@ApiStatus.Experimental
public abstract @Nullable Project loadAndOpenProject(@NotNull Path file) throws IOException, JDOMException;
/**
* Closes the specified project, but does not dispose it.
*
@@ -11,6 +11,8 @@ import com.intellij.openapi.application.PathManager
import com.intellij.openapi.application.impl.ApplicationImpl
import com.intellij.openapi.util.RecursionManager
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl
import com.intellij.ui.IconManager
import com.intellij.util.SystemProperties
import com.intellij.util.concurrency.AppExecutorUtil
@@ -52,8 +54,9 @@ internal fun doLoadApp(setupEventQueue: () -> Unit) {
IconManager.activate()
val plugins: List<IdeaPluginDescriptorImpl>
try {
// 40 seconds - tests maybe executed on cloud agents where IO speed is a very slow
plugins = registerRegistryAndInitStore(registerAppComponents(loadedPluginFuture, app), app)
.get(20, TimeUnit.SECONDS)
.get(40, TimeUnit.SECONDS)
val boundedExecutor = createExecutorToPreloadServices()
@@ -63,10 +66,13 @@ internal fun doLoadApp(setupEventQueue: () -> Unit) {
preloadServiceFuture
.thenCompose { callAppInitialized(app, boundedExecutor) }
.get(20, TimeUnit.SECONDS)
.get(40, TimeUnit.SECONDS)
(PersistentFS.getInstance() as PersistentFSImpl).cleanPersistedContents()
}
catch (e: TimeoutException) {
throw RuntimeException("Cannot preload services in 20 seconds: ${ThreadDumper.dumpThreadsToString()}", e)
throw RuntimeException("Cannot preload services in 40 seconds: ${ThreadDumper.dumpThreadsToString()}", e)
}
catch (e: ExecutionException) {
throw e.cause ?: e
@@ -26,8 +26,6 @@ import com.intellij.openapi.project.impl.ProjectManagerImpl
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl
import com.intellij.project.stateStore
import com.intellij.util.SmartList
import com.intellij.util.ThrowableRunnable
@@ -56,7 +54,6 @@ open class ApplicationRule : ExternalResource() {
public final override fun before() {
TestApplicationManager.getInstance()
(PersistentFS.getInstance() as PersistentFSImpl).cleanPersistedContents()
}
}
@@ -100,8 +97,6 @@ class ProjectRule(val projectDescriptor: LightProjectDescriptor = LightProjectDe
}
private fun createLightProject(): ProjectEx {
(PersistentFS.getInstance() as PersistentFSImpl).cleanPersistedContents()
val projectFile = TemporaryDirectory.generateTemporaryPath("light_temp_shared_project${ProjectFileType.DOT_DEFAULT_EXTENSION}")
val buffer = ByteArrayOutputStream()
Throwable(projectFile.systemIndependentPath, null).printStackTrace(PrintStream(buffer))
@@ -163,7 +158,7 @@ class ProjectRule(val projectDescriptor: LightProjectDescriptor = LightProjectDe
}
if (projectOpened.compareAndSet(false, true)) {
runInEdtAndWait { ProjectManagerEx.getInstanceEx().openTestProject(project) }
runInEdtAndWait { PlatformTestUtil.openTestProject(project) }
}
return result!!
}
@@ -280,7 +275,7 @@ suspend fun Project.use(task: suspend (Project) -> Unit) {
try {
if (!projectManager.isProjectOpened(this)) {
withContext(AppUIExecutor.onUiThread().coroutineDispatchingContext()) {
projectManager.openTestProject(this@use)
PlatformTestUtil.openTestProject(this@use)
}
}
task(this)
@@ -378,7 +373,7 @@ suspend fun createOrLoadProject(tempDirManager: TemporaryDirectory,
val project = when (projectCreator) {
null -> createHeavyProject(file, useDefaultProjectAsTemplate = useDefaultProjectSettings)
else -> ProjectManagerImpl.loadProject(file, null) { project ->
else -> ProjectManagerImpl.loadProject(file) { project ->
if (loadComponentState) {
project.putUserData(LISTEN_SCHEME_VFS_CHANGES_IN_TEST_MODE, true)
}
@@ -5,7 +5,6 @@ import com.intellij.application.options.CodeStyle;
import com.intellij.ide.highlighter.ModuleFileType;
import com.intellij.ide.highlighter.ProjectFileType;
import com.intellij.ide.impl.OpenProjectTask;
import com.intellij.ide.startup.impl.StartupManagerImpl;
import com.intellij.idea.IdeaLogger;
import com.intellij.mock.MockApplication;
import com.intellij.openapi.Disposable;
@@ -39,7 +38,6 @@ import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.EmptyRunnable;
import com.intellij.openapi.util.Ref;
@@ -53,8 +51,6 @@ import com.intellij.openapi.vfs.impl.VirtualFilePointerTracker;
import com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl;
import com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl;
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
@@ -70,8 +66,8 @@ import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.indexing.FileBasedIndexImpl;
import com.intellij.util.indexing.IndexableSetContributor;
import com.intellij.util.ui.UIUtil;
import gnu.trove.THashSet;
import gnu.trove.TIntHashSet;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import junit.framework.TestCase;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NonNls;
@@ -111,12 +107,11 @@ import static com.intellij.testFramework.RunAll.runAll;
*/
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"})
public abstract class HeavyPlatformTestCase extends UsefulTestCase implements DataProvider {
private static TestApplicationManager ourTestAppManager;
private static boolean ourReportedLeakedProjects;
protected Project myProject;
protected Module myModule;
protected final Collection<File> myFilesToDelete = new THashSet<>();
protected final Collection<File> myFilesToDelete = new HashSet<>();
private final TempFiles myTempFiles = new TempFiles(myFilesToDelete);
protected boolean myAssertionsInTestDetected;
@@ -165,13 +160,8 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
}
protected void initApplication() throws Exception {
boolean firstTime = ourTestAppManager == null;
ourTestAppManager = TestApplicationManager.getInstance();
ourTestAppManager.setDataProvider(this);
if (firstTime) {
cleanPersistedVFSContent();
}
TestApplicationManager testAppManager = TestApplicationManager.getInstance();
testAppManager.setDataProvider(this);
// try to remember old sdks as soon as possible after the app instantiation
myOldSdks = new SdkLeakTracker();
}
@@ -208,15 +198,10 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
}
}
private static void cleanPersistedVFSContent() {
((PersistentFSImpl)PersistentFS.getInstance()).cleanPersistedContents();
}
@Override
protected void setUp() throws Exception {
super.setUp();
File tempDir = new File(FileUtilRt.getTempDirectory());
myFilesToDelete.add(tempDir);
myFilesToDelete.add(new File(FileUtilRt.getTempDirectory()));
if (ourTestCase != null) {
String message = "Previous test " + ourTestCase + " hasn't called tearDown(). Probably overridden without super call.";
@@ -243,7 +228,6 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
myCodeStyleSettingsTracker = isTrackCodeStyleChanges ? new CodeStyleSettingsTracker(() -> CodeStyle.getDefaultSettings()) : null;
ourTestCase = this;
if (myProject != null) {
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
CodeStyle.setTemporarySettings(myProject, CodeStyle.createTestSettings());
InjectedLanguageManagerImpl.pushInjectors(myProject);
((PsiDocumentManagerBase)PsiDocumentManager.getInstance(myProject)).clearUncommittedDocuments();
@@ -268,7 +252,7 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
protected void setUpProject() throws Exception {
myProject = doCreateProject(getProjectDirOrFile());
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
PlatformTestUtil.openTestProject(myProject);
LocalFileSystem.getInstance().refreshIoFiles(myFilesToDelete);
WriteAction.run(() ->
@@ -280,7 +264,6 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
LightPlatformTestCase.clearUncommittedDocuments(getProject());
runStartupActivities();
((FileTypeManagerImpl)FileTypeManager.getInstance()).drainReDetectQueue();
}
@@ -329,7 +312,7 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
@Contract("_ -> fail")
public static void reportLeakedProjects(@NotNull TooManyProjectLeakedException e) {
TIntHashSet hashCodes = new TIntHashSet();
IntSet hashCodes = new IntOpenHashSet();
for (Project project : e.getLeakedProjects()) {
hashCodes.add(System.identityHashCode(project));
}
@@ -347,19 +330,12 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
leakers.append(";-----\n");
hashCodes.remove(hashCode);
return !hashCodes.isEmpty();
});
fail(leakers + "\nPlease see '" + dumpPath + "' for a memory dump");
}
protected void runStartupActivities() {
StartupManagerImpl startupManager = (StartupManagerImpl)StartupManager.getInstance(myProject);
startupManager.runStartupActivities();
startupManager.runPostStartupActivitiesRegisteredDynamically();
}
@NotNull
protected Path getProjectDirOrFile() {
return getProjectDirOrFile(false);
@@ -538,7 +514,7 @@ public abstract class HeavyPlatformTestCase extends UsefulTestCase implements Da
() -> disposeRootDisposable(),
() -> {
if (myProject != null) {
LightPlatformTestCase.doTearDown(myProject, ourTestAppManager);
LightPlatformTestCase.doTearDown(myProject, TestApplicationManager.getInstanceIfCreated());
myProject = null;
}
},
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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.testFramework;
import com.intellij.ProjectTopics;
@@ -279,10 +279,9 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
descriptor.registerSdk(parentDisposable);
ProjectManagerEx projectManagerEx = ProjectManagerEx.getInstanceEx();
Project project = ourProject;
try {
projectManagerEx.openTestProject(project);
PlatformTestUtil.openTestProject(project);
}
catch (Throwable e) {
setProject(null);
@@ -46,6 +46,7 @@ import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.paths.WebReference;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.project.impl.ProjectManagerImpl;
import com.intellij.openapi.ui.Queryable;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
@@ -1096,4 +1097,27 @@ public final class PlatformTestUtil {
}
}
}
public static @NotNull Project loadAndOpenProject(@NotNull Path path) {
Project project = ProjectManagerImpl.loadProject(path, null);
openTestProject(project);
return project;
}
public static void openTestProject(@NotNull Project project) {
assert ApplicationManager.getApplication().isUnitTestMode();
if (!ProjectManagerEx.getInstanceEx().openProject(project)) {
throw new IllegalStateException("openProject returned false");
}
if (ApplicationManager.getApplication().isDispatchThread()) {
dispatchAllInvocationEventsInIdeEventQueue();
}
}
public static @NotNull Project createProject(@NotNull Path file, @NotNull Disposable parentDisposable) {
Project project = FixtureRuleKt.createHeavyProject(file, /* useDefaultProjectAsTemplate = */ false);
Disposer.register(parentDisposable, () -> forceCloseProjectWithoutSaving(project));
return project;
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.
// 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.testFramework;
import com.intellij.openapi.application.ApplicationManager;
@@ -14,7 +14,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Collection;
public class TempFiles {
public final class TempFiles {
private final Collection<File> myFilesToDelete;
public TempFiles(@NotNull Collection<File> filesToDelete) {
@@ -10,7 +10,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
@@ -301,7 +301,7 @@ public abstract class UsefulTestCase extends TestCase {
}
})
.append(() -> {
currentCodeStyleSettings.getIndentOptions(StdFileTypes.JAVA);
currentCodeStyleSettings.getIndentOptions(FileTypeManager.getInstance().getStdFileType("JAVA"));
try {
checkCodeStyleSettingsEqual(oldCodeStyleSettings, currentCodeStyleSettings);
}
@@ -437,10 +437,11 @@ public abstract class UsefulTestCase extends TestCase {
@Override
public void runBare() throws Throwable {
if (!shouldRunTest()) return;
if (!shouldRunTest()) {
return;
}
if (runInDispatchThread()) {
TestRunnerUtil.replaceIdeEventQueueSafely();
TestApplicationManagerKt.replaceIdeEventQueueSafely();
EdtTestUtil.runInEdtAndWait(this::defaultRunBare);
}
else {
@@ -617,7 +618,7 @@ public abstract class UsefulTestCase extends TestCase {
}
public static <T> void assertContainsElements(@NotNull Collection<? extends T> collection, @NotNull Collection<? extends T> expected) {
ArrayList<T> copy = new ArrayList<>(collection);
List<T> copy = new ArrayList<>(collection);
copy.retainAll(expected);
assertSameElements(toString(collection), copy, expected);
}
@@ -633,7 +634,7 @@ public abstract class UsefulTestCase extends TestCase {
}
public static <T> void assertDoesntContain(@NotNull Collection<? extends T> collection, @NotNull Collection<? extends T> notExpected) {
ArrayList<T> expected = new ArrayList<>(collection);
List<T> expected = new ArrayList<>(collection);
expected.removeAll(notExpected);
assertSameElements(collection, expected);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.
// 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.testFramework.fixtures;
import com.intellij.openapi.editor.Editor;
@@ -6,6 +6,7 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.TestApplicationManager;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.testFramework.builders.EmptyModuleFixtureBuilder;
import com.intellij.testFramework.builders.ModuleFixtureBuilder;
@@ -14,21 +15,27 @@ import org.jetbrains.annotations.NonNls;
import java.io.File;
/**
* @author yole
* @see BasePlatformTestCase for light tests
*/
public abstract class CodeInsightFixtureTestCase<T extends ModuleFixtureBuilder> extends UsefulTestCase {
public abstract class CodeInsightFixtureTestCase<T extends ModuleFixtureBuilder<?>> extends UsefulTestCase {
protected CodeInsightTestFixture myFixture;
protected Module myModule;
@Override
public final void runBare() throws Throwable {
// don't create application in EDT
TestApplicationManager.getInstance();
super.runBare();
}
@Override
protected void setUp() throws Exception {
super.setUp();
String name = getClass().getName() + "." + getName();
final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(name);
TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(name);
myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
final T moduleFixtureBuilder = projectBuilder.addModule(getModuleBuilderClass());
T moduleFixtureBuilder = projectBuilder.addModule(getModuleBuilderClass());
moduleFixtureBuilder.addSourceContentRoot(myFixture.getTempDirPath());
tuneFixture(moduleFixtureBuilder);
@@ -38,9 +45,10 @@ public abstract class CodeInsightFixtureTestCase<T extends ModuleFixtureBuilder>
}
protected Class<T> getModuleBuilderClass() {
return (Class<T>)EmptyModuleFixtureBuilder.class;
//noinspection unchecked,rawtypes
return (Class)EmptyModuleFixtureBuilder.class;
}
@Override
protected void tearDown() throws Exception {
myModule = null;
@@ -56,7 +64,7 @@ public abstract class CodeInsightFixtureTestCase<T extends ModuleFixtureBuilder>
}
}
protected void tuneFixture(final T moduleBuilder) {}
protected void tuneFixture(T moduleBuilder) {}
/**
* Return relative path to the test data. Path is relative to the
@@ -1182,7 +1182,6 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
public void setUp() throws Exception {
super.setUp();
TestApplicationManager.getInstance();
EdtTestUtil.runInEdtAndWait(() -> {
myProjectFixture.setUp();
myTempDirFixture.setUp();
@@ -21,7 +21,6 @@ import com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.ModuleListener;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
@@ -183,7 +182,7 @@ final class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTes
});
EdtTestUtil.runInEdtAndWait(() -> {
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
PlatformTestUtil.openTestProject(myProject);
for (ModuleFixtureBuilder<?> moduleFixtureBuilder : myModuleFixtureBuilders) {
moduleFixtureBuilder.getFixture().setUp();
@@ -19,6 +19,7 @@ import com.intellij.openapi.roots.libraries.LibraryTable
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
@@ -46,7 +47,7 @@ class ProjectModelRule(private val forceEnableWorkspaceModel: Boolean = false) :
createHeavyProject(baseProjectDir.root.toPath())
}
runInEdtAndWait {
ProjectManagerEx.getInstanceEx().openTestProject(project)
PlatformTestUtil.openTestProject(project)
}
}
@@ -78,6 +78,16 @@ public class MultiMap<K, V> implements Serializable {
}
}
public final @NotNull Map<K, Collection<V>> toHashMap() {
if (myMap instanceof HashMap) {
//noinspection unchecked
return (Map<K, Collection<V>>)((HashMap<K, Collection<V>>)myMap).clone();
}
else {
return new HashMap<>(myMap);
}
}
public final void putAllValues(@NotNull Map<? extends K, ? extends V> from) {
for (Map.Entry<? extends K, ? extends V> entry : from.entrySet()) {
putValue(entry.getKey(), entry.getValue());
@@ -1,8 +1,7 @@
// Copyright 2000-2019 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.
// 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.project.ex.ProjectManagerEx
import com.intellij.openapi.startup.StartupManager
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.SystemInfo
@@ -52,8 +51,7 @@ class DirectoryMappingListTest : HeavyPlatformTestCase() {
projectRoot = PsiTestUtil.createTestProjectStructure(getTestName(true), null, root, myFilesToDelete, false)
rootPath = projectRoot.path
myProject = ProjectManagerEx.getInstanceEx().loadProject(Paths.get("$rootPath/directoryMappings.ipr"))
ProjectManagerEx.getInstanceEx().openTestProject(myProject)
myProject = PlatformTestUtil.loadAndOpenProject(Paths.get("$rootPath/directoryMappings.ipr"))
vcsMock = MockAbstractVcs(myProject, MOCK)
vcsMock2 = MockAbstractVcs(myProject, MOCK2)
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.testFramework.ApplicationRule
import com.intellij.testFramework.DisposableRule
import com.intellij.testFramework.PlatformTestUtil
import com.intellij.testFramework.TemporaryDirectory
import com.intellij.testFramework.UsefulTestCase.assertEmpty
import com.intellij.testFramework.UsefulTestCase.assertSameElements
@@ -406,7 +407,7 @@ class LegacyBridgeModulesTest {
WorkspaceModelInitialTestContent.withInitialContent(builder.toStorage()) {
val project = ProjectManager.getInstance().createProject("testProject", iprFile.path)!!
invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().openTestProject(project) }
invokeAndWaitIfNeeded { PlatformTestUtil.openTestProject(project) }
disposableRule.disposable.attach { invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().forceCloseProject(project) } }
val module = ModuleManager.getInstance(project).findModuleByName("test")
@@ -441,7 +442,7 @@ class LegacyBridgeModulesTest {
WorkspaceModelInitialTestContent.withInitialContent(builder.toStorage()) {
val project = ProjectManager.getInstance().createProject("testProject", iprFile.path)!!
invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().openTestProject(project) }
invokeAndWaitIfNeeded { PlatformTestUtil.openTestProject(project) }
disposableRule.disposable.attach { invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().forceCloseProject(project) } }
val projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project)
@@ -657,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 { ProjectManagerEx.getInstanceEx().openTestProject(project) }
invokeAndWaitIfNeeded { PlatformTestUtil.openTestProject(project) }
disposableRule.disposable.attach { invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().forceCloseProject(project) } }
return project
}
@@ -9,7 +9,6 @@ import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.module.impl.ModuleManagerComponent
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ex.ProjectManagerEx
import com.intellij.openapi.rd.attach
import com.intellij.openapi.roots.ModuleRootManager
@@ -21,6 +20,7 @@ import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.registry.Registry
import com.intellij.testFramework.ApplicationRule
import com.intellij.testFramework.DisposableRule
import com.intellij.testFramework.PlatformTestUtil
import com.intellij.testFramework.TemporaryDirectory
import com.intellij.workspace.api.ModuleDependencyItem
import com.intellij.workspace.api.ModuleEntity
@@ -36,11 +36,11 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.io.File
import java.nio.file.Path
const val JAVA_CLASS_PREFIX = "JavaClass"
const val MODULE_PREFIX = "module"
const val TEST_MODULE_PREFIX = "test"
private const val JAVA_CLASS_PREFIX = "JavaClass"
private const val MODULE_PREFIX = "module"
private const val TEST_MODULE_PREFIX = "test"
@RunWith(Parameterized::class)
class WorkspaceModelPerformanceTest(private val modulesCount: Int) {
@@ -73,9 +73,9 @@ class WorkspaceModelPerformanceTest(private val modulesCount: Int) {
disposerDebugMode = Disposer.isDebugMode()
Disposer.setDebugMode(false)
val projectDir = temporaryDirectoryRule.newPath("project").toFile()
val projectDir = temporaryDirectoryRule.newPath("project")
logExecutionTimeInMillis("Project generation") {
generateProject(projectDir)
generateProject(projectDir.toFile())
}
project = loadTestProject(projectDir, disposableRule)
}
@@ -141,8 +141,7 @@ class WorkspaceModelPerformanceTest(private val modulesCount: Int) {
}
}
private fun findAndRemoveLibFromHundredModules(modules: MutableList<Module>,
antLibName: String) {
private fun findAndRemoveLibFromHundredModules(modules: MutableList<Module>, antLibName: String) {
modules.forEach { module ->
ModuleRootManager.getInstance(module).modifiableModel.let {
val moduleLibrary = it.moduleLibraryTable.getLibraryByName(antLibName)!!
@@ -170,8 +169,7 @@ class WorkspaceModelPerformanceTest(private val modulesCount: Int) {
moduleManager.modules.forEach { ModuleRootManager.getInstance(it).contentRoots.forEach { entry -> entry.canonicalFile } }
}
private fun addModuleLibraryToHunredModules(modules: MutableList<Module>,
antLibName: String) {
private fun addModuleLibraryToHunredModules(modules: MutableList<Module>, antLibName: String) {
modules.forEach { module -> ModuleRootModificationUtil.addModuleLibrary(module, antLibName, listOf(), emptyList()) }
}
@@ -224,12 +222,15 @@ class WorkspaceModelPerformanceTest(private val modulesCount: Int) {
assertEquals(modulesCount, entities.toList().size)
}
private fun loadTestProject(projectDir: File, disposableRule: DisposableRule): Project {
private fun loadTestProject(projectDir: Path, disposableRule: DisposableRule): Project {
val project = logExecutionTimeInMillis<Project>("Project load") {
return@logExecutionTimeInMillis ProjectManager.getInstance().loadAndOpenProject(projectDir)!!
PlatformTestUtil.loadAndOpenProject(projectDir)
}
disposableRule.disposable.attach {
invokeAndWaitIfNeeded {
ProjectManagerEx.getInstanceEx().forceCloseProject(project)
}
}
invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().openTestProject(project) }
disposableRule.disposable.attach { invokeAndWaitIfNeeded { ProjectManagerEx.getInstanceEx().forceCloseProject(project) } }
return project
}
@@ -1,25 +1,22 @@
// Copyright 2000-2019 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.
// 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.coverage;
import com.intellij.idea.ExcludeFromTestDiscovery;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiPackage;
import com.intellij.rt.coverage.data.ClassData;
import com.intellij.rt.coverage.data.LineCoverage;
import com.intellij.testFramework.JavaModuleTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import java.io.File;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
/**
* @author yole
*/
@ExcludeFromTestDiscovery
public class CoverageIntegrationTest extends JavaModuleTestCase {
private static String getTestDataPath() {
@@ -27,11 +24,8 @@ public class CoverageIntegrationTest extends JavaModuleTestCase {
}
@Override
protected void setUpProject() throws Exception {
String testDataPath = getTestDataPath();
myProject = ProjectManagerEx.getInstanceEx().loadProject(Paths.get(testDataPath));
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
runStartupActivities();
protected void setUpProject() {
myProject = PlatformTestUtil.loadAndOpenProject(Paths.get(getTestDataPath()));
}
public void testSimple() {
@@ -72,14 +66,10 @@ public class CoverageIntegrationTest extends JavaModuleTestCase {
}
private static class PackageAnnotationConsumer implements PackageAnnotator.Annotator {
private final Map<VirtualFile, PackageAnnotator.PackageCoverageInfo> myDirectoryCoverage =
new HashMap<>();
private final Map<String, PackageAnnotator.PackageCoverageInfo> myPackageCoverage =
new HashMap<>();
private final Map<String, PackageAnnotator.PackageCoverageInfo> myFlatPackageCoverage =
new HashMap<>();
private final Map<String, PackageAnnotator.ClassCoverageInfo> myClassCoverageInfo =
new HashMap<>();
private final Map<VirtualFile, PackageAnnotator.PackageCoverageInfo> myDirectoryCoverage = new HashMap<>();
private final Map<String, PackageAnnotator.PackageCoverageInfo> myPackageCoverage = new HashMap<>();
private final Map<String, PackageAnnotator.PackageCoverageInfo> myFlatPackageCoverage = new HashMap<>();
private final Map<String, PackageAnnotator.ClassCoverageInfo> myClassCoverageInfo = new HashMap<>();
@Override
public void annotateSourceDirectory(VirtualFile virtualFile, PackageAnnotator.PackageCoverageInfo packageCoverageInfo, Module module) {
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// 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 org.jetbrains.idea.maven.project;
import com.intellij.CommonBundle;
@@ -31,6 +31,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.text.StringUtil;
@@ -55,7 +56,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.concurrency.AsyncPromise;
import org.jetbrains.concurrency.Promise;
import org.jetbrains.concurrency.Promises;
import org.jetbrains.idea.maven.buildtool.MavenSyncConsole;
import org.jetbrains.idea.maven.importing.MavenFoldersImporter;
import org.jetbrains.idea.maven.importing.MavenPomPathModuleService;
@@ -64,7 +64,6 @@ import org.jetbrains.idea.maven.importing.worktree.LegacyBrigdeIdeModifiableMode
import org.jetbrains.idea.maven.model.*;
import org.jetbrains.idea.maven.project.MavenArtifactDownloader.DownloadResult;
import org.jetbrains.idea.maven.server.MavenEmbedderWrapper;
import org.jetbrains.idea.maven.server.MavenServerManager;
import org.jetbrains.idea.maven.server.MavenServerProgressIndicator;
import org.jetbrains.idea.maven.server.NativeMavenProjectHolder;
import org.jetbrains.idea.maven.utils.*;
@@ -80,7 +79,7 @@ import java.util.function.Consumer;
import java.util.stream.Collectors;
@State(name = "MavenProjectsManager")
public class MavenProjectsManager extends MavenSimpleProjectComponent
public final class MavenProjectsManager extends MavenSimpleProjectComponent
implements PersistentStateComponent<MavenProjectsManagerState>, SettingsSavingComponentJavaAdapter, Disposable {
private static final int IMPORT_DELAY = 1000;
private static final String NON_MANAGED_POM_NOTIFICATION_GROUP_ID = "Maven: non-managed pom.xml";
@@ -189,10 +188,11 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
@Override
public void initializeComponent() {
if (!isNormalProject()) return;
StartupManagerEx startupManager = StartupManagerEx.getInstanceEx(myProject);
if (!isNormalProject()) {
return;
}
StartupManager startupManager = StartupManager.getInstance(myProject);
startupManager.registerStartupActivity(() -> {
boolean wasMavenized = !myState.originalFiles.isEmpty();
if (!wasMavenized) return;
@@ -5,7 +5,6 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.projectRoots.Sdk
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.roots.ModuleRootModificationUtil
@@ -14,16 +13,16 @@ import com.intellij.openapi.vfs.VfsUtil
import com.intellij.testFramework.PlatformTestUtil
import com.intellij.util.ui.UIUtil
import java.io.File
import java.nio.file.Paths
fun openProjectWithSdk(projectPath: String,
moduleTypeId: String,
sdkProducer: (Project, Module) -> Sdk?): Pair<Project, Sdk?> {
println("Opening project at $projectPath")
val project: Project? = ProjectManager.getInstance().loadAndOpenProject(projectPath)
val project = PlatformTestUtil.loadAndOpenProject(Paths.get(projectPath))
try {
val module = getOrCreateModule(project!!, projectPath, moduleTypeId)
val module = getOrCreateModule(project, projectPath, moduleTypeId)
val sdk = sdkProducer(project, module)
@@ -38,11 +37,9 @@ fun openProjectWithSdk(projectPath: String,
return Pair(project, sdk)
}
catch (e: Throwable) {
if (project != null) {
UIUtil.invokeAndWaitIfNeeded(Runnable {
PlatformTestUtil.forceCloseProjectWithoutSaving(project)
})
}
UIUtil.invokeAndWaitIfNeeded(Runnable {
PlatformTestUtil.forceCloseProjectWithoutSaving(project)
})
throw e
}
}
@@ -53,15 +50,15 @@ fun getOrCreateModule(project: Project, projectPath: String, moduleTypeId: Strin
}
else {
val module: Module = ApplicationManager.getApplication().runWriteAction(
Computable<Module> { ModuleManager.getInstance(project).newModule(projectPath, moduleTypeId) }
Computable { ModuleManager.getInstance(project).newModule(projectPath, moduleTypeId) }
)
val root = VfsUtil.findFileByIoFile(File(projectPath), true) ?: throw AssertionError("Can't find $projectPath")
ModuleRootModificationUtil.updateModel(module, { t ->
ModuleRootModificationUtil.updateModel(module) { t ->
val e = t.addContentEntry(root)
e.addSourceFolder(root, false)
})
}
return module
}
@@ -1,14 +1,14 @@
// Copyright 2000-2019 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.
// 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 org.jetbrains.index.stubs
import com.google.common.hash.HashCode
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.impl.DebugUtil
import com.intellij.psi.stubs.*
import com.intellij.testFramework.PlatformTestUtil
import com.intellij.testFramework.TestApplicationManager
import com.intellij.util.indexing.FileBasedIndex
import com.intellij.util.indexing.FileBasedIndexExtension
@@ -71,7 +71,7 @@ private fun writeStubsVersionFile(stubsStorageFilePath: String, stubsVersion: St
fun mergeStubs(paths: List<String>, stubsFilePath: String, stubsFileName: String, projectPath: String, stubsVersion: String) {
TestApplicationManager.getInstance()
ProjectManager.getInstance().loadAndOpenProject(projectPath)!!
PlatformTestUtil.loadAndOpenProject(Paths.get(projectPath))
// we don't need a project here, but I didn't find a better way to wait until indices and components are initialized
val stubExternalizer = GeneratingFullStubExternalizer()
@@ -81,7 +81,7 @@ fun mergeStubs(paths: List<String>, stubsFilePath: String, stubsFileName: String
storageFile.delete()
}
val storage = PersistentHashMap<HashCode, SerializedStubTree>(storageFile.toPath(), HashCodeDescriptor.instance, stubExternalizer)
val storage = PersistentHashMap(storageFile.toPath(), HashCodeDescriptor.instance, stubExternalizer)
val stringEnumeratorFile = File(stubsFilePath, "$stubsFileName.names")
if (stringEnumeratorFile.exists()) {
@@ -98,7 +98,7 @@ fun mergeStubs(paths: List<String>, stubsFilePath: String, stubsFileName: String
println("Reading stubs from $path")
var count = 0
val fromStorageFile = File(path, "$stubsFileName.input")
val fromStorage = PersistentHashMap<HashCode, SerializedStubTree>(fromStorageFile, HashCodeDescriptor.instance, stubExternalizer)
val fromStorage = PersistentHashMap(fromStorageFile, HashCodeDescriptor.instance, stubExternalizer)
val serializationManager = SerializationManagerImpl(File(path, "$stubsFileName.names").toPath(), true)
try {