mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -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) }
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -33,17 +33,17 @@ public class FindInProjectSettingsBase implements PersistentStateComponent<FindI
|
||||
@Tag("findStrings")
|
||||
@Property(surroundWithTag = false)
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "find", elementValueAttribute = "")
|
||||
public List<String> findStrings = new ArrayList<String>();
|
||||
public List<String> findStrings = new ArrayList<>();
|
||||
|
||||
@Tag("replaceStrings")
|
||||
@Property(surroundWithTag = false)
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "replace", elementValueAttribute = "")
|
||||
public List<String> replaceStrings = new ArrayList<String>();
|
||||
public List<String> replaceStrings = new ArrayList<>();
|
||||
|
||||
@Tag("dirStrings")
|
||||
@Property(surroundWithTag = false)
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "dir", elementValueAttribute = "")
|
||||
public List<String> dirStrings = new ArrayList<String>();
|
||||
public List<String> dirStrings = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void loadState(FindInProjectSettingsBase state) {
|
||||
@@ -78,7 +78,7 @@ public class FindInProjectSettingsBase implements PersistentStateComponent<FindI
|
||||
|
||||
@NotNull
|
||||
public List<String> getRecentDirectories() {
|
||||
return new ArrayList<String>(dirStrings);
|
||||
return new ArrayList<>(dirStrings);
|
||||
}
|
||||
|
||||
public void addStringToFind(@NotNull String s){
|
||||
|
||||
Reference in New Issue
Block a user