]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Automatically import also SCLMain modules of dependent index roots 85/3485/1
authorAntti Villberg <antti.villberg@semantum.fi>
Sat, 9 Nov 2019 19:56:15 +0000 (21:56 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Sat, 9 Nov 2019 19:56:15 +0000 (21:56 +0200)
gitlab #413

Change-Id: I0f2e345bc59aa1e74f90cd2a3d138de1d0befd36

bundles/org.simantics.db.common/src/org/simantics/db/common/request/RuntimeEnvironmentRequest.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/EnvironmentRequest.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/RuntimeEnvironmentRequest2.java

index 24a5c10c909be94716ae7d907b3c698144af7975..777f1ede97f8d357b24a0a383f4bae9c13de7d40 100644 (file)
@@ -7,6 +7,7 @@ import org.simantics.db.common.utils.CommonDBUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.Listener;
 import org.simantics.db.request.Read;
+import org.simantics.layer0.Layer0;
 import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification;
 import org.simantics.scl.compiler.module.repository.ImportFailureException;
 import org.simantics.scl.compiler.module.repository.UpdateListener;
@@ -108,6 +109,12 @@ public class RuntimeEnvironmentRequest extends UnaryRead<Resource, RuntimeEnviro
         if(mainModule != null) {
             mainModuleUri = graph.getURI(mainModule);
             environmentSpecification.importModule(mainModuleUri, "");
+            Layer0 L0 = Layer0.getInstance(graph);
+            for(Resource l : graph.getObjects(parameter, L0.IsLinkedTo)) {
+                mainModule = CommonDBUtils.getPossibleChild(graph, l, "SCLMain");
+                if(mainModule != null)
+                    environmentSpecification.importModule(graph.getURI(mainModule), "");
+            }
         }
         else
             mainModuleUri = graph.getURI(parameter) + "/#"; // Add something dummy to the model uri that cannot be in a real URI
index f1f235a887d867cb85cbd75daec743256900bf94..edb40f642ad20a984d9cb8ba38523f31b7857620 100644 (file)
@@ -4,10 +4,12 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.request.ParametrizedPrimitiveRead;
 import org.simantics.db.common.request.UnaryRead;
+import org.simantics.db.common.utils.CommonDBUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.internal.SimanticsInternal;
 import org.simantics.db.procedure.Listener;
 import org.simantics.db.request.Read;
+import org.simantics.layer0.Layer0;
 import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification;
 import org.simantics.scl.compiler.module.repository.ImportFailureException;
@@ -103,11 +105,17 @@ public abstract class EnvironmentRequest extends UnaryRead<Resource, Pair<Enviro
                 "Builtin", "",
                 "StandardLibrary", "");
         fillEnvironmentSpecification(environmentSpecification);
-        Resource mainModule = Layer0Utils.getPossibleChild(graph, parameter, getRootModuleName());
+        Resource mainModule = CommonDBUtils.getPossibleChild(graph, parameter, getRootModuleName());
         String mainModuleUri;
         if(mainModule != null) {
             mainModuleUri = graph.getURI(mainModule);
             environmentSpecification.importModule(mainModuleUri, "");
+            Layer0 L0 = Layer0.getInstance(graph);
+            for(Resource l : graph.getObjects(parameter, L0.IsLinkedTo)) {
+                mainModule = CommonDBUtils.getPossibleChild(graph, l, "SCLMain");
+                if(mainModule != null)
+                    environmentSpecification.importModule(graph.getURI(mainModule), "");
+            }
         }
         else
             mainModuleUri = graph.getURI(parameter) + "/#"; // Add something dummy to the model uri that cannot be in a real URI
index c51428f2f8087758621d9396e6d6bad5f3cbd138..28d18e50772ece99c914c7069ce73ad89e3bd9e6 100644 (file)
@@ -7,6 +7,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.common.request.BinaryRead;
 import org.simantics.db.common.request.ObjectsWithType;
 import org.simantics.db.common.request.ParametrizedPrimitiveRead;
+import org.simantics.db.common.utils.CommonDBUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.internal.SimanticsInternal;
 import org.simantics.db.procedure.Listener;
@@ -122,9 +123,15 @@ public class RuntimeEnvironmentRequest2 extends BinaryRead<Resource, Resource, R
             // `parameter` is optional and can be null for e.g. procedural user components
         }
 
-        Resource mainModule = Layer0Utils.getPossibleChild(graph, parameter2, "SCLMain");
-        if(mainModule != null)
+        Resource mainModule = CommonDBUtils.getPossibleChild(graph, parameter2, "SCLMain");
+        if(mainModule != null) {
             environmentSpecification.importModule(graph.getURI(mainModule), "");
+            for(Resource l : graph.getObjects(parameter2, L0.IsLinkedTo)) {
+                mainModule = CommonDBUtils.getPossibleChild(graph, l, "SCLMain");
+                if(mainModule != null)
+                    environmentSpecification.importModule(graph.getURI(mainModule), "");
+            }
+        }
 
         return graph.syncRequest(new ParametrizedPrimitiveRead<EnvironmentSpecification, RuntimeEnvironment>(environmentSpecification) {