diff --git a/platform/configuration-store-impl/src/FileBasedStorage.kt b/platform/configuration-store-impl/src/FileBasedStorage.kt index 5ae53956ebfb..e79258927e63 100644 --- a/platform/configuration-store-impl/src/FileBasedStorage.kt +++ b/platform/configuration-store-impl/src/FileBasedStorage.kt @@ -202,12 +202,7 @@ private fun isEqualContent(result: VirtualFile, lineSeparator: LineSeparator, co return false } - for (i in headerLength..oldContent.size - 1) { - if (oldContent[i] != content.internalBuffer[i - headerLength]) { - return false - } - } - return true + return (headerLength..oldContent.size - 1).all { oldContent[it] == content.internalBuffer[it - headerLength] } } private fun doWrite(requestor: Any, file: VirtualFile, content: Any, lineSeparator: LineSeparator, prependXmlProlog: Boolean) { @@ -274,7 +269,7 @@ private fun deleteFile(file: Path, requestor: Any, virtualFile: VirtualFile?) { } } -fun deleteFile(requestor: Any, virtualFile: VirtualFile) { +internal fun deleteFile(requestor: Any, virtualFile: VirtualFile) { runWriteAction { virtualFile.delete(requestor) } } diff --git a/platform/configuration-store-impl/src/XmlElementStorage.kt b/platform/configuration-store-impl/src/XmlElementStorage.kt index ab3cfffef2d0..e89825d1420f 100644 --- a/platform/configuration-store-impl/src/XmlElementStorage.kt +++ b/platform/configuration-store-impl/src/XmlElementStorage.kt @@ -19,9 +19,11 @@ import com.intellij.openapi.components.RoamingType import com.intellij.openapi.components.StateStorage import com.intellij.openapi.components.TrackingPathMacroSubstitutor import com.intellij.openapi.components.impl.stores.FileStorageCoreUtil +import com.intellij.openapi.diagnostic.catchAndLog import com.intellij.openapi.diagnostic.debug import com.intellij.openapi.util.JDOMUtil import com.intellij.util.containers.SmartHashSet +import com.intellij.util.isEmpty import com.intellij.util.loadElement import gnu.trove.THashMap import org.jdom.Attribute @@ -66,7 +68,7 @@ abstract class XmlElementStorage protected constructor(protected val fileSpec: S protected open fun dataLoadedFromProvider(element: Element?) { } - private fun loadDataFromProvider() = provider!!.read(fileSpec, roamingType)?.let { loadElement(it) } + private fun loadDataFromProvider() = provider!!.read(fileSpec, roamingType)?.let(::loadElement) private fun loadState(element: Element): StateMap { beforeElementLoaded(element) @@ -151,12 +153,12 @@ abstract class XmlElementStorage protected constructor(protected val fileSpec: S } protected open fun beforeElementSaved(element: Element) { - if (pathMacroSubstitutor != null) { + pathMacroSubstitutor?.let { try { - pathMacroSubstitutor.collapsePaths(element) + it.collapsePaths(element) } finally { - pathMacroSubstitutor.reset() + it.reset() } } } @@ -171,7 +173,7 @@ abstract class XmlElementStorage protected constructor(protected val fileSpec: S return } - try { + LOG.catchAndLog { val newElement = if (deleted) null else if (streamProvider) loadDataFromProvider() else loadLocalData() val states = storageDataRef.get() if (newElement == null) { @@ -187,9 +189,6 @@ abstract class XmlElementStorage protected constructor(protected val fileSpec: S setStates(states, newStates) } } - catch (e: Throwable) { - LOG.error(e) - } } } @@ -235,7 +234,7 @@ private fun save(states: StateMap, rootElementName: String?, newLiveStates: Map< rootElement.addContent(element) } - return if (JDOMUtil.isEmpty(rootElement)) null else rootElement + return if (rootElement.isEmpty()) null else rootElement } internal fun Element.normalizeRootName(): Element { diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectSettingsBase.java b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectSettingsBase.java index a56d5ef2e163..428b79f71341 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectSettingsBase.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectSettingsBase.java @@ -33,17 +33,17 @@ public class FindInProjectSettingsBase implements PersistentStateComponent findStrings = new ArrayList(); + public List findStrings = new ArrayList<>(); @Tag("replaceStrings") @Property(surroundWithTag = false) @AbstractCollection(surroundWithTag = false, elementTag = "replace", elementValueAttribute = "") - public List replaceStrings = new ArrayList(); + public List replaceStrings = new ArrayList<>(); @Tag("dirStrings") @Property(surroundWithTag = false) @AbstractCollection(surroundWithTag = false, elementTag = "dir", elementValueAttribute = "") - public List dirStrings = new ArrayList(); + public List dirStrings = new ArrayList<>(); @Override public void loadState(FindInProjectSettingsBase state) { @@ -78,7 +78,7 @@ public class FindInProjectSettingsBase implements PersistentStateComponent getRecentDirectories() { - return new ArrayList(dirStrings); + return new ArrayList<>(dirStrings); } public void addStringToFind(@NotNull String s){