Main Question: How can you print all the subclasses (recursively) of a class in Scala?
Context:
I am using the CDE library (https://github.com/chipsalliance/cde) that is used in a variety of downstream projects to parameterize classes. As a result of using the library, a large amount of case classes are created extending a class called Config
(across multiple Scala files), like so:
class Cfg0 extends Config(...)
class Cfg1 extends Cfg0
class Cfg2 extends Cfg1
Our users normally manually call out the "Config" object names in Makefiles, etc and I would like to print the names of all the classes so that these classes are easier to discover (instead of grepping).
Definition of Config
class: https://github.com/chipsalliance/cde/blob/384c06b8d45c8184ca2f3fba2f8e78f79d2c1b51/cde/src/chipsalliance/rocketchip/config.scala#L151
I've looked at:
How do I use Scala reflection to find all subclasses of a trait (without using third-party tools)? https://gist.github.com/longshorej/1a0a2cf50de8e6ff101c
But they looked like they were oriented around case classes/traits.