add Initial support for comments in SIR #KT-65174 Fixed
Merge-request: KT-MR-14007 Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
This commit is contained in:
@@ -29,6 +29,7 @@ public class SirAsSwiftSourcesPrinter(private val printer: SmartPrinter) : SirVi
|
||||
}
|
||||
|
||||
override fun visitFunction(function: SirFunction): Unit = with(printer) {
|
||||
function.documentation?.let { println(it) }
|
||||
print(
|
||||
function.visibility.takeIf { it != SirVisibility.INTERNAL }?.let { "${it.swift} " } ?: "",
|
||||
if (function.isStatic) { "static " } else { "" },
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
/// Function foo description.
|
||||
/// - Parameters:
|
||||
/// - p: first Integer to consume
|
||||
/// - Returns: Bool
|
||||
public func foo(
|
||||
p: Swift.Int64
|
||||
) -> Swift.Bool {
|
||||
fatalError()
|
||||
}
|
||||
+34
@@ -255,6 +255,40 @@ class SirAsSwiftSourcesPrinterTests {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should print DocC comment`() {
|
||||
|
||||
val module = buildModule {
|
||||
name = "Test"
|
||||
declarations.add(
|
||||
buildFunction {
|
||||
origin = SirOrigin.Unknown
|
||||
isStatic = false
|
||||
visibility = SirVisibility.PUBLIC
|
||||
name = "foo"
|
||||
parameters.add(
|
||||
SirParameter(
|
||||
argumentName = "p",
|
||||
type = SirNominalType(SirSwiftModule.int64)
|
||||
)
|
||||
)
|
||||
returnType = SirNominalType(SirSwiftModule.bool)
|
||||
documentation = """
|
||||
/// Function foo description.
|
||||
/// - Parameters:
|
||||
/// - p: first Integer to consume
|
||||
/// - Returns: Bool
|
||||
""".trimIndent()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
runTest(
|
||||
module,
|
||||
"testData/commented_function"
|
||||
)
|
||||
}
|
||||
|
||||
private fun runTest(module: SirModule, goldenDataFile: String) {
|
||||
val expectedSwiftSrc = File(KtTestUtil.getHomeDirectory()).resolve("$goldenDataFile.golden.swift")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user