1 package org.simantics.scl.compiler.source.repository;
3 import gnu.trove.procedure.TObjectProcedure;
5 import org.simantics.scl.compiler.module.repository.UpdateListener;
6 import org.simantics.scl.compiler.source.ModuleSource;
8 public class CompositeModuleSourceRepository implements ModuleSourceRepository {
9 public final ModuleSourceRepository[] children;
11 public CompositeModuleSourceRepository(ModuleSourceRepository ... children) {
12 this.children = children;
16 public ModuleSource getModuleSource(String moduleName,
17 UpdateListener listener) {
18 ModuleSource result = null;
19 for(ModuleSourceRepository sourceRepository : children) {
20 ModuleSource source = sourceRepository.getModuleSource(moduleName, listener);
23 double resultPriority = result.getPriority();
24 double sourcePriority = source.getPriority();
25 if(resultPriority > sourcePriority)
27 if(resultPriority == sourcePriority)
28 throw new RuntimeException("Module " + moduleName + " has two sources " + result + ", " +
29 source + " with the same priority.");
38 public String getDocumentation(String documentationName) {
39 for(ModuleSourceRepository sourceRepository : children) {
40 String documentation = sourceRepository.getDocumentation(documentationName);
41 if(documentation != null)
48 public void forAllModules(TObjectProcedure<String> procedure) {
49 for(ModuleSourceRepository sourceRepository : children)
50 sourceRepository.forAllModules(procedure);
54 public void forAllDocumentations(TObjectProcedure<String> procedure) {
55 for(ModuleSourceRepository sourceRepository : children)
56 sourceRepository.forAllDocumentations(procedure);
60 public void checkUpdates() {
65 for (ModuleSourceRepository child : children)