Плагин Intellij: невозможно инициализировать исключение состояния компонента

#java #xml #intellij-idea #intellij-plugin

#java #xml #intellij-idea #intellij-плагин

Вопрос:

Я пытаюсь создать плагин Intellij Idea с некоторыми конфигурациями Settings->Tools .

У меня есть ApplicationService возможность сохранить и сохранить эти конфигурации, но при вызове возникает исключение ServiceManager.getService(MyService.class) , и конфигурация не сохраняется при повторном открытии Intellij Idea.

Вот трассировка стека для исключения:

 com.intellij.diagnostic.PluginException: Cannot init  component state [Plugin: org.mycompany.mycompany-plugin]
    at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:116)
    at com.intellij.configurationStore.ComponentStoreWithExtraComponents.initComponent(ComponentStoreWithExtraComponents.kt:50)
    at com.intellij.serviceContainer.ComponentManagerImpl.initializeComponent$intellij_platform_serviceContainer(ComponentManagerImpl.kt:358)
    at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:58)
    at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:41)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:115)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:69)
    at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:411)
    at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:394)
    at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:20)
    at com.mycompany.config.SettingsService.getInstance(SettingsService.java:14)
    at com.mycompany.config.SettingsConfigurable.reset(SettingsConfigurable.java:46)
    at com.intellij.openapi.options.ex.ConfigurableWrapper.reset(ConfigurableWrapper.java:177)
    at com.intellij.openapi.options.ex.ConfigurableCardPanel.reset(ConfigurableCardPanel.java:166)
    at com.intellij.openapi.options.ex.ConfigurableCardPanel.lambda$createConfigurableComponent$4(ConfigurableCardPanel.java:118)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)
    (a lot more lines here)
Caused by: java.lang.UnsupportedOperationException: configurationSchemaKey must be specified for com.mycompany.config.SettingsService
    at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:369)
    at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:100)
    ... 113 more
  

Я не нашел документации об этом «configurationSchemaKey», за исключением того факта, что это параметр ApplicationService XML, но я не смог выяснить, какое значение я должен в него ввести. I.

Вот как я определил службу:

 <applicationService
                serviceImplementation="com.testmycode.config.SettingsService"
                id="com.testmycode.config.SettingsService"/>
  

Чего мне не хватает?

Ответ №1:

configurationSchemaKey свойство является частью ServiceDescriptor и описывается как:

Невозможно указать как часть {@link State}, потому что для получения аннотации класс должен быть загружен, но это невозможно сделать по соображениям производительности.

Однако не принято создавать такую службу для обработки настроек.

Пожалуйста, просмотрите текущую реализацию и следуйте руководству «Введение в настройки» в IntelliJ Platform SDK DevGuide.