Kapt: Add flag to keep KDoc comments in stubs

Currently, KaptGenerateStubsTask may not generate KDoc comments
correctly. See KT-43593 for more details.

This commit provides a Kapt flag called
`kapt.keep.kdoc.comments.in.stubs`
to control whether KDoc comments will be included in the generated
stubs.

This flag is currently enabled by default to keep the existing behavior
and avoid breaking existing users.

Users who don't need KDoc comments in stubs but are hitting KT-43593 can
disable the flag.

Whether this flag will be disabled by default later is to be determined.

Bug: https://youtrack.jetbrains.com/issue/KT-43593
     (Note that this commit only provides a workaround, it doesn't
     actually fix the bug.)
Test: (Ir)ClassFileToSourceStubConverterTestGenerated#testCommentsRemoved
This commit is contained in:
Hung Nguyen
2021-01-21 11:07:23 +00:00
committed by nataliya.valtman
parent dcda47b502
commit e2521718dd
12 changed files with 307 additions and 38 deletions
@@ -0,0 +1,67 @@
// !KEEP_KDOC_COMMENTS_IN_STUBS
/** Test. */
class Test {
/** method(). */
fun method() {}
/** method(int). */
fun method(a: Int) {}
/** method(String). */
fun method(a: String) {}
/** prop. */
const val prop: String = ""
/** prop2. */
@Anno
val prop2: String = ""
/** prop3. */
var prop3: String
/** get. */ get() = ""
/** set. */ set(v) {}
}
/**
* Test2
* Multiline
* documentation.
*/
class Test2(val a: String)
class Test3 /** constructor. */ protected constructor(val a: String)
/** Obj. */
object Obj
@Target(AnnotationTarget.PROPERTY)
annotation class Anno
/* simple comment. */
class Test4 {
// method simple comment
fun method() {}
}
enum class EnumError {
One {
override fun doIt() = ""
class OneOne {
/** Documentation for 'test'. */
fun test() {}
}
},
Two {
/** Documentation for 'doIt'. */
override fun doIt() = ""
};
abstract fun doIt(): String
}
/**
* `/* Failure */`
*/
interface TestComponent