mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
Kotlin: When verbose, make with log when it starts and finishes doing something
This commit is contained in:
@@ -42,10 +42,15 @@ open class KotlinFileExtractor(
|
||||
): KotlinUsesExtractor(logger, tw, dependencyCollector, externalClassExtractor, primitiveTypeMapping, pluginContext, globalExtensionState) {
|
||||
|
||||
inline fun <T> with(kind: String, element: IrElement, f: () -> T): T {
|
||||
val loc = tw.getLocationString(element)
|
||||
try {
|
||||
return f()
|
||||
val name = (element as? IrDeclarationWithName)?.name?.asString() ?: "<no name>"
|
||||
logger.trace("Starting a $kind ($name) at $loc")
|
||||
val result = f()
|
||||
logger.trace("Finished a $kind ($name) at $loc")
|
||||
return result
|
||||
} catch(exception: Exception) {
|
||||
throw Exception("While extracting a $kind at ${tw.getLocationString(element)}", exception)
|
||||
throw Exception("While extracting a $kind at $loc", exception)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user