kotlin-stdlib-gen: add dsl option for multiple suppressed diagnostics
This commit is contained in:
@@ -75,6 +75,7 @@ fun PrimitiveType.isNumeric(): Boolean = this in PrimitiveType.numericPrimitives
|
|||||||
enum class Inline {
|
enum class Inline {
|
||||||
No,
|
No,
|
||||||
Yes,
|
Yes,
|
||||||
|
YesSuppressWarning, // with suppressed warning about nothing to inline
|
||||||
Only;
|
Only;
|
||||||
|
|
||||||
fun isInline() = this != No
|
fun isInline() = this != No
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ class MemberBuilder(
|
|||||||
var returns: String? = null; private set
|
var returns: String? = null; private set
|
||||||
var body: String? = null; private set
|
var body: String? = null; private set
|
||||||
val annotations: MutableList<String> = mutableListOf()
|
val annotations: MutableList<String> = mutableListOf()
|
||||||
|
val suppressions: MutableList<String> = mutableListOf()
|
||||||
|
|
||||||
fun sourceFile(file: SourceFile) { sourceFile = file }
|
fun sourceFile(file: SourceFile) { sourceFile = file }
|
||||||
|
|
||||||
@@ -89,7 +90,7 @@ class MemberBuilder(
|
|||||||
inline = value
|
inline = value
|
||||||
if (suppressWarning) {
|
if (suppressWarning) {
|
||||||
require(value == Inline.Yes)
|
require(value == Inline.Yes)
|
||||||
annotation("""@Suppress("NOTHING_TO_INLINE")""")
|
inline = Inline.YesSuppressWarning
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun inlineOnly() { inline = Inline.Only }
|
fun inlineOnly() { inline = Inline.Only }
|
||||||
@@ -113,6 +114,10 @@ class MemberBuilder(
|
|||||||
annotations += annotation
|
annotations += annotation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun suppress(diagnostic: String) {
|
||||||
|
suppressions += diagnostic
|
||||||
|
}
|
||||||
|
|
||||||
fun sequenceClassification(vararg sequenceClass: SequenceClass) {
|
fun sequenceClassification(vararg sequenceClass: SequenceClass) {
|
||||||
sequenceClassification += sequenceClass
|
sequenceClassification += sequenceClass
|
||||||
}
|
}
|
||||||
@@ -324,8 +329,15 @@ class MemberBuilder(
|
|||||||
|
|
||||||
annotations.forEach { builder.append(it.trimIndent()).append('\n') }
|
annotations.forEach { builder.append(it.trimIndent()).append('\n') }
|
||||||
|
|
||||||
if (inline == Inline.Only) {
|
when (inline) {
|
||||||
builder.append("@kotlin.internal.InlineOnly").append('\n')
|
Inline.Only -> builder.append("@kotlin.internal.InlineOnly").append('\n')
|
||||||
|
Inline.YesSuppressWarning -> suppressions.add("NOTHING_TO_INLINE")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (suppressions.isNotEmpty()) {
|
||||||
|
suppressions.joinTo(builder, separator = ", ", prefix = "@Suppress(", postfix = ")\n") {
|
||||||
|
""""$it""""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
|
|||||||
Reference in New Issue
Block a user