1 package org.simantics.scl.compiler.source.repository;
4 import java.io.IOException;
6 import org.simantics.scl.compiler.module.ImportDeclaration;
7 import org.simantics.scl.compiler.module.repository.UpdateListener;
8 import org.simantics.scl.compiler.source.ClassModuleSource;
9 import org.simantics.scl.compiler.source.FileModuleSource;
10 import org.simantics.scl.compiler.source.ModuleSource;
12 import gnu.trove.procedure.TObjectProcedure;
13 import gnu.trove.set.hash.THashSet;
15 public class FileModuleSourceRepository extends AbstractModuleSourceRepository {
17 private final File path;
18 private final ClassLoader classLoader;
19 private final THashSet<String> modules = new THashSet<String>();
21 public FileModuleSourceRepository(File path, ClassLoader classLoader) throws IOException {
23 this.classLoader = classLoader;
24 ModuleBrowsingUtil.collectModuleSourcesAt(modules, path);
28 public ModuleSource getModuleSource(String moduleName,
29 UpdateListener listener) {
30 if(!modules.contains(moduleName))
32 return new FileModuleSource(moduleName, classLoader, new File(path, moduleName + ".scl"), getBuiltinImports());
36 public void forAllModules(TObjectProcedure<String> procedure) {
37 modules.forEach(procedure);
40 protected ImportDeclaration[] getBuiltinImports() {
41 return ClassModuleSource.DEFAULT_IMPORTS;