TupleN classes and their usages replaced by Pair and Triple
(KT-2358 Drop tuples) #KT-2358 In Progress
This commit is contained in:
@@ -4,14 +4,14 @@ import java.util.HashMap
|
||||
import java.util.List
|
||||
import java.util.Map
|
||||
|
||||
fun <A, K, V> List<A>.toHashMap(f: (A) -> #(K, V)): Map<K, V> {
|
||||
fun <A, K, V> List<A>.toHashMap(f: (A) -> Pair<K, V>): Map<K, V> {
|
||||
val r = HashMap<K, V>()
|
||||
for (item in this) {
|
||||
val entry = f(item)
|
||||
r.put(entry._1, entry._2)
|
||||
r.put(entry.first, entry.second)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
fun <K, V> List<V>.toHashMapMappingToKey(f: (V) -> K): Map<K, V> = toHashMap { v -> #(f(v), v) }
|
||||
fun <K, V> List<V>.toHashMapMappingToKey(f: (V) -> K): Map<K, V> = toHashMap { v -> Pair(f(v), v) }
|
||||
|
||||
+5
-5
@@ -16,24 +16,24 @@ private fun PsiElement.getAllChildren(): List<PsiElement> {
|
||||
return r.build()
|
||||
}
|
||||
|
||||
private fun splitPsiImpl(psi: PsiElement, listBuilder: ImmutableArrayListBuilder<#(String, PsiElement)>) {
|
||||
private fun splitPsiImpl(psi: PsiElement, listBuilder: ImmutableArrayListBuilder<Pair<String, PsiElement>>) {
|
||||
var lastPos = 0
|
||||
for (child in psi.getAllChildren()) {
|
||||
if (child.getTextChildRelativeOffset() > lastPos) {
|
||||
val text = psi.getText()!!.substring(lastPos, child.getTextChildRelativeOffset())
|
||||
listBuilder.add(#(text, psi))
|
||||
listBuilder.add(Pair(text, psi))
|
||||
}
|
||||
splitPsiImpl(child, listBuilder)
|
||||
lastPos = child.getTextChildRelativeOffset() + child.getTextRange()!!.getLength()
|
||||
}
|
||||
if (lastPos < psi.getTextRange()!!.getLength()) {
|
||||
val text = psi.getText()!!.substring(lastPos)
|
||||
listBuilder.add(#(text, psi))
|
||||
listBuilder.add(Pair(text, psi))
|
||||
}
|
||||
}
|
||||
|
||||
fun splitPsi(psi: PsiElement): List<#(String, PsiElement)> {
|
||||
val listBuilder = listBuilder<#(String, PsiElement)>()
|
||||
fun splitPsi(psi: PsiElement): List<Pair(String, PsiElement)> {
|
||||
val listBuilder = listBuilder<Pair(String, PsiElement)>()
|
||||
splitPsiImpl(psi, listBuilder)
|
||||
return listBuilder.build()
|
||||
}
|
||||
|
||||
@@ -734,13 +734,13 @@ class TemplateLinkRenderer(val annotated: KAnnotated, val template: KDocTemplate
|
||||
// TODO dirty hack - remove when this issue is fixed
|
||||
// http://youtrack.jetbrains.com/issue/KT-1524
|
||||
val hackedLinks = hashMap(
|
||||
#("IllegalArgumentException", #("java.lang", "java/lang/IllegalArgumentException.html")),
|
||||
#("IllegalStateException", #("java.lang", "java/lang/IllegalStateException.html")),
|
||||
#("Map.Entry", #("java.util", "java/util/Map.Entry.html")),
|
||||
#("System.in", #("java.lang", "java/lang/System.html#in")),
|
||||
#("System.out", #("java.lang", "java/lang/System.html#in")),
|
||||
#("#equals()", #("java.lang", "java/lang/Object.html#equals(java.lang.Object)")),
|
||||
#("#hashCode()", #("java.lang", "java/lang/Object.html#hashCode()"))
|
||||
Pair("IllegalArgumentException", Pair("java.lang", "java/lang/IllegalArgumentException.html")),
|
||||
Pair("IllegalStateException", Pair("java.lang", "java/lang/IllegalStateException.html")),
|
||||
Pair("Map.Entry", Pair("java.util", "java/util/Map.Entry.html")),
|
||||
Pair("System.in", Pair("java.lang", "java/lang/System.html#in")),
|
||||
Pair("System.out", Pair("java.lang", "java/lang/System.html#in")),
|
||||
Pair("#equals()", Pair("java.lang", "java/lang/Object.html#equals(java.lang.Object)")),
|
||||
Pair("#hashCode()", Pair("java.lang", "java/lang/Object.html#hashCode()"))
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ abstract class HtmlTemplate() : TextTemplate() {
|
||||
tagName: String,
|
||||
style: String? = null,
|
||||
className: String? = null,
|
||||
attributes: List<#(String, String)> = arrayList(),
|
||||
attributes: List<Pair<String, String>> = arrayList(),
|
||||
content: () -> Unit) {
|
||||
val allAttributesBuilder = listBuilder<#(String, String)>()
|
||||
val allAttributesBuilder = listBuilder<Pair<String, String>>()
|
||||
if (style != null)
|
||||
allAttributesBuilder.add(#("style", style))
|
||||
allAttributesBuilder.add(Pair("style", style))
|
||||
if (className != null)
|
||||
allAttributesBuilder.add(#("class", className))
|
||||
allAttributesBuilder.add(Pair("class", className))
|
||||
|
||||
// TODO: add addAll to ListBuilder
|
||||
for (attribute in attributes)
|
||||
@@ -55,7 +55,7 @@ abstract class HtmlTemplate() : TextTemplate() {
|
||||
fun linkCssStylesheet(href: String) =
|
||||
tag(
|
||||
tagName = "link",
|
||||
attributes = arrayList(#("rel", "stylesheet"), #("type", "text/css"), #("href", href))) {}
|
||||
attributes = arrayList(Pair("rel", "stylesheet"), Pair("type", "text/css"), Pair("href", href))) {}
|
||||
|
||||
fun body(style: String? = null, className: String? = null, content: () -> Unit) =
|
||||
tag(tagName = "body", style = style, className = className, content = content)
|
||||
@@ -79,11 +79,11 @@ 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<#(String, String)>()
|
||||
val attributes = listBuilder<Pair<String, String>>()
|
||||
if (href != null)
|
||||
attributes.add(#("href", href))
|
||||
attributes.add(Pair("href", href))
|
||||
if (name != null)
|
||||
attributes.add(#("name", name))
|
||||
attributes.add(Pair("name", name))
|
||||
tag(tagName = "a", attributes = attributes.build(), content = content)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user