Collect deprecated code, remove unused private ImmutableArrayList

This commit is contained in:
Ilya Ryzhenkov
2014-12-01 16:47:44 +03:00
parent 31fb24d390
commit fbbb7eced1
10 changed files with 39 additions and 203 deletions
@@ -6,16 +6,16 @@ private fun PsiElement.getTextChildRelativeOffset() =
getTextRange()!!.getStartOffset() - getParent()!!.getTextRange()!!.getStartOffset()
private fun PsiElement.getAllChildren(): List<PsiElement> {
val r = listBuilder<PsiElement>()
val r = arrayListOf<PsiElement>()
var child = getFirstChild()
while (child != null) {
r.add(child!!)
child = child!!.getNextSibling()
}
return r.build()
return r
}
private fun splitPsiImpl(psi: PsiElement, listBuilder: ImmutableArrayListBuilder<Pair<String, PsiElement>>) {
private fun splitPsiImpl(psi: PsiElement, listBuilder: MutableList<Pair<String, PsiElement>>) {
var lastPos = 0
for (child in psi.getAllChildren()) {
if (child.getTextChildRelativeOffset() > lastPos) {
@@ -32,9 +32,9 @@ private fun splitPsiImpl(psi: PsiElement, listBuilder: ImmutableArrayListBuilder
}
fun splitPsi(psi: PsiElement): List<Pair<String, PsiElement>> {
val listBuilder = listBuilder<Pair<String, PsiElement>>()
val listBuilder = arrayListOf<Pair<String, PsiElement>>()
splitPsiImpl(psi, listBuilder)
return listBuilder.build()
return listBuilder
}
@@ -8,17 +8,13 @@ abstract class HtmlTemplate() : TextTemplate() {
className: String? = null,
attributes: List<Pair<String, String>> = listOf(),
content: () -> Unit) {
val allAttributesBuilder = listBuilder<Pair<String, String>>()
val allAttributes = arrayListOf<Pair<String, String>>()
if (style != null)
allAttributesBuilder.add(Pair<String, String>("style", style))
allAttributes.add(Pair("style", style))
if (className != null)
allAttributesBuilder.add(Pair<String, String>("class", className))
allAttributes.add(Pair("class", className))
// TODO: add addAll to ListBuilder
for (attribute in attributes)
allAttributesBuilder.add(attribute)
val allAttributes = allAttributesBuilder.build()
allAttributes.addAll(attributes)
print(
if (allAttributes.isEmpty()) {
@@ -77,12 +73,12 @@ abstract class HtmlTemplate() : TextTemplate() {
tag(tagName = "span", style = style, className = className, content = content)
fun a(href: String? = null, name: String? = null, content: () -> Unit) {
val attributes = listBuilder<Pair<String, String>>()
val attributes = arrayListOf<Pair<String, String>>()
if (href != null)
attributes.add(Pair<String, String>("href", href))
attributes.add(Pair("href", href))
if (name != null)
attributes.add(Pair<String, String>("name", name))
tag(tagName = "a", attributes = attributes.build(), content = content)
attributes.add(Pair("name", name))
tag(tagName = "a", attributes = attributes, content = content)
}
}