From 0fac1d925b74f24002a4e1538088ce66c4b02cb9 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 30 Jan 2015 19:01:40 +0100 Subject: code review --- src/Formats/StructuredFormatService.kt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/Formats') diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index fe127732..6ec75379 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -98,23 +98,24 @@ public abstract class StructuredFormatService(val locationService: LocationServi appendSectionWithSubject(it.getKey(), location, it.getValue(), to) } - for (section in node.content.sections) { - if (section.subjectName != null) continue - appendLine(to, formatStrong(formatText(section.label))) + for (section in node.content.sections.filter { it.subjectName == null }) { + appendLine(to, formatStrong(formatText(section.tag))) appendLine(to, formatText(location, section)) } } } } - fun appendSectionWithSubject(title: String, location: Location, parameterSections: List, to: StringBuilder) { + fun Content.getSectionsWithSubjects(): Map> = + sections.filter { it.subjectName != null }.groupBy { it.tag } + + fun appendSectionWithSubject(title: String, location: Location, subjectSections: List, to: StringBuilder) { appendHeader(to, title, 3) - parameterSections.forEach { - val parameterName = it.subjectName - if (parameterName != null) { - to.append(formatCode(parameterName)).append(" - ") - val formatted = formatText(location, it) - to.append(formatted) + subjectSections.forEach { + val subjectName = it.subjectName + if (subjectName != null) { + to.append(formatCode(subjectName)).append(" - ") + to.append(formatText(location, it)) appendLine(to) } } -- cgit