Compiler plugin - tracking loaded classes


I’m working on improving Kotlin support for Bazel (

I’d like to write a Kotlin compiler plugin that records which jars from the classpath each referenced type was loaded from (outside of the module source).

We can use this information to improve build speed.

With the Java compiler we can get this information from and javax.lang.model.type.TypeVisitor

Looking for some pointers… should I visit the Psi Tree for each KtFile in an AnalysisHandlerExtension or is there a more efficient way.

Also, how can I look up origin (jar file) the loaded type came from?

Thanks in advance, Jonathan