[formatter-core] minor, signature change

This commit is contained in:
Yaroslav Lepenkin
2016-06-30 19:03:07 +03:00
parent 4d8dff725e
commit 6ecb24cd01
2 changed files with 13 additions and 13 deletions
@@ -56,23 +56,23 @@ interface BlockProcessor {
}
class AdditionalRangesExtractor : BlockProcessor {
val extraRanges = mutableListOf<ExtraReformatRanges>()
val additionalRanges = mutableListOf<TextRange>()
override fun processLeafBlock(block: Block) {
extractAdditionalRange(block)
}
override fun processLeafBlock(block: Block) = Unit
override fun processCompositeBlock(block: Block) {
extractAdditionalRange(block)
}
private fun extractAdditionalRange(block: Block) {
if (block is AbstractBlock) {
block.extraRangeToReformat?.let { additionalRanges.add(it) }
block.extraRangesToFormat?.let { extraRanges.add(it) }
}
}
}
class ExtraReformatRanges(val ranges: List<TextRange> = emptyList()) {
constructor(range: TextRange): this(listOf(range))
}
fun FormatTextRanges.mergeWith(extraRanges: ExtraReformatRanges) {
extraRanges.ranges.forEach { add(it, false) }
}
@@ -84,7 +84,7 @@ class AdjustFormatRangesState(var currentRoot: Block,
init {
setOnDone({
extractor.additionalRanges.forEach { formatRanges.add(it, true) }
extractor.extraRanges.forEach { formatRanges.mergeWith(it) }
})
}
@@ -183,7 +183,7 @@ public abstract class AbstractBlock implements ASTBlock {
* @return additional range to reformat, when this block if formatted
*/
@Nullable
public TextRange getExtraRangeToReformat() {
public ExtraReformatRanges getExtraRangesToFormat() {
return null;
}