Constructor for a PersistentStateComponent

Hi,

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.StoragePathMacros
import com.intellij.openapi.components.StorageScheme
import com.intellij.util.config.Storage
import com.intellij.util.xmlb.XmlSerializerUtil

@State(
        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 ! :)

2 comments
Comment actions Permalink

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

1
Comment actions Permalink

Owh, thank you ! Stupid mistake.

0

Please sign in to leave a comment.