Merge pull request #14940 from igfoo/igfoo/comments

Kotlin 2: Comment improvements
This commit is contained in:
Ian Lynagh
2024-01-29 11:27:19 +00:00
committed by GitHub
5 changed files with 17 additions and 51 deletions

View File

@@ -205,7 +205,7 @@ open class KotlinFileExtractor(
}
@OptIn(ObsoleteDescriptorBasedAPI::class)
private fun isFake(d: IrDeclarationWithVisibility): Boolean {
fun isFake(d: IrDeclarationWithVisibility): Boolean {
val hasFakeVisibility =
d.visibility.let {
it is DelegatedDescriptorVisibility && it.delegate == Visibilities.InvisibleFake

View File

@@ -41,7 +41,13 @@ open class CommentExtractor(
tw.getExistingLabelFor<DbTop>(label)
}
if (existingLabel == null) {
logger.warn("Couldn't get existing label for $label")
// Sometimes we don't extract elements.
// The actual extractor logic is a bit more nuanced than
// just "isFake", but just checking isFake is good enough
// to not bother with a warning.
if (element !is IrDeclarationWithVisibility || !fileExtractor.isFake(element)) {
logger.warn("Couldn't get existing label for $label")
}
return null
}
return existingLabel

View File

@@ -15,6 +15,9 @@ import org.jetbrains.kotlin.kdoc.lexer.KDocTokens
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.util.getChildren
// TODO: This doesn't give owners to as many comments as the PSI extractor does.
// See the library-tests/comments tests for details.
class CommentExtractorLighterAST(
fileExtractor: KotlinFileExtractor,
file: IrFile,