fix serialization

This commit is contained in:
Vladimir Krivosheev
2016-06-07 12:11:47 +02:00
parent 175269aa31
commit dc260ec6c6
2 changed files with 11 additions and 12 deletions
+1 -1
View File
@@ -54,6 +54,6 @@
<orderEntry type="library" scope="TEST" name="KotlinTest" level="project" />
<orderEntry type="module" module-name="built-in-server-api" scope="TEST" />
<orderEntry type="module" module-name="configuration-store-impl" scope="TEST" />
<orderEntry type="library" name="memoryfilesystem" level="project" />
<orderEntry type="library" scope="TEST" name="memoryfilesystem" level="project" />
</component>
</module>
@@ -240,14 +240,13 @@ class InspectionProjectProfileManagerImpl(private val project: Project,
}
@Synchronized override fun getState(): Element? {
val state = Element("settings")
val result = Element("settings")
val sortedProfiles = profiles.keys.toTypedArray<String>()
Arrays.sort(sortedProfiles)
for (profile in sortedProfiles) {
val projectProfile = profiles[profile]
if (projectProfile != null) {
val profileElement = ProfileEx.serializeProfile(projectProfile)
profiles.get(profile)?.let {
val profileElement = ProfileEx.serializeProfile(it)
var hasSmthToSave = sortedProfiles.size > 1 || isCustomProfileUsed
if (!hasSmthToSave) {
for (child in profileElement.children) {
@@ -258,22 +257,22 @@ class InspectionProjectProfileManagerImpl(private val project: Project,
}
}
if (hasSmthToSave) {
state.addContent(profileElement)
result.addContent(profileElement)
}
}
}
if (!state.children.isEmpty() || isCustomProfileUsed) {
XmlSerializer.serializeInto(state, state)
state.addContent(Element("version").setAttribute("value", VERSION))
if (!result.children.isEmpty() || isCustomProfileUsed) {
XmlSerializer.serializeInto(this.state, result)
result.addContent(Element("version").setAttribute("value", VERSION))
}
severityRegistrar.writeExternal(state)
return state
severityRegistrar.writeExternal(result)
return result
}
private val isCustomProfileUsed: Boolean
get() = state.projectProfile != null && !Comparing.strEqual(state.projectProfile, PROJECT_DEFAULT_PROFILE_NAME)
get() = state.projectProfile != null && state.projectProfile != PROJECT_DEFAULT_PROFILE_NAME
override fun getProfile(name: String) = getProfile(name, true)