- private void indexTypes(final Iterable<? extends Generator> generators) {
- for (Generator gen : generators) {
- gen.generatedType().ifPresent(type -> indexType(gen, type));
- indexTypes(gen);
+ private void indexModules(final Map<QNameModule, ModuleGenerator> moduleGens) {
+ for (var entry : moduleGens.entrySet()) {
+ final var modGen = entry.getValue();
+
+ // index the module's runtime type
+ safePut(modules, "modules", entry.getKey(), modGen.runtimeType().orElseThrow());
+
+ // index module's identities and RPC input/outputs
+ for (var gen : modGen) {
+ if (gen instanceof IdentityGenerator idGen) {
+ idGen.runtimeType().ifPresent(identity -> {
+ safePut(identities, "identities", identity.statement().argument(), identity);
+ });
+ }
+ // FIXME: do not collect these once we they generate a proper RuntimeType
+ if (gen instanceof RpcGenerator rpcGen) {
+ final QName rpcName = rpcGen.statement().argument();
+ for (var subgen : gen) {
+ if (subgen instanceof InputGenerator inputGen) {
+ inputGen.runtimeType().ifPresent(input -> rpcInputs.put(rpcName, input));
+ } else if (subgen instanceof OutputGenerator outputGen) {
+ outputGen.runtimeType().ifPresent(output -> rpcOutputs.put(rpcName, output));
+ }
+ }
+ }
+ }