Kotlin: Avoid using a possibly-throwing method

This commit is contained in:
Ian Lynagh
2023-09-22 18:15:28 +01:00
parent 52d924924b
commit 56b9fa8e9c

View File

@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.util.getChildren
class CommentExtractorLighterAST(fileExtractor: KotlinFileExtractor, file: IrFile, fileLabel: Label<out DbFile>): CommentExtractor(fileExtractor, file, fileLabel) { class CommentExtractorLighterAST(fileExtractor: KotlinFileExtractor, file: IrFile, fileLabel: Label<out DbFile>): CommentExtractor(fileExtractor, file, fileLabel) {
// Returns true if it extracted the comments; false otherwise. // Returns true if it extracted the comments; false otherwise.
fun extract(): Boolean { fun extract(): Boolean {
val sourceElement = (file.metadata as? FirMetadataSource.File)?.files?.get(0)?.source val sourceElement = (file.metadata as? FirMetadataSource.File)?.files?.elementAtOrNull(0)?.source
val treeStructure = sourceElement?.treeStructure val treeStructure = sourceElement?.treeStructure
if (treeStructure == null) { if (treeStructure == null) {
return false return false