Skip to content

Commit 185db37

Browse files
committed
Fix NeptuneModuleData not saving in modules file
1 parent da1a808 commit 185db37

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/main/kotlin/io/runescript/plugin/ide/neptune/NeptuneModuleData.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@ import com.intellij.openapi.components.*
44
import com.intellij.openapi.module.Module
55
import com.intellij.openapi.module.ModuleUtil
66
import com.intellij.psi.PsiElement
7-
import com.intellij.util.xmlb.XmlSerializerUtil
87

98
@State(
109
name = "NeptuneModuleData",
1110
storages = [Storage(StoragePathMacros.MODULE_FILE)]
1211
)
13-
class NeptuneModuleData : PersistentStateComponent<NeptuneModuleData> {
12+
class NeptuneModuleData : SerializablePersistentStateComponent<NeptuneModuleData.State>(State()) {
1413

15-
override fun getState() = this
14+
data class State(
15+
var dummy: Int = 0
16+
)
1617

17-
override fun loadState(state: NeptuneModuleData) {
18-
XmlSerializerUtil.copyBean(state, this)
19-
}
20-
21-
fun updateFromImportData(@Suppress("unused") importData: NeptuneProjectImportData) {
18+
val dummy: Int
19+
get() = state.dummy
2220

21+
fun updateFromImportData(importData: NeptuneProjectImportData) = updateState {
22+
it.dummy = 0
23+
it
2324
}
2425
}
2526

26-
val Module.neptuneModuleData: NeptuneModuleData?
27+
val Module.neptuneModuleData: NeptuneModuleData
2728
get() = service<NeptuneModuleData>()
2829

2930
val PsiElement.neptuneModuleData: NeptuneModuleData?
30-
get() = ModuleUtil.findModuleForFile(containingFile)?.neptuneModuleData
31+
get() = ModuleUtil.findModuleForFile(containingFile)?.neptuneModuleData

0 commit comments

Comments
 (0)