This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the formatting of function parameters whose types are functions w…
…ith modifier lists. These were not treated properly as blocks before, resulting in line breaks being inserted incorrectly and without proper indentation.
- Loading branch information
Showing
4 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
formatter/src/main/kotlin/org/kotlin/formatter/scanning/TypeReferenceScanner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.kotlin.formatter.scanning | ||
|
||
import org.jetbrains.kotlin.KtNodeTypes | ||
import org.jetbrains.kotlin.com.intellij.lang.ASTNode | ||
import org.jetbrains.kotlin.psi.psiUtil.children | ||
import org.kotlin.formatter.Token | ||
import org.kotlin.formatter.scanning.nodepattern.nodePattern | ||
|
||
/** A [NodeScanner] for references to types. */ | ||
internal class TypeReferenceScanner(private val kotlinScanner: KotlinScanner) : NodeScanner { | ||
private val nodePattern = | ||
nodePattern { | ||
zeroOrOne { | ||
nodeOfType(KtNodeTypes.MODIFIER_LIST) thenMapToTokens { nodes -> | ||
kotlinScanner.scanNodes(nodes, ScannerState.STATEMENT) | ||
} | ||
} | ||
possibleWhitespace() | ||
oneOrMore { anyNode() } thenMapToTokens { nodes -> | ||
kotlinScanner.scanNodes(nodes, ScannerState.STATEMENT) | ||
} | ||
end() | ||
} | ||
|
||
override fun scan(node: ASTNode, scannerState: ScannerState): List<Token> = | ||
nodePattern.matchSequence(node.children().asIterable()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters