Constructor for a PersistentStateComponent


I'm trying to persist settings for a plugin, so I created the following class :

import com.intellij.openapi.components
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.StorageScheme
import com.intellij.util.config.Storage
import com.intellij.util.xmlb.XmlSerializerUtil

        name = "CleverIdeaSettings",
storages = {
            @Storage(id = "other", file = StoragePathMacros.PROJECT_FILE),
            @Storage(id = "dir", file = StoragePathMacros.PROJECT_CONFIG_DIR + "/cleverIdea.xml", scheme = StorageScheme.DIRECTORY_BASED)
public class Settings() : PersistentStateComponent<Settings> {

    override fun getState(): Settings? {
        return this

    override fun loadState(state: Settings?) {
        XmlSerializerUtil.copyBean(state, this)


But IDEA tell me that "@Storage(id = "other", file = StoragePathMacros.PROJECT_FILE)" need a default constructor.

I read the documentation, it tell it too, but I don't really understand what should I implement or where ? Have you an example ? I looked on the Symfony 2 plugin who implement it, but I didn't found a constructor nor what to implement. Can you help me ?

Thank you ! :)

Comment actions Permalink

You have imported the wrong Storage class. You need the one from the com.intellij.openapi.components package.

Comment actions Permalink

Owh, thank you ! Stupid mistake.


Please sign in to leave a comment.