]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/NamespaceImpl.java
New SCL completion implementation
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / environment / NamespaceImpl.java
index 98666c11a16bab50cf93723f2fdb26f5af413b95..0dd144053aa584d66c54c10175d29c1927a36e54 100644 (file)
@@ -1,12 +1,13 @@
 package org.simantics.scl.compiler.environment;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.function.Consumer;
 
+import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
-import org.simantics.scl.compiler.elaboration.modules.TypeAlias;
 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
-import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
+import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
 import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
@@ -33,13 +34,6 @@ public class NamespaceImpl implements Namespace {
             this.module = module;
             this.filter = filter;
         }
-        
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder();
-            sb.append("ModuleImport \"").append(module).append("\"").append(" with filter ").append(filter);
-            return sb.toString();
-        }
     }
     
     public NamespaceImpl(THashMap<String, Namespace> namespaceMap,
@@ -52,6 +46,11 @@ public class NamespaceImpl implements Namespace {
     public Namespace getNamespace(String name) {
         return namespaceMap.get(name);
     }
+    
+    @Override
+    public Collection<String> getNamespaces() {
+        return namespaceMap.keySet();
+    }
 
     @Override
     public SCLValue getValue(String name) throws AmbiguousNameException {
@@ -81,7 +80,7 @@ public class NamespaceImpl implements Namespace {
             throw new AmbiguousNameException(conflictingModules, name);
         return result;
     }
-
+    
     @Override
     public SCLRelation getRelation(String name) throws AmbiguousNameException {
         SCLRelation result = null, temp;
@@ -138,14 +137,14 @@ public class NamespaceImpl implements Namespace {
     }
 
     @Override
-    public TypeConstructor getTypeConstructor(String name)
+    public TypeDescriptor getTypeDescriptor(String name)
             throws AmbiguousNameException {
-        TypeConstructor result = null, temp;
+        TypeDescriptor result = null, temp;
         Module resultModule = null;
         ArrayList<String> conflictingModules = null;
         for(ModuleImport moduleImport : moduleImports) {
             Module module = moduleImport.module;
-            temp = module.getTypeConstructor(name);
+            temp = module.getTypeDescriptor(name);
             if(temp != null) {
                 if(result != null) {
                     if(conflictingModules == null) {
@@ -221,13 +220,13 @@ public class NamespaceImpl implements Namespace {
     }
 
     @Override
-    public TypeAlias getTypeAlias(String name) throws AmbiguousNameException {
-        TypeAlias result = null, temp;
+    public MappingRelation getMappingRelation(String name) throws AmbiguousNameException {
+        MappingRelation result = null, temp;
         Module resultModule = null;
         ArrayList<String> conflictingModules = null;
         for(ModuleImport moduleImport : moduleImports) {
             Module module = moduleImport.module;
-            temp = module.getTypeAlias(name);
+            temp = module.getMappingRelation(name);
             if(temp != null) {
                 if(result != null) {
                     if(conflictingModules == null) {
@@ -246,15 +245,15 @@ public class NamespaceImpl implements Namespace {
             throw new AmbiguousNameException(conflictingModules, name);
         return result;
     }
-
+    
     @Override
-    public MappingRelation getMappingRelation(String name) throws AmbiguousNameException {
-        MappingRelation result = null, temp;
+    public TransformationRule getRule(String name) throws AmbiguousNameException {
+        TransformationRule result = null, temp;
         Module resultModule = null;
         ArrayList<String> conflictingModules = null;
         for(ModuleImport moduleImport : moduleImports) {
             Module module = moduleImport.module;
-            temp = module.getMappingRelation(name);
+            temp = module.getRule(name);
             if(temp != null) {
                 if(result != null) {
                     if(conflictingModules == null) {
@@ -275,13 +274,13 @@ public class NamespaceImpl implements Namespace {
     }
     
     @Override
-    public TransformationRule getRule(String name) throws AmbiguousNameException {
-        TransformationRule result = null, temp;
+    public CHRRuleset getRuleset(String name) throws AmbiguousNameException {
+        CHRRuleset result = null, temp;
         Module resultModule = null;
         ArrayList<String> conflictingModules = null;
         for(ModuleImport moduleImport : moduleImports) {
             Module module = moduleImport.module;
-            temp = module.getRule(name);
+            temp = module.getRuleset(name);
             if(temp != null) {
                 if(result != null) {
                     if(conflictingModules == null) {