[IR] Autogenerate IrExternalPackageFragmentImpl
#KT-65773 In Progress
This commit is contained in:
committed by
Space Team
parent
f92670024e
commit
2ed0ffd123
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,10 @@ package org.jetbrains.kotlin.utils
|
||||
* A printer that is suitable for printing text with indentation.
|
||||
*/
|
||||
interface IndentingPrinter {
|
||||
/**
|
||||
* The current indentation.
|
||||
*/
|
||||
val currentIndent: String
|
||||
|
||||
/**
|
||||
* The current indentation level. Basically, this is the number of [pushIndent] calls that don't yet have a matching [popIndent] call.
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
package org.jetbrains.kotlin.utils
|
||||
|
||||
@@ -24,8 +13,10 @@ open class Printer private constructor(
|
||||
private val out: Appendable,
|
||||
private val maxBlankLines: Int,
|
||||
private val indentUnit: String,
|
||||
private var indent: String
|
||||
indent: String,
|
||||
) : IndentingPrinter {
|
||||
final override var currentIndent = indent
|
||||
private set
|
||||
private var blankLineCountIncludingCurrent = 0
|
||||
private var withholdIndentOnce = false
|
||||
private var length = 0
|
||||
@@ -40,7 +31,7 @@ open class Printer private constructor(
|
||||
indent = "",
|
||||
)
|
||||
|
||||
constructor(out: Appendable, parent: Printer) : this(out, parent.maxBlankLines, parent.indentUnit, parent.indent)
|
||||
constructor(out: Appendable, parent: Printer) : this(out, parent.maxBlankLines, parent.indentUnit, parent.currentIndent)
|
||||
|
||||
private fun append(o: Any?) {
|
||||
try {
|
||||
@@ -76,7 +67,7 @@ open class Printer private constructor(
|
||||
}
|
||||
|
||||
fun printIndent() {
|
||||
append(indent)
|
||||
append(currentIndent)
|
||||
}
|
||||
|
||||
fun printWithNoIndent(vararg objects: Any?): Printer {
|
||||
@@ -99,13 +90,13 @@ open class Printer private constructor(
|
||||
}
|
||||
|
||||
override fun pushIndent(): Printer {
|
||||
indent += indentUnit
|
||||
currentIndent += indentUnit
|
||||
return this
|
||||
}
|
||||
|
||||
override fun popIndent(): Printer {
|
||||
check(indent.length >= indentUnit.length) { "No indentation to pop" }
|
||||
indent = indent.substring(indentUnit.length)
|
||||
check(currentIndent.length >= indentUnit.length) { "No indentation to pop" }
|
||||
currentIndent = currentIndent.substring(indentUnit.length)
|
||||
return this
|
||||
}
|
||||
|
||||
@@ -138,14 +129,14 @@ open class Printer private constructor(
|
||||
}
|
||||
|
||||
override val currentIndentLengthInUnits: Int
|
||||
get() = indent.length / indentUnit.length
|
||||
get() = currentIndent.length / indentUnit.length
|
||||
|
||||
override val indentUnitLength: Int
|
||||
get() = indentUnit.length
|
||||
|
||||
companion object {
|
||||
private const val DEFAULT_INDENTATION_UNIT = " "
|
||||
const val TWO_SPACE_INDENT = " ";
|
||||
const val TWO_SPACE_INDENT = " "
|
||||
|
||||
@JvmField
|
||||
val LINE_SEPARATOR: String = System.getProperty("line.separator")
|
||||
|
||||
Reference in New Issue
Block a user