]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/repository/ModuleRepository.java
Method for manually recompling a SCL Module
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / module / repository / ModuleRepository.java
index 8a86c5ccce36ecef59326e7abcd32a558d7e27ea..23491235ce3289c46fd254009cde5963774374d6 100644 (file)
@@ -37,6 +37,8 @@ import org.simantics.scl.compiler.top.ModuleInitializer;
 import org.simantics.scl.compiler.top.SCLCompilerConfiguration;
 import org.simantics.scl.compiler.top.ValueNotFound;
 import org.simantics.scl.compiler.types.Types;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.THashMap;
 import gnu.trove.map.hash.TObjectLongHashMap;
@@ -49,6 +51,9 @@ import gnu.trove.set.hash.THashSet;
  * @author Hannu Niemistö
  */
 public class ModuleRepository {
+    
+    private static final Logger LOGGER = LoggerFactory.getLogger(ModuleRepository.class);
+
     private final ModuleRepository parentRepository;
     private final ModuleSourceRepository sourceRepository;
     private ConcurrentHashMap<String, ModuleEntry> moduleCache = new ConcurrentHashMap<String, ModuleEntry>();
@@ -120,9 +125,9 @@ public class ModuleRepository {
             if(moduleCache.get(moduleName) == this) {
                 moduleCache.remove(moduleName);
                 if(SCLCompilerConfiguration.TRACE_MODULE_UPDATE) {
-                    System.out.println("Invalidate " + moduleName);
+                    LOGGER.info("Invalidate " + moduleName);
                     for(UpdateListener l : listenersCopy)
-                        System.out.println("    " + l);
+                        LOGGER.info("    " + l);
                 }
                 for(UpdateListener l : listenersCopy)
                     if(!l.stopListening())
@@ -141,7 +146,7 @@ public class ModuleRepository {
                 compilationResult = DoesNotExist.getInstance();
             else {
                 if(SCLCompilerConfiguration.TRACE_MODULE_UPDATE)
-                    System.out.println("Compile " + source);
+                    LOGGER.info("Compile " + source);
                 beginModuleCompilation(moduleName);
                 compilationResult = source.compileModule(ModuleRepository.this, this, advisor == null ? null : advisor.getOptions(moduleName));
                 finishModuleCompilation(moduleName);
@@ -235,6 +240,10 @@ public class ModuleRepository {
         return getModule(moduleName, null);
     }
     
+    public void update(String moduleName) {
+        getModuleEntry(moduleName, null).notifyAboutUpdate();
+    }
+    
     public Failable<RuntimeModule> getRuntimeModule(String moduleName, UpdateListener listener) {
         return getModuleEntry(moduleName, listener).getRuntimeModule();
     }
@@ -505,7 +514,7 @@ public class ModuleRepository {
         if (moduleCache != null)
             for (ModuleEntry entry : moduleCache.values())
                 entry.dispose();
-        moduleCache = null;
+        moduleCache = new ConcurrentHashMap<String, ModuleEntry>();
     }
 
     /**