Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c2df20

Browse files
committed
Kotlin: When verbose, make with log when it starts and finishes doing something
1 parent 8b56302 commit 9c2df20

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ open class KotlinFileExtractor(
4242
): KotlinUsesExtractor(logger, tw, dependencyCollector, externalClassExtractor, primitiveTypeMapping, pluginContext, globalExtensionState) {
4343

4444
inline fun <T> with(kind: String, element: IrElement, f: () -> T): T {
45+
val loc = tw.getLocationString(element)
4546
try {
46-
return f()
47+
val name = (element as? IrDeclarationWithName)?.name?.asString() ?: "<no name>"
48+
logger.trace("Starting a $kind ($name) at $loc")
49+
val result = f()
50+
logger.trace("Finished a $kind ($name) at $loc")
51+
return result
4752
} catch(exception: Exception) {
48-
throw Exception("While extracting a $kind at ${tw.getLocationString(element)}", exception)
53+
throw Exception("While extracting a $kind at $loc", exception)
4954
}
5055
}
5156

0 commit comments

Comments
 (0)