execute BundledPluginsLister not in EDT

GitOrigin-RevId: f6c3c08dde134721e2e610329fe3b48a901a8cf7
This commit is contained in:
Vladimir Krivosheev
2020-02-14 10:25:08 +01:00
committed by intellij-monorepo-bot
parent bfba71f624
commit 1c50ef0658
18 changed files with 126 additions and 117 deletions

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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 org.jetbrains.jps.incremental.dependencies;
import org.jetbrains.annotations.NotNull;
@@ -21,7 +7,6 @@ import org.jetbrains.jps.builders.*;
import org.jetbrains.jps.builders.impl.BuildTargetChunk;
import org.jetbrains.jps.builders.storage.BuildDataPaths;
import org.jetbrains.jps.incremental.CompileContext;
import org.jetbrains.jps.incremental.ProjectBuildException;
import org.jetbrains.jps.incremental.TargetBuilder;
import org.jetbrains.jps.incremental.messages.ProgressMessage;
import org.jetbrains.jps.indices.IgnoredFileIndex;
@@ -29,12 +14,11 @@ import org.jetbrains.jps.indices.ModuleExcludeIndex;
import org.jetbrains.jps.model.JpsModel;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class ProjectDependenciesResolver extends TargetBuilder<BuildRootDescriptor, ProjectDependenciesResolver.ProjectDependenciesResolvingTarget> {
public final class ProjectDependenciesResolver extends TargetBuilder<BuildRootDescriptor, ProjectDependenciesResolver.ProjectDependenciesResolvingTarget> {
public static final String TARGET_TYPE_ID = "project-dependencies-resolving";
public ProjectDependenciesResolver() {
@@ -45,7 +29,7 @@ public class ProjectDependenciesResolver extends TargetBuilder<BuildRootDescript
public void build(@NotNull ProjectDependenciesResolvingTarget target,
@NotNull DirtyFilesHolder<BuildRootDescriptor, ProjectDependenciesResolvingTarget> holder,
@NotNull BuildOutputConsumer outputConsumer,
@NotNull CompileContext context) throws ProjectBuildException, IOException {
@NotNull CompileContext context) {
context.processMessage(new ProgressMessage("Resolving repository libraries in the project..."));
try {
DependencyResolvingBuilder.resolveMissingDependencies(context, context.getProjectDescriptor().getProject().getModules(),

View File

@@ -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.configurationStore
import com.intellij.configurationStore.statistic.eventLog.FeatureUsageSettingsEvents
@@ -16,6 +16,7 @@ import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.diagnostic.debug
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.diagnostic.runAndLogException
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
@@ -89,7 +90,7 @@ abstract class ComponentStoreImpl : IComponentStore {
internal fun getComponents(): Map<String, ComponentInfo> = components
override fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?) {
override fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?, pluginId: PluginId?) {
var componentName = ""
try {
@Suppress("DEPRECATION")
@@ -106,7 +107,7 @@ abstract class ComponentStoreImpl : IComponentStore {
throw e
}
catch (e: Exception) {
PluginException.logPluginError(LOG, "Cannot init $componentName component state", e, component.javaClass)
LOG.error(PluginException("Cannot init $componentName component state", e, pluginId))
}
}

View File

@@ -1,10 +1,11 @@
// 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.configurationStore
import com.intellij.openapi.components.ServiceDescriptor
import com.intellij.openapi.components.SettingsSavingComponent
import com.intellij.openapi.diagnostic.runAndLogException
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.util.SmartList
import com.intellij.util.containers.ContainerUtil
@@ -37,7 +38,7 @@ abstract class ComponentStoreWithExtraComponents : ComponentStoreImpl() {
}
}
override fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?) {
override fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?, pluginId: PluginId?) {
@Suppress("DEPRECATION")
if (component is com.intellij.configurationStore.SettingsSavingComponent) {
asyncSettingsSavingComponents.add(component)
@@ -46,7 +47,7 @@ abstract class ComponentStoreWithExtraComponents : ComponentStoreImpl() {
settingsSavingComponents.add(component)
}
super.initComponent(component, serviceDescriptor)
super.initComponent(component, serviceDescriptor, pluginId)
}
internal suspend fun saveSettingsSavingComponentsAndCommitComponents(result: SaveResult, forceSavingAllSettings: Boolean,

View File

@@ -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.configurationStore
import com.intellij.configurationStore.schemeManager.ROOT_CONFIG
@@ -68,11 +68,11 @@ internal class ApplicationStoreTest {
componentStore.storageManager.removeStreamProvider(MyStreamProvider::class.java)
componentStore.storageManager.addStreamProvider(streamProvider)
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
component.foo = "newValue"
componentStore.save()
assertThat(streamProvider.data[RoamingType.DEFAULT]!!["new.xml"]).isEqualTo("<application>\n <component name=\"A\" foo=\"newValue\" />\n</application>")
assertThat(streamProvider.data.get(RoamingType.DEFAULT)!!.get("new.xml")).isEqualTo("<application>\n <component name=\"A\" foo=\"newValue\" />\n</application>")
}
@Test fun `load from stream provider`() {
@@ -87,7 +87,7 @@ internal class ApplicationStoreTest {
val storageManager = componentStore.storageManager
storageManager.removeStreamProvider(MyStreamProvider::class.java)
storageManager.addStreamProvider(streamProvider)
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
assertThat(component.foo).isEqualTo("newValue")
assertThat(Paths.get(storageManager.expandMacros(fileSpec))).doesNotExist()
@@ -116,7 +116,7 @@ internal class ApplicationStoreTest {
testAppConfig.refreshVfs()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
assertThat(component.foo).isEqualTo("new")
component.foo = "new2"
@@ -152,7 +152,7 @@ internal class ApplicationStoreTest {
testAppConfig.refreshVfs()
val component = A()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
component.options.foo = "new"
@@ -203,7 +203,7 @@ internal class ApplicationStoreTest {
testAppConfig.refreshVfs()
val component = SeveralStoragesConfigured()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
assertThat(component.foo).isEqualTo("new")
componentStore.save()
@@ -221,7 +221,7 @@ internal class ApplicationStoreTest {
testAppConfig.refreshVfs()
val component = A()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
assertThat(component.options).isEqualTo(TestState("old"))
componentStore.save()
@@ -247,12 +247,12 @@ internal class ApplicationStoreTest {
val component = A()
component.isThrowErrorOnLoadState = true
assertThatThrownBy {
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
}.isInstanceOf(ProcessCanceledException::class.java)
assertThat(component.options).isEqualTo(TestState())
component.isThrowErrorOnLoadState = false
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
assertThat(component.options).isEqualTo(TestState("old"))
}
@@ -266,7 +266,7 @@ internal class ApplicationStoreTest {
testAppConfig.refreshVfs()
val component = AWorkspace()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
assertThat(component.options).isEqualTo(TestState("old"))
try {
@@ -289,7 +289,7 @@ internal class ApplicationStoreTest {
class AOther : A()
val component = AOther()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
component.options.foo = "old"
componentStore.save()
@@ -312,15 +312,15 @@ internal class ApplicationStoreTest {
class COther : A()
val component = AOther()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
component.options.foo = "old"
val component2 = BOther()
componentStore.initComponent(component2, null)
componentStore.initComponent(component2, null, null)
component2.options.foo = "old?"
val component3 = COther()
componentStore.initComponent(component3, null)
componentStore.initComponent(component3, null, null)
component3.options.bar = "foo"
componentStore.save()

View File

@@ -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.configurationStore
import com.intellij.configurationStore.schemeManager.ROOT_CONFIG
@@ -61,7 +61,7 @@ internal class ComponentStoreModificationTrackerTest {
}
val component = A()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
assertThat(component.modificationCount).isEqualTo(0)
assertThat(component.stateCalledCount.get()).isEqualTo(0)
@@ -128,7 +128,7 @@ internal class ComponentStoreModificationTrackerTest {
}
val component = A()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
assertThat(component.modificationCount.get()).isEqualTo(0)
assertThat(component.stateCalledCount.get()).isEqualTo(0)

View File

@@ -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.configurationStore
import com.intellij.externalDependencies.DependencyOnPlugin
@@ -83,12 +83,12 @@ internal class DefaultProjectStoreTest {
<main name="$TEST_COMPONENT_NAME"/><sub name="foo" /><sub name="bar" />
</component>""".trimIndent()))
val stateStore = ProjectManager.getInstance().defaultProject.stateStore as ComponentStoreImpl
stateStore.initComponent(defaultTestComponent, null)
stateStore.initComponent(defaultTestComponent, null, null)
try {
// obviously, project must be directory-based also
createProjectAndUseInLoadComponentStateMode(tempDirManager, directoryBased = true) {
val component = TestComponent()
it.stateStore.initComponent(component, null)
it.stateStore.initComponent(component, null, null)
assertThat(component.state).isEqualTo(defaultTestComponent.state)
}
}

View File

@@ -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.configurationStore
import com.intellij.ide.highlighter.ProjectFileType
@@ -202,7 +202,7 @@ internal class ProjectStoreTest {
class AOther : A()
val component = AOther()
componentStore.initComponent(component, null)
componentStore.initComponent(component, null, null)
assertThat(component.options.foo).isEqualTo("some data")
componentStore.save()
@@ -243,7 +243,7 @@ internal class ProjectStoreTest {
val testComponent = TestComponent()
testComponent.loadState(TestState(AAvalue = "foo"))
(projectManager.defaultProject as ComponentManager).stateStore.initComponent(testComponent, null)
(projectManager.defaultProject as ComponentManager).stateStore.initComponent(testComponent, null, null)
val newProjectPath = tempDirManager.newPath()
val newProject = projectManager.newProject("foo", newProjectPath.systemIndependentPath, true, false)!!
@@ -261,7 +261,7 @@ internal class ProjectStoreTest {
private suspend fun test(project: Project): TestComponent {
val testComponent = TestComponent()
project.stateStore.initComponent(testComponent, null)
project.stateStore.initComponent(testComponent, null, null)
assertThat(testComponent.state).isEqualTo(TestState("customValue"))
testComponent.state!!.AAvalue = "foo"

View File

@@ -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.diagnostic;
import com.intellij.openapi.diagnostic.Logger;

View File

@@ -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.impl
import com.intellij.configurationStore.SaveSession
@@ -7,6 +7,7 @@ import com.intellij.configurationStore.StateStorageManager
import com.intellij.configurationStore.StreamProvider
import com.intellij.openapi.components.*
import com.intellij.openapi.components.impl.stores.ModuleStore
import com.intellij.openapi.extensions.PluginId
import com.intellij.util.messages.MessageBus
import org.jetbrains.annotations.ApiStatus
@@ -15,7 +16,7 @@ internal class NonPersistentModuleStore : ModuleStore {
override val storageManager: StateStorageManager = NonPersistentStateStorageManager
override fun setPath(path: String): Unit = Unit
override fun setPath(path: String, isNew: Boolean): Unit = Unit
override fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?): Unit = Unit
override fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?, pluginId: PluginId?): Unit = Unit
override fun initPersistencePlainComponent(component: Any, key: String): Unit = Unit
override fun reloadStates(componentNames: Set<String>, messageBus: MessageBus): Unit = Unit
override fun reloadState(componentClass: Class<out PersistentStateComponent<*>>): Unit = Unit

View File

@@ -1,9 +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.openapi.application;
import com.intellij.ide.CliResult;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.util.ArrayUtilRt;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -12,12 +13,14 @@ import java.util.concurrent.Future;
/**
* This extension point allows running custom [command-line] application based on IntelliJ platform.
*
* @author max
*/
public interface ApplicationStarter {
ExtensionPointName<ApplicationStarter> EP_NAME = new ExtensionPointName<>("com.intellij.appStarter");
int NON_MODAL = 1;
int ANY_MODALITY = 2;
int NOT_IN_EDT = 3;
/**
* Command-line switch to start with this runner.
* For example return {@code "inspect"} if you'd like to start an app with {@code "idea.exe inspect ..."} command).
@@ -34,7 +37,7 @@ public interface ApplicationStarter {
default void premain(@SuppressWarnings("unused") String @NotNull [] args) { }
/**
* Called before application initialization. Invoked in event dispatch thread.
* Called before application initialization.
*
* @param args program arguments (including the selector)
*/
@@ -42,13 +45,22 @@ public interface ApplicationStarter {
premain(ArrayUtilRt.toStringArray(args));
}
/**
* @deprecated Use {@link #main(List)}
*/
@Deprecated
default void main(String @NotNull [] args) {
}
/**
* <p>Called when application has been initialized. Invoked in event dispatch thread.</p>
* <p>An application starter should take care of terminating JVM when appropriate by calling {@link System#exit}.</p>
*
* @param args program arguments (including the selector)
*/
void main(String @NotNull [] args);
default void main(@NotNull List <String> args) {
main(ArrayUtilRt.toStringArray(args));
}
/**
* Applications that are incapable of working in a headless mode should override the method and return {@code false}.
@@ -72,8 +84,9 @@ public interface ApplicationStarter {
* Such a starter may not directly change the PSI/VFS/project model of the opened projects or open new projects.
* Such activities should be performed inside write-safe contexts (see {@link TransactionGuard}).
*/
default boolean allowAnyModalityState() {
return false;
@MagicConstant(intValues = {NON_MODAL, ANY_MODALITY, NOT_IN_EDT})
default int getModalityState() {
return NON_MODAL;
}
/** @see #canProcessExternalCommandLine */

View File

@@ -1,25 +1,25 @@
// 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.plugins;
import com.google.gson.stream.JsonWriter;
import com.intellij.openapi.application.ApplicationStarter;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.fileTypes.FileNameMatcher;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.PlainTextLikeFileType;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Ivan Chirkov
*/
@SuppressWarnings("UseOfSystemOutOrSystemErr")
final class BundledPluginsLister implements ApplicationStarter {
@Override
public String getCommandName() {
@@ -27,42 +27,48 @@ final class BundledPluginsLister implements ApplicationStarter {
}
@Override
public void main(String @NotNull [] args) {
public int getModalityState() {
return NOT_IN_EDT;
}
@Override
public void main(@NotNull List<String> args) {
try {
OutputStream out;
if (args.length == 2) {
File outFile = new File(args[1]);
FileUtil.createParentDirs(outFile);
//noinspection IOResourceOpenedButNotSafelyClosed
out = new FileOutputStream(outFile);
Writer out;
if (args.size() == 2) {
Path outFile = Paths.get(args.get(1));
Files.createDirectories(outFile.getParent());
out = Files.newBufferedWriter(outFile);
}
else {
out = System.out;
// noinspection UseOfSystemOutOrSystemErr,IOResourceOpenedButNotSafelyClosed
out = new OutputStreamWriter(System.out, StandardCharsets.UTF_8);
}
try (JsonWriter writer = new JsonWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8))) {
try (JsonWriter writer = new JsonWriter(out)) {
List<? extends IdeaPluginDescriptor> plugins = PluginManagerCore.getLoadedPlugins();
List<String> modules = new ArrayList<>();
for (IdeaPluginDescriptor it : plugins) {
if (it instanceof IdeaPluginDescriptorImpl) {
for (PluginId pluginId : ((IdeaPluginDescriptorImpl)it).getModules()) {
modules.add(pluginId.getIdString());
List<String> pluginIds = new ArrayList<>(plugins.size());
for (IdeaPluginDescriptor plugin : plugins) {
pluginIds.add(plugin.getPluginId().getIdString());
for (PluginId pluginId : ((IdeaPluginDescriptorImpl)plugin).getModules()) {
modules.add(pluginId.getIdString());
}
}
pluginIds.sort(null);
modules.sort(null);
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
List<String> extensions = new ArrayList<>();
for (FileType type : fileTypeManager.getRegisteredFileTypes()) {
if (!(type instanceof PlainTextLikeFileType)) {
for (FileNameMatcher matcher : fileTypeManager.getAssociations(type)) {
extensions.add(matcher.getPresentableString());
}
}
}
modules.sort(null);
List<String> pluginIds = plugins.stream()
.map(plugin -> plugin.getPluginId().getIdString())
.sorted()
.collect(Collectors.toList());
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
List<String> extensions = Arrays.stream(fileTypeManager.getRegisteredFileTypes()).
filter(type -> !(type instanceof PlainTextLikeFileType)).
flatMap(type -> fileTypeManager.getAssociations(type).stream()).
map(matcher -> matcher.getPresentableString()).
collect(Collectors.toList());
writer.beginObject();
writeList(writer, "modules", modules);
@@ -72,6 +78,7 @@ final class BundledPluginsLister implements ApplicationStarter {
}
}
catch (IOException e) {
//noinspection UseOfSystemOutOrSystemErr
e.printStackTrace(System.err);
System.exit(1);
}
@@ -79,7 +86,7 @@ final class BundledPluginsLister implements ApplicationStarter {
System.exit(0);
}
private static void writeList(JsonWriter writer, String name, List<String> elements) throws IOException {
private static void writeList(@NotNull JsonWriter writer, String name, @NotNull List<String> elements) throws IOException {
writer.name(name).beginArray();
for (String module : elements) {
writer.value(module);

View File

@@ -26,7 +26,6 @@ import com.intellij.ui.AppIcon
import com.intellij.ui.mac.MacOSApplicationProvider
import com.intellij.ui.mac.foundation.Foundation
import com.intellij.ui.mac.touchbar.TouchBarsManager
import com.intellij.util.ArrayUtilRt
import com.intellij.util.concurrency.AppExecutorUtil
import com.intellij.util.concurrency.NonUrgentExecutor
import com.intellij.util.io.write
@@ -215,14 +214,14 @@ private fun startApp(app: ApplicationImpl,
// not good, so force execution out of EDT
nonEdtExecutor)
.thenRun(Runnable {
if (starter is IdeStarter) {
if (starter.modalityState == ApplicationStarter.NOT_IN_EDT) {
starter.main(args)
}
else {
// backward compatibility
ApplicationManager.getApplication().invokeLater(Runnable {
(TransactionGuard.getInstance() as TransactionGuardImpl).performUserActivity {
starter.main(ArrayUtilRt.toStringArray(args))
starter.main(args)
}
})
}
@@ -311,10 +310,14 @@ private fun addActivateAndWindowsCliListeners() {
MainRunner.LISTENER = WindowsCommandLineListener { currentDirectory, args ->
LOG.info("External Windows command received")
if (args.isEmpty()) return@WindowsCommandLineListener 0
if (args.isEmpty()) {
return@WindowsCommandLineListener 0
}
val app = ApplicationManager.getApplication()
val anyState = ApplicationStarter.EP_NAME.iterable.any { it.canProcessExternalCommandLine() && args[0] == it.commandName && it.allowAnyModalityState() }
val anyState = ApplicationStarter.EP_NAME.iterable.any {
it.canProcessExternalCommandLine() && args[0] == it.commandName && it.modalityState != ApplicationStarter.NON_MODAL
}
val state = if (anyState) app.anyModalityState else app.defaultModalityState
val ref = AtomicReference<Future<CliResult>>()

View File

@@ -58,11 +58,9 @@ open class IdeStarter : ApplicationStarter {
override fun getCommandName(): String? = null
override fun main(args: Array<String>) {
main(args.toList())
}
override fun getModalityState() = ApplicationStarter.NOT_IN_EDT
internal fun main(args: List<String>) {
override fun main(args: List<String>) {
val frameInitActivity = StartUpMeasurer.startMainActivity("frame initialization")
// Event queue should not be changed during initialization of application components.

View File

@@ -1,10 +1,11 @@
// 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.stores
import com.intellij.configurationStore.SaveSession
import com.intellij.configurationStore.StateStorageManager
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.ServiceDescriptor
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.messages.MessageBus
import org.jetbrains.annotations.SystemIndependent
@@ -15,7 +16,7 @@ interface IComponentStore {
fun setPath(path: @SystemIndependent String)
fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?)
fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?, pluginId: PluginId?)
@JvmDefault
fun unloadComponent(component: Any) {

View File

@@ -39,7 +39,7 @@ internal class MyComponentAdapter(private val componentKey: Class<*>,
Disposer.register(componentManager.serviceParentDisposable, instance)
}
componentManager.initializeComponent(instance, null)
componentManager.initializeComponent(instance, serviceDescriptor = null, pluginId = pluginId)
@Suppress("DEPRECATION")
if (instance is BaseComponent) {
@Suppress("DEPRECATION")

View File

@@ -297,11 +297,10 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
}
}
@Internal
fun initializeComponent(component: Any, serviceDescriptor: ServiceDescriptor?) {
internal fun initializeComponent(component: Any, serviceDescriptor: ServiceDescriptor?, pluginId: PluginId?) {
if (serviceDescriptor == null || !(component is PathMacroManager || component is IComponentStore || component is MessageBusFactory)) {
LoadingState.CONFIGURATION_STORE_INITIALIZED.checkOccurred()
componentStore.initComponent(component, serviceDescriptor)
componentStore.initComponent(component, serviceDescriptor, pluginId)
}
}
@@ -503,9 +502,9 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
Disposer.register(serviceParentDisposable, result)
}
initializeComponent(result, null)
val pluginClassLoader = serviceClass.classLoader as? PluginClassLoader
StartUpMeasurer.addCompletedActivity(startTime, serviceClass, getServiceActivityCategory(this), pluginClassLoader?.pluginIdString)
val pluginId = (serviceClass.classLoader as? PluginClassLoader)?.pluginId
initializeComponent(result, null, pluginId)
StartUpMeasurer.addCompletedActivity(startTime, serviceClass, getServiceActivityCategory(this), pluginId?.idString)
return result
}

View File

@@ -56,7 +56,7 @@ internal class ServiceComponentAdapter(val descriptor: ServiceDescriptor,
if (instance is Disposable) {
Disposer.register(componentManager.serviceParentDisposable, instance)
}
componentManager.initializeComponent(instance, descriptor)
componentManager.initializeComponent(instance, descriptor, pluginId)
return instance
}

View File

@@ -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.serviceContainer
import com.intellij.configurationStore.StateStorageManager
@@ -8,6 +8,7 @@ import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.ServiceDescriptor
import com.intellij.openapi.components.impl.stores.IComponentStore
import com.intellij.openapi.extensions.DefaultPluginDescriptor
import com.intellij.openapi.extensions.PluginId
import com.intellij.util.messages.MessageBus
internal val testPluginDescriptor = DefaultPluginDescriptor("test")
@@ -29,7 +30,7 @@ private class TestComponentStore : IComponentStore {
override fun setPath(path: String) {
}
override fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?) {
override fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?, pluginId: PluginId?) {
}
override fun initPersistencePlainComponent(component: Any, key: String) {