Persistent state storage throwing IllegalArgumentException while using StoragePathMacros.WORKSPACE_FILE

I'm trying to implement persistent storage for my plugin, and after following the tutorial on persisting state I am getting this error when launching my plugin. Is there some dependency I am missing? I tried googling this error message looking for an easy fix, but I have been unsuccessful.

 

@State(name = "SpSettings",
storages = { @Storage(StoragePathMacros.WORKSPACE_FILE) })
[ 12457] ERROR - rationStore.ComponentStoreImpl - IntelliJ IDEA 2016.1.3 Build #IC-145.1617.8 
[ 12457] ERROR - rationStore.ComponentStoreImpl - JDK: 1.8.0_60
[ 12457] ERROR - rationStore.ComponentStoreImpl - VM: Java HotSpot(TM) 64-Bit Server VM
[ 12457] ERROR - rationStore.ComponentStoreImpl - Vendor: Oracle Corporation
[ 12457] ERROR - rationStore.ComponentStoreImpl - OS: Windows 10
[ 12457] ERROR - rationStore.ComponentStoreImpl - Last Action: ShowSettings
[ 20454] WARN - mponents.impl.stores.StoreUtil - Save settings failed
java.lang.IllegalArgumentException: Unknown macro: $WORKSPACE_FILE$ in storage file spec: $WORKSPACE_FILE$
at com.intellij.configurationStore.StateStorageManagerImpl.expandMacros(StateStorageManagerImpl.kt:309)
at com.intellij.configurationStore.ApplicationStorageManager.expandMacros(ApplicationStoreImpl.kt:110)
at com.intellij.configurationStore.StateStorageManagerImpl.createStateStorage(StateStorageManagerImpl.kt:200)
at com.intellij.configurationStore.StateStorageManagerImpl.getOrCreateStorage(StateStorageManagerImpl.kt:153)
at com.intellij.configurationStore.StateStorageManagerImpl.getStateStorage(StateStorageManagerImpl.kt:135)
at com.intellij.configurationStore.StateStorageManagerImpl$startExternalization$1.setState(StateStorageManagerImpl.kt:348)
at com.intellij.configurationStore.ComponentStoreImpl.commitComponent(ComponentStoreImpl.kt:201)
at com.intellij.configurationStore.ComponentStoreImpl.save(ComponentStoreImpl.kt:130)
at com.intellij.openapi.components.impl.stores.StoreUtil.save(StoreUtil.java:49)
at com.intellij.openapi.application.impl.ApplicationImpl.saveSettings(ApplicationImpl.java:1438)
at com.intellij.openapi.application.impl.ApplicationImpl.doExit(ApplicationImpl.java:852)
at com.intellij.openapi.application.impl.ApplicationImpl.access$1000(ApplicationImpl.java:92)
at com.intellij.openapi.application.impl.ApplicationImpl$16.run(ApplicationImpl.java:834)
at com.intellij.openapi.application.impl.ApplicationImpl.exit(ApplicationImpl.java:840)
at com.intellij.openapi.application.impl.ApplicationImpl.exit(ApplicationImpl.java:789)
at com.intellij.openapi.application.impl.ApplicationImpl.exit(ApplicationImpl.java:784)
at com.intellij.openapi.wm.impl.IdeFrameImpl$5$1.run(IdeFrameImpl.java:273)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:345)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:329)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:857)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:658)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
4 comments
Comment actions Permalink

After migrating my plugin away from the deprecated, StoragePathMacros.APP_CONFIG, I also have been receiving this error. According to the inline documentation on the StoragePathMacros.WORKSPACE_FILE, it appears to allow for an application-level persistent component storage:

Workspace file key.

'Workspace file' holds settings that are local to a particular environment and should not be shared with another team members.

@NonNls @NotNull public static final String WORKSPACE_FILE = "$WORKSPACE_FILE$";

private StoragePathMacros() {
}
0
Comment actions Permalink

> According to the inline documentation on the StoragePathMacros.WORKSPACE_FILE, it appears to allow for an application-level persistent component storage:

 

No. In the javadocs stated  `{@link Project#getWorkspaceFile() Workspace} file key.` It means that it can be used only for project components, not for application. We will improve javadocs.

0
Comment actions Permalink

So in my use-case, I should be using the com.intellij.ide.util.PropertiesComponent service? Is that the standard method to persist state for language plugins?

0
Comment actions Permalink

Please see example — https://github.com/JetBrains/intellij-community/blob/master/platform/projectModel-api/src/com/intellij/openapi/components/Storage.java#L39 — `@Storage("yourName.xml")` 

 

If your configuration is per-machine only and should not be shared (using settings-repository plugin), then specify roaming type `DISABLED`.

0

Please sign in to leave a comment.