]> 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 bb98f1aa529b019274cf1252069126595a8db0df..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;
@@ -45,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 {
@@ -74,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;
@@ -131,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) {
@@ -214,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) {
@@ -239,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) {
@@ -268,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) {