From 5802a6f0ba65ad8ade0bc65b808c0e521b41a4dd Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 12 Apr 2012 15:04:30 +0100 Subject: [PATCH] switched code to use nicer iteration over Map --- .../sandbox/templatelib/src/TemplateHtml.kt | 6 ++---- .../org/jetbrains/kotlin/doc/KDocConfig.kt | 19 +++++++------------ .../doc/templates/PackageFrameTemplate.kt | 4 ++-- .../doc/templates/PackageSummaryTemplate.kt | 12 ++++++------ 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/libraries/sandbox/templatelib/src/TemplateHtml.kt b/libraries/sandbox/templatelib/src/TemplateHtml.kt index 9de7bd3e831..5d34c5cdf14 100644 --- a/libraries/sandbox/templatelib/src/TemplateHtml.kt +++ b/libraries/sandbox/templatelib/src/TemplateHtml.kt @@ -44,10 +44,8 @@ abstract class Tag(val name : String) : Element() { builder.append("<") builder.append(name) if (!attributes.isEmpty()) { - for (e in attributes.entrySet()) { - if (e != null) { - builder.append(" ${e.getKey()}=\"${e.getValue()}\"") - } + for (e in attributes) { + builder.append(" ${e.key}=\"${e.value}\"") } } if (children.isEmpty()) { diff --git a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocConfig.kt b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocConfig.kt index 098b0686795..442d1bc3d16 100644 --- a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocConfig.kt +++ b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocConfig.kt @@ -70,20 +70,15 @@ class KDocConfig() { * Resolves a link to the given class name */ fun resolveLink(packageName: String): String { - // TODO should be able to do something like - // for (e in packageUrls.filterNotNull()) { - val entrySet = packagePrefixToUrls.entrySet() - if (entrySet != null) { - for (e in entrySet) { - val p = e?.getKey() - val url = e?.getValue() - if (p != null && url != null) { - if (packageName.startsWith(p)) { - return url - } + for (e in packagePrefixToUrls) { + val p = e.key + val url = e.value + if (p != null && url != null) { + if (packageName.startsWith(p)) { + return url } } - } + } if (missingPackageUrls.add(packageName)) { println("Warning: could not find external link to package: $packageName") } diff --git a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageFrameTemplate.kt b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageFrameTemplate.kt index 3a5d695eddc..a1cffaf8a75 100644 --- a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageFrameTemplate.kt +++ b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageFrameTemplate.kt @@ -96,8 +96,8 @@ ${stylesheets()} Extensions 
""") - for (e in map.entrySet()) { - val c = e?.getKey() + for (e in map) { + val c = e.key if (c != null) { println("""${c.name}
""") diff --git a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageSummaryTemplate.kt b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageSummaryTemplate.kt index b379bdbde42..b880e16a3ca 100644 --- a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageSummaryTemplate.kt +++ b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageSummaryTemplate.kt @@ -136,9 +136,9 @@ ${pkg.detailedDescription(this)} """) val groupMap = pkg.groupClassMap() - for (e in groupMap.entrySet()) { - val group = e?.getKey() ?: "Other" - val list = e?.getValue() + for (e in groupMap) { + val group = e.key ?: "Other" + val list = e.value if (list != null) { println("""

$group

@@ -275,13 +275,13 @@ Copyright © 2010-2012. All Rights Reserved. Extensions Summary
""") - for (e in map.entrySet()) { - val c = e?.getKey() + for (e in map) { + val c = e.key if (c != null) { println(""" ${c.name} """) - val list = e?.getValue() + val list = e.value if (list != null) { val functions = filterDuplicateNames(list) for (f in functions) {