Compiler plugin - tracking loaded classes

Hi,

I’m working on improving Kotlin support for Bazel (GitHub - bazelbuild/rules_kotlin: Bazel rules for Kotlin).

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

com.sun.tools.javac.code.Symtab 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

5 Likes