How to change storage for PersistentStateComponent

I used PersistentStateComponent like this:

 

@State(
name = "Configurator",
storages = {
@Storage(id = "default", file = StoragePathMacros.PROJECT_FILE, scheme = StorageScheme.DEFAULT),
@Storage(id = "dir",
file = StoragePathMacros.PROJECT_CONFIG_DIR + "/JHelper.xml",
scheme = StorageScheme.DIRECTORY_BASED)
}
)
public class Configurator extends AbstractProjectComponent implements PersistentStateComponent<Configurator.State> {
...
}

Now I am getting warnings that PROJECT_FILE and PROJECT_CONFIG_DIR are now deprecated.

I'd like to rewrite it to the new scheme, so that 

1) everything is stored on per-project basis.

I read docs here

I think I just need

@Storage("filename")

if I need specific file or just leave storages in @State empty if I don't care.

Is that correct?

2) (this is the main question) after I change it, people don't lose settings in the plugin.

How do I do that?

0

These are commented in the code as "Not required anymore" so it would seem that they are ignored if present.

On the other hand if you remove the deprecated directives it will not work with older IDEs that do require them. I discovered that when my plugin failed to save settings in an older version of the IDE.

 

0

请先登录再写评论。