From 3ac5477ae920ad02a0c947fd6f452f7f711c8b33 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Sat, 13 Jun 2026 09:44:10 -0400 Subject: [PATCH 1/5] Run missing formatting --- .../main/java/com/facebook/ktfmt/cli/Main.kt | 3 +- .../java/com/facebook/ktfmt/cli/ParsedArgs.kt | 9 +- .../com/facebook/ktfmt/format/Formatter.kt | 3 +- .../com/facebook/ktfmt/format/KotlinInput.kt | 6 +- .../ktfmt/format/KotlinInputAstVisitor.kt | 76 +- .../ktfmt/format/MultilineStringFormatter.kt | 6 +- .../com/facebook/ktfmt/format/ParseError.kt | 3 +- .../ktfmt/format/RedundantElementManager.kt | 6 +- .../format/RedundantSemicolonDetector.kt | 18 +- .../facebook/ktfmt/kdoc/KDocCommentsHelper.kt | 3 +- .../ktfmt/kdoc/KDocFormattingOptions.kt | 3 +- .../java/com/facebook/ktfmt/kdoc/Paragraph.kt | 42 +- .../ktfmt/kdoc/ParagraphListBuilder.kt | 149 ++-- .../java/com/facebook/ktfmt/kdoc/Table.kt | 22 +- .../ktfmt/cli/EditorConfigResolverTest.kt | 48 +- .../com/facebook/ktfmt/cli/ParsedArgsTest.kt | 9 +- .../facebook/ktfmt/format/FormatterTest.kt | 735 ++++++------------ .../format/GoogleStyleFormatterKtTest.kt | 3 +- .../format/MultilineStringFormatterTest.kt | 124 ++- .../ktfmt/format/WhitespaceTombstonesTest.kt | 6 +- .../com/facebook/ktfmt/kdoc/DokkaVerifier.kt | 7 +- .../com/facebook/ktfmt/testutil/KtfmtTruth.kt | 12 +- 22 files changed, 465 insertions(+), 828 deletions(-) diff --git a/core/src/main/java/com/facebook/ktfmt/cli/Main.kt b/core/src/main/java/com/facebook/ktfmt/cli/Main.kt index f026772b..8f86798b 100644 --- a/core/src/main/java/com/facebook/ktfmt/cli/Main.kt +++ b/core/src/main/java/com/facebook/ktfmt/cli/Main.kt @@ -73,8 +73,7 @@ class Main( result.addAll( File(arg).walkTopDown().filter { it.isFile && (it.extension == "kt" || it.extension == "kts") - } - ) + }) } return result } diff --git a/core/src/main/java/com/facebook/ktfmt/cli/ParsedArgs.kt b/core/src/main/java/com/facebook/ktfmt/cli/ParsedArgs.kt index 949dd57a..bd0e524a 100644 --- a/core/src/main/java/com/facebook/ktfmt/cli/ParsedArgs.kt +++ b/core/src/main/java/com/facebook/ktfmt/cli/ParsedArgs.kt @@ -134,8 +134,7 @@ data class ParsedArgs( stdinName = parseKeyValueArg("--stdin-name", arg) ?: return ParseResult.Error( - "Found option '${arg}', expected '${"--stdin-name"}='" - ) + "Found option '${arg}', expected '${"--stdin-name"}='") arg.startsWith("--") -> return ParseResult.Error("Unexpected option: $arg") arg.startsWith("@") -> return ParseResult.Error("Unexpected option: $arg") else -> fileNames.add(arg) @@ -148,8 +147,7 @@ data class ParsedArgs( val filesExceptStdin = fileNames - "-" return ParseResult.Error( "Cannot read from stdin and files in same run. Found stdin specifier '-'" + - " and files ${filesExceptStdin.joinToString(", ")} " - ) + " and files ${filesExceptStdin.joinToString(", ")} ") } } else if (stdinName != null) { return ParseResult.Error("--stdin-name can only be specified when reading from stdin") @@ -164,8 +162,7 @@ data class ParsedArgs( stdinName, editorConfig, quiet, - ) - ) + )) } private fun parseKeyValueArg(key: String, arg: String): String? { diff --git a/core/src/main/java/com/facebook/ktfmt/format/Formatter.kt b/core/src/main/java/com/facebook/ktfmt/format/Formatter.kt index 24864b5a..11f140f2 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/Formatter.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/Formatter.kt @@ -133,8 +133,7 @@ object Formatter { val tokenRangeSet = kotlinInput.characterRangesToTokenRanges(ImmutableList.of(Range.closedOpen(0, code.length))) return WhitespaceTombstones.replaceTombstoneWithTrailingWhitespace( - JavaOutput.applyReplacements(code, javaOutput.getFormatReplacements(tokenRangeSet)) - ) + JavaOutput.applyReplacements(code, javaOutput.getFormatReplacements(tokenRangeSet))) } private fun createAstVisitor(options: FormattingOptions, builder: OpsBuilder): PsiElementVisitor { diff --git a/core/src/main/java/com/facebook/ktfmt/format/KotlinInput.kt b/core/src/main/java/com/facebook/ktfmt/format/KotlinInput.kt index b559ef1a..49565b70 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/KotlinInput.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/KotlinInput.kt @@ -84,8 +84,7 @@ class KotlinInput(private val text: String, file: KtFile) : Input() { characterRangeToTokenRange( characterRange.lowerEndpoint(), characterRange.upperEndpoint() - characterRange.lowerEndpoint(), - ) - ) + )) } return tokenRangeSet } @@ -107,8 +106,7 @@ class KotlinInput(private val text: String, file: KtFile) : Input() { "error: invalid length %d, offset + length (%d) is outside the file", length, requiredLength, - ) - ) + )) } val expandedLength = when { diff --git a/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt b/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt index ed52de53..c6e1d32e 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt @@ -665,10 +665,8 @@ class KotlinInputAstVisitor( (receiverExpression as? KtQualifiedExpression)?.selectorExpression ?: receiverExpression val current = checkNotNull(part.selectorExpression) - if ( - lastIndexToOpen == 0 && - shouldGroupPartWithPrevious(parts, part, index, previous, current) - ) { + if (lastIndexToOpen == 0 && + shouldGroupPartWithPrevious(parts, part, index, previous, current)) { // this and the previous items should be grouped for better style // we add another group to open in index 0 groupingInfos[0].groupOpenCount++ @@ -712,27 +710,21 @@ class KotlinInputAstVisitor( return true } // this and the previous part are a package name, type name, or property - if ( - previous is KtSimpleNameExpression && - current is KtSimpleNameExpression && - part is KtDotQualifiedExpression - ) { + if (previous is KtSimpleNameExpression && + current is KtSimpleNameExpression && + part is KtDotQualifiedExpression) { return true } // this is `Foo` in `com.facebook.Foo`, so everything before it is a package name - if ( - current.text.first().isUpperCase() && - current is KtSimpleNameExpression && - part is KtDotQualifiedExpression - ) { + if (current.text.first().isUpperCase() && + current is KtSimpleNameExpression && + part is KtDotQualifiedExpression) { return true } // this is the `foo()` in `com.facebook.Foo.foo()` or in `Foo.foo()` - if ( - current is KtCallExpression && - (previous !is KtCallExpression) && - previous.text?.firstOrNull()?.isUpperCase() == true - ) { + if (current is KtCallExpression && + (previous !is KtCallExpression) && + previous.text?.firstOrNull()?.isUpperCase() == true) { return true } // this is an invocation and the last item, and the previous it not, i.e. `a.b.c()` @@ -935,12 +927,10 @@ class KotlinInputAstVisitor( val shouldForceMultiline = options.preserveLambdaBreaks && hasSourceNewlineInLambdaBody(lambdaExpression) - if ( - !shouldForceMultiline && - expressionStatements.size == 1 && - expressionStatements.first() !is KtReturnExpression && - !bodyExpression.startsWithComment() - ) { + if (!shouldForceMultiline && + expressionStatements.size == 1 && + expressionStatements.first() !is KtReturnExpression && + !bodyExpression.startsWithComment()) { visitStatement(expressionStatements[0]) } else { visitStatements(expressionStatements) @@ -1315,10 +1305,8 @@ class KotlinInputAstVisitor( val operator = expression.operationReference.text visit(baseExpression) - if ( - baseExpression is KtPostfixExpression && - baseExpression.operationReference.text.last() == operator.first() - ) { + if (baseExpression is KtPostfixExpression && + baseExpression.operationReference.text.last() == operator.first()) { builder.space() } builder.token(operator) @@ -1332,10 +1320,8 @@ class KotlinInputAstVisitor( val operator = expression.operationReference.text builder.token(operator) - if ( - baseExpression is KtPrefixExpression && - operator.last() == baseExpression.operationReference.text.first() - ) { + if (baseExpression is KtPrefixExpression && + operator.last() == baseExpression.operationReference.text.first()) { builder.space() } visit(baseExpression) @@ -1591,11 +1577,9 @@ class KotlinInputAstVisitor( carry = carry.selectorExpression } if (carry is KtCallExpression) { - if ( - carry.valueArgumentList?.leftParenthesis == null && - carry.lambdaArguments.isNotEmpty() && - carry.typeArgumentList?.arguments.isNullOrEmpty() - ) { + if (carry.valueArgumentList?.leftParenthesis == null && + carry.lambdaArguments.isNotEmpty() && + carry.typeArgumentList?.arguments.isNullOrEmpty()) { carry = carry.lambdaArguments[0].getArgumentExpression() } else { return false @@ -2526,11 +2510,9 @@ class KotlinInputAstVisitor( visit(expression.leftHandSide) if (!openGroupBeforeLeft) builder.open(ZERO) val parent = expression.parent - if ( - parent is KtValueArgument || - parent is KtParenthesizedExpression || - parent is KtContainerNode - ) { + if (parent is KtValueArgument || + parent is KtParenthesizedExpression || + parent is KtContainerNode) { builder.breakOp(Doc.FillMode.UNIFIED, " ", expressionBreakIndent) } else { builder.space() @@ -2693,8 +2675,7 @@ class KotlinInputAstVisitor( child is PsiComment -> continue child is KtScript && importListEmpty -> OpsBuilder.BlankLineWanted.PRESERVE else -> OpsBuilder.BlankLineWanted.YES - } - ) + }) visit(child) isFirst = false @@ -2717,9 +2698,8 @@ class KotlinInputAstVisitor( builder.blankLineWanted(OpsBuilder.BlankLineWanted.PRESERVE) } else if (lastChildIsContextReceiver) { builder.blankLineWanted(OpsBuilder.BlankLineWanted.NO) - } else if ( - child !is PsiComment && (childGetsBlankLineBefore || lastChildHadBlankLineBefore) - ) { + } else if (child !is PsiComment && + (childGetsBlankLineBefore || lastChildHadBlankLineBefore)) { builder.blankLineWanted(OpsBuilder.BlankLineWanted.YES) } visit(child) diff --git a/core/src/main/java/com/facebook/ktfmt/format/MultilineStringFormatter.kt b/core/src/main/java/com/facebook/ktfmt/format/MultilineStringFormatter.kt index b9079b1b..653c8f02 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/MultilineStringFormatter.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/MultilineStringFormatter.kt @@ -152,12 +152,10 @@ class MultilineStringFormatter(val continuationIndentSize: Int) { expression.getParentOfType(strict = false) != null, commentsBetweenStringAndTrimCall = comments, - ) - ) + )) } } - } - ) + }) return strings.toList() } } diff --git a/core/src/main/java/com/facebook/ktfmt/format/ParseError.kt b/core/src/main/java/com/facebook/ktfmt/format/ParseError.kt index daaba540..6c19b524 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/ParseError.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/ParseError.kt @@ -21,8 +21,7 @@ import org.jetbrains.kotlin.com.intellij.psi.PsiElement class ParseError(val errorDescription: String, val lineColumn: LineColumn) : IllegalArgumentException( - "${lineColumn.line + 1}:${lineColumn.column + 1}: error: $errorDescription" - ) { + "${lineColumn.line + 1}:${lineColumn.column + 1}: error: $errorDescription") { constructor( errorDescription: String, diff --git a/core/src/main/java/com/facebook/ktfmt/format/RedundantElementManager.kt b/core/src/main/java/com/facebook/ktfmt/format/RedundantElementManager.kt index d05863d8..3930a8c9 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/RedundantElementManager.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/RedundantElementManager.kt @@ -69,8 +69,7 @@ object RedundantElementManager { redundantImportDetector.takeReferenceExpression(expression) super.visitReferenceExpression(expression) } - } - ) + }) val elementsToRemove = redundantSemicolonDetector.getRedundantSemicolonElements() + @@ -107,8 +106,7 @@ object RedundantElementManager { trailingCommaSuggestor.takeElement(element) super.visitElement(element) } - } - ) + }) val suggestionElements = trailingCommaSuggestor.getTrailingCommaSuggestions() if (suggestionElements.isEmpty()) return code diff --git a/core/src/main/java/com/facebook/ktfmt/format/RedundantSemicolonDetector.kt b/core/src/main/java/com/facebook/ktfmt/format/RedundantSemicolonDetector.kt index d4c54cee..76a2d058 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/RedundantSemicolonDetector.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/RedundantSemicolonDetector.kt @@ -69,12 +69,10 @@ internal class RedundantSemicolonDetector { val prevConcreteSibling = element.getPrevSiblingIgnoringWhitespaceAndComments() if (parent is KtClassBody) { - if ( - prevConcreteSibling is KtObjectDeclaration && - prevConcreteSibling.isCompanion() && - prevConcreteSibling.nameIdentifier == null && - !isLastConcreteChild(element) - ) { + if (prevConcreteSibling is KtObjectDeclaration && + prevConcreteSibling.isCompanion() && + prevConcreteSibling.nameIdentifier == null && + !isLastConcreteChild(element)) { // Example: `class Foo { companion object ; init { } }` return false } @@ -85,11 +83,9 @@ internal class RedundantSemicolonDetector { } val prevLeaf = element.prevLeaf(false) - if ( - (prevConcreteSibling is KtIfExpression || prevConcreteSibling is KtWhileExpression) && - prevLeaf is KtContainerNodeForControlStructureBody && - prevLeaf.text.isEmpty() - ) { + if ((prevConcreteSibling is KtIfExpression || prevConcreteSibling is KtWhileExpression) && + prevLeaf is KtContainerNodeForControlStructureBody && + prevLeaf.text.isEmpty()) { return false } diff --git a/core/src/main/java/com/facebook/ktfmt/kdoc/KDocCommentsHelper.kt b/core/src/main/java/com/facebook/ktfmt/kdoc/KDocCommentsHelper.kt index e04bd118..313efb52 100644 --- a/core/src/main/java/com/facebook/ktfmt/kdoc/KDocCommentsHelper.kt +++ b/core/src/main/java/com/facebook/ktfmt/kdoc/KDocCommentsHelper.kt @@ -54,8 +54,7 @@ class KDocCommentsHelper(private val lineSeparator: String, private val maxLineL convertMarkup = false nestedListIndent = 4 optimal = false // Use greedy line breaking for predictability. - } - ) + }) override fun rewrite(tok: Tok, maxWidth: Int, column0: Int): String { if (!tok.isComment) { diff --git a/core/src/main/java/com/facebook/ktfmt/kdoc/KDocFormattingOptions.kt b/core/src/main/java/com/facebook/ktfmt/kdoc/KDocFormattingOptions.kt index 2784d1d0..91034910 100644 --- a/core/src/main/java/com/facebook/ktfmt/kdoc/KDocFormattingOptions.kt +++ b/core/src/main/java/com/facebook/ktfmt/kdoc/KDocFormattingOptions.kt @@ -69,8 +69,7 @@ class KDocFormattingOptions( if (value < 3) { error( "Nested list indent must be at least 3; if list items are only indented 2 spaces they " + - "will not be rendered as list items" - ) + "will not be rendered as list items") } field = value } diff --git a/core/src/main/java/com/facebook/ktfmt/kdoc/Paragraph.kt b/core/src/main/java/com/facebook/ktfmt/kdoc/Paragraph.kt index 2a0337ad..6ca1b8dc 100644 --- a/core/src/main/java/com/facebook/ktfmt/kdoc/Paragraph.kt +++ b/core/src/main/java/com/facebook/ktfmt/kdoc/Paragraph.kt @@ -249,12 +249,10 @@ class Paragraph(private val task: FormattingTask) { sb.append(']') i = end + 1 continue - } else if ( - s.startsWith("@link", i, true) - // @linkplain is similar to @link, but kdoc does *not* render a [symbol] - // into a {@linkplain} in HTML, so converting these would change the output. - && !s.startsWith("@linkplain", i, true) - ) { + } else if (s.startsWith("@link", i, true) + // @linkplain is similar to @link, but kdoc does *not* render a [symbol] + // into a {@linkplain} in HTML, so converting these would change the output. + && !s.startsWith("@linkplain", i, true)) { // {@link} or {@linkplain} sb.append('[') var curr = i + 5 @@ -346,13 +344,11 @@ class Paragraph(private val task: FormattingTask) { } private fun reflow(words: List, lineWidth: Int, hangingIndentSize: Int): List { - if ( - options.alternate || - !options.optimal || - (hanging && hangingIndentSize > 0) || - // An unbreakable long word may make other lines shorter and won't look good - words.any { it.length > lineWidth } - ) { + if (options.alternate || + !options.optimal || + (hanging && hangingIndentSize > 0) || + // An unbreakable long word may make other lines shorter and won't look good + words.any { it.length > lineWidth }) { // Switch to greedy if explicitly turned on, and for hanging indent // paragraphs, since the current implementation doesn't have support // for a different maximum length on the first line from the rest @@ -390,10 +386,8 @@ class Paragraph(private val task: FormattingTask) { val newLines = reflowOptimal(lineWidth - hangingIndentSize, words.subList(0, lastWord)) if (newLines.size < lines.size) { val newLongestLine = newLines.maxOf(maxLine) - if ( - newLongestLine > longestLine && - newLines.subList(0, newLines.size - 1).any { it.length > longestLine } - ) { + if (newLongestLine > longestLine && + newLines.subList(0, newLines.size - 1).any { it.length > longestLine }) { return newLines + reflowGreedy( lineWidth - hangingIndentSize, @@ -422,14 +416,12 @@ class Paragraph(private val task: FormattingTask) { // Can we start a new line with this without interpreting it in a special // way? - if ( - word.startsWith("#") || - word.startsWith("```") || - word.isDirectiveMarker() || - word.startsWith("@") || // interpreted as a tag - word.isTodo() || - word.startsWith(">") - ) { + if (word.startsWith("#") || + word.startsWith("```") || + word.isDirectiveMarker() || + word.startsWith("@") || // interpreted as a tag + word.isTodo() || + word.startsWith(">")) { return false } diff --git a/core/src/main/java/com/facebook/ktfmt/kdoc/ParagraphListBuilder.kt b/core/src/main/java/com/facebook/ktfmt/kdoc/ParagraphListBuilder.kt index 24f10075..2e3f34fe 100644 --- a/core/src/main/java/com/facebook/ktfmt/kdoc/ParagraphListBuilder.kt +++ b/core/src/main/java/com/facebook/ktfmt/kdoc/ParagraphListBuilder.kt @@ -163,9 +163,8 @@ class ParagraphListBuilder( while (j < lines.size) { val l = lines[j] val lineWithIndentation = lineContent(l) - if ( - lineWithIndentation.contains("```") && lineWithIndentation.trimStart().startsWith("```") - ) { + if (lineWithIndentation.contains("```") && + lineWithIndentation.trimStart().startsWith("```")) { // Don't convert
 tags if we already have nested ``` content; that will lead to
         // trouble
         allowCustomize = false
@@ -248,50 +247,42 @@ class ParagraphListBuilder(
         return paragraph
       }
 
-      if (
-          lineWithIndentation.startsWith("    ") && // markdown preformatted text
-              (i == 1 || lineContent(lines[i - 2]).isBlank()) && // we've already ++'ed i above
-              // Make sure it's not just deeply indented inside a different block
-              (paragraph.prev == null ||
-                  lineWithIndentation.length - lineWithoutIndentation.length >=
-                      checkNotNull(paragraph.prev).originalIndent + 4)
-      ) {
+      if (lineWithIndentation.startsWith("    ") && // markdown preformatted text
+          (i == 1 || lineContent(lines[i - 2]).isBlank()) && // we've already ++'ed i above
+          // Make sure it's not just deeply indented inside a different block
+          (paragraph.prev == null ||
+              lineWithIndentation.length - lineWithoutIndentation.length >=
+                  checkNotNull(paragraph.prev).originalIndent + 4)) {
         i = addPreformatted(i - 1, includeEnd = false, expectClose = false) { !it.startsWith(" ") }
-      } else if (
-          lineWithoutIndentation.startsWith("-") &&
-              lineWithoutIndentation.containsOnly('-', '|', ' ')
-      ) {
+      } else if (lineWithoutIndentation.startsWith("-") &&
+          lineWithoutIndentation.containsOnly('-', '|', ' ')) {
         val paragraph = newParagraph(i - 1)
         appendText(lineWithoutIndentation)
         newParagraph(i).block = true
         // Dividers must be surrounded by blank lines
-        if (
-            lineWithIndentation.isLine() &&
-                (i < 2 || lineContent(lines[i - 2]).isBlank()) &&
-                (i > lines.size - 1 || lineContent(lines[i]).isBlank())
-        ) {
+        if (lineWithIndentation.isLine() &&
+            (i < 2 || lineContent(lines[i - 2]).isBlank()) &&
+            (i > lines.size - 1 || lineContent(lines[i]).isBlank())) {
           paragraph.separator = true
         }
-      } else if (
-          lineWithoutIndentation.startsWith("=") && lineWithoutIndentation.containsOnly('=', ' ')
-      ) {
+      } else if (lineWithoutIndentation.startsWith("=") &&
+          lineWithoutIndentation.containsOnly('=', ' ')) {
         // Header
         // ======
         newParagraph(i - 1).block = true
         appendText(lineWithoutIndentation)
         newParagraph(i).block = true
-      } else if (
-          lineWithoutIndentation.startsWith("#")
-          // "## X" is a header, "##X" is not
-          && lineWithoutIndentation.firstOrNull { it != '#' }?.equals(' ') == true
-      ) { // not isHeader() because  is handled separately
+      } else if (lineWithoutIndentation.startsWith("#")
+      // "## X" is a header, "##X" is not
+      &&
+          lineWithoutIndentation.firstOrNull { it != '#' }?.equals(' ') ==
+              true) { // not isHeader() because  is handled separately
         // ## Header
         newParagraph(i - 1).block = true
         appendText(lineWithoutIndentation)
         newParagraph(i).block = true
-      } else if (
-          lineWithoutIndentation.startsWith("*") && lineWithoutIndentation.containsOnly('*', ' ')
-      ) {
+      } else if (lineWithoutIndentation.startsWith("*") &&
+          lineWithoutIndentation.containsOnly('*', ' ')) {
         // Horizontal rule:
         // *******
         // * * *
@@ -365,13 +356,11 @@ class ParagraphListBuilder(
           val qTrimmed = qLineContent.trim()
 
           // Check termination conditions
-          if (
-              qTrimmed.isBlank() ||
-                  qTrimmed.isKDocTag() ||
-                  qTrimmed.isTodo() ||
-                  qTrimmed.isDirectiveMarker() ||
-                  qTrimmed.isHeader()
-          ) {
+          if (qTrimmed.isBlank() ||
+              qTrimmed.isKDocTag() ||
+              qTrimmed.isTodo() ||
+              qTrimmed.isDirectiveMarker() ||
+              qTrimmed.isHeader()) {
             break
           }
 
@@ -419,9 +408,8 @@ class ParagraphListBuilder(
         }
 
         newParagraph(i)
-      } else if (
-          lineWithoutIndentation.equals("