I'm trying to extract all (but I'm mostly interested in classes/objects) symbols defined in a scala source file from a Java app using Scala Compiler API.
I'm able to compile a source file using scala.tools.nsc.Global.Run.compileSources, but how to extract all symbols that were defined there?
import scala.tools.nsc.Global;
import scala.tools.nsc.Settings;
import scala.reflect.internal.util.SourceFile;
import scala.collection.immutable.Nil$;
...
Global global = new Global(settings);
SourceFile src = global.newSourceFile("object test {}", "<src>");
Global.Run run = global.new Run();
run.compileSources(Nil$.MODULE$.$colon$colon(src));
None of Run, CompilationUnit and Global provide an API to retrieve all symbols.
Am I trying to solve a problem using a wrong way? :)