mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remove extra not required runAndLogException
This commit is contained in:
@@ -97,9 +97,7 @@ abstract class ProjectStoreBase(final override val project: Project) : Component
|
||||
normalizeDefaultProjectElement(defaultProject, element, Paths.get(storageManager.expandMacro(PROJECT_CONFIG_DIR)))
|
||||
}
|
||||
else {
|
||||
LOG.runAndLogException {
|
||||
moveComponentConfiguration(defaultProject, element) { if (it == "workspace.xml") Paths.get(workspaceFilePath) else Paths.get(projectFilePath) }
|
||||
}
|
||||
moveComponentConfiguration(defaultProject, element) { if (it == "workspace.xml") Paths.get(workspaceFilePath) else Paths.get(projectFilePath) }
|
||||
}
|
||||
}
|
||||
(storageManager.getOrCreateStorage(PROJECT_FILE) as XmlElementStorage).setDefaultState(element)
|
||||
|
||||
@@ -21,53 +21,54 @@ import java.nio.file.Path
|
||||
|
||||
internal fun normalizeDefaultProjectElement(defaultProject: Project, element: Element, projectConfigDir: Path) {
|
||||
LOG.runAndLogException {
|
||||
moveComponentConfiguration(defaultProject, element) { projectConfigDir.resolve(it)}
|
||||
moveComponentConfiguration(defaultProject, element) { projectConfigDir.resolve(it) }
|
||||
}
|
||||
|
||||
LOG.runAndLogException {
|
||||
val iterator = element.getChildren("component").iterator()
|
||||
for (component in iterator) {
|
||||
val componentName = component.getAttributeValue("name")
|
||||
val iterator = element.getChildren("component").iterator()
|
||||
for (component in iterator) {
|
||||
val componentName = component.getAttributeValue("name")
|
||||
|
||||
fun writeProfileSettings(schemeDir: Path) {
|
||||
component.removeAttribute("name")
|
||||
if (!component.isEmpty()) {
|
||||
val wrapper = Element("component").setAttribute("name", componentName)
|
||||
component.name = "settings"
|
||||
wrapper.addContent(component)
|
||||
|
||||
val file = schemeDir.resolve("profiles_settings.xml")
|
||||
if (file.fileSystem == FileSystems.getDefault()) {
|
||||
// VFS must be used to write workspace.xml and misc.xml to ensure that project files will be not reloaded on external file change event
|
||||
writeFile(file, fakeSaveSession, null, createDataWriterForElement(wrapper, "default project"), LineSeparator.LF, prependXmlProlog = false)
|
||||
}
|
||||
else {
|
||||
file.outputStream().use {
|
||||
wrapper.write(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
fun writeProfileSettings(schemeDir: Path) {
|
||||
component.removeAttribute("name")
|
||||
if (component.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
when (componentName) {
|
||||
"InspectionProjectProfileManager" -> {
|
||||
iterator.remove()
|
||||
val schemeDir = projectConfigDir.resolve("inspectionProfiles")
|
||||
convertProfiles(component.getChildren("profile").iterator(), componentName, schemeDir)
|
||||
component.removeChild("version")
|
||||
writeProfileSettings(schemeDir)
|
||||
}
|
||||
val wrapper = Element("component").setAttribute("name", componentName)
|
||||
component.name = "settings"
|
||||
wrapper.addContent(component)
|
||||
|
||||
"CopyrightManager" -> {
|
||||
iterator.remove()
|
||||
val schemeDir = projectConfigDir.resolve("copyright")
|
||||
convertProfiles(component.getChildren("copyright").iterator(), componentName, schemeDir)
|
||||
writeProfileSettings(schemeDir)
|
||||
val file = schemeDir.resolve("profiles_settings.xml")
|
||||
if (file.fileSystem == FileSystems.getDefault()) {
|
||||
// VFS must be used to write workspace.xml and misc.xml to ensure that project files will be not reloaded on external file change event
|
||||
writeFile(file, fakeSaveSession, null, createDataWriterForElement(wrapper, "default project"), LineSeparator.LF,
|
||||
prependXmlProlog = false)
|
||||
}
|
||||
else {
|
||||
file.outputStream().use {
|
||||
wrapper.write(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModuleManagerImpl.COMPONENT_NAME -> {
|
||||
iterator.remove()
|
||||
}
|
||||
when (componentName) {
|
||||
"InspectionProjectProfileManager" -> {
|
||||
iterator.remove()
|
||||
val schemeDir = projectConfigDir.resolve("inspectionProfiles")
|
||||
convertProfiles(component.getChildren("profile").iterator(), componentName, schemeDir)
|
||||
component.removeChild("version")
|
||||
writeProfileSettings(schemeDir)
|
||||
}
|
||||
|
||||
"CopyrightManager" -> {
|
||||
iterator.remove()
|
||||
val schemeDir = projectConfigDir.resolve("copyright")
|
||||
convertProfiles(component.getChildren("copyright").iterator(), componentName, schemeDir)
|
||||
writeProfileSettings(schemeDir)
|
||||
}
|
||||
|
||||
ModuleManagerImpl.COMPONENT_NAME -> {
|
||||
iterator.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
@@ -54,7 +54,7 @@ fun loadElement(stream: InputStream): Element = JDOMUtil.load(stream)
|
||||
@Throws(IOException::class, JDOMException::class)
|
||||
fun loadElement(path: Path): Element = JDOMUtil.load(path.inputStream())
|
||||
|
||||
fun Element?.isEmpty(): Boolean = this == null || JDOMUtil.isEmpty(this)
|
||||
fun Element?.isEmpty() = this == null || JDOMUtil.isEmpty(this)
|
||||
|
||||
fun Element.getOrCreate(name: String): Element {
|
||||
var element = getChild(name)
|
||||
|
||||
Reference in New Issue
Block a user