3

I created PersistentStateComponent which looks like this

    @State(name = "MyState", storages = [Storage("my_state.xml")])
    class MyStatePersistence : PersistentStateComponent<MyState> {
      ...
    }

and I registered it in plugin.xml:

<extensions defaultExtensionNs="com.intellij">
    <applicationService serviceImplementation="com.example.MyStatePersistence"/>
</extensions>

I can't figure out where is file my_state.xml, which I specified. Is it located in project or what?

lishee loo
  • 57
  • 1
  • 6
  • 1
    The best place for such questions would be https://intellij-support.jetbrains.com/hc/en-us/community/topics/200366979-IntelliJ-IDEA-Open-API-and-Plugin-Development. – CrazyCoder Aug 10 '22 at 17:06
  • For my sandbox IDE I usually find them in `build/idea-sandbox/config/options`. – Abby Aug 11 '22 at 18:01
  • @Abby ok, but if I install plugin on real project, I can't find this file anywhere – lishee loo Aug 12 '22 at 08:02
  • 1
    also I find out that in case of project service state's file is located in .idea directory, but for application service I don't see the file – lishee loo Aug 12 '22 at 08:08
  • On linux they seem to be in `~/.config/JetBrains/IntelliJIdea2022.2/options` (with IJ installed via the Toolbox that is). If it's not there, maybe see if running `find -iname "my_state.xml"` in your home directory can find it? – Abby Aug 12 '22 at 08:31

1 Answers1

0

There are two kind of services, and both store their data in different locations.

  1. A project service stores its xml file in the .idea directory that you find inside the root of the IDE project (or possible module when working with IntelliJ).

  2. An application service stores its xml file in the options directory, which is located in the configuration directory. In the sandbox IDE, this is build/idea-sandbox/config/options.

To summarize, on Linux, you can find the my_state.xml in ~/.config/JetBrains/IntelliJIdea2022.2/options (for the latest IntelliJ version).


For similar situations in the future (on Linux) you could find the file by running find . -name "my_state.xml" in your home directory.

Abby
  • 1,610
  • 3
  • 19
  • 35