]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Namespace.java
New SCL completion implementation
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / environment / Namespace.java
1 package org.simantics.scl.compiler.environment;
2
3 import java.util.Collection;
4 import java.util.function.Consumer;
5
6 import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
7 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
8 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
9 import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
10 import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
11 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
12 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
13 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
14 import org.simantics.scl.compiler.environment.filter.NamespaceFilter;
15 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
16 import org.simantics.scl.compiler.types.TCon;
17
18 import gnu.trove.procedure.TObjectProcedure;
19
20 public interface Namespace {
21         /**
22          * Find a sub-namespace with a given name
23          * @param name  name of the namespace
24          * @return  a Namespace instance, or null if not found
25          */
26     Namespace getNamespace(String name);
27     
28     Collection<String> getNamespaces();
29     
30     /**
31      * Get an SCLValue for a given name. The same instance is returned on each call.
32      * @param name  the name of a defined value
33      * @return  The return value is an SCLValue provided by any source included in the namespace,
34      *          or null if the name is not found.
35      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
36      */
37     SCLValue getValue(String name) throws AmbiguousNameException;
38     
39     /**
40      * Get an SCLRelation for a given name. The same instance is returned on each call.
41      * @param name  the name of a defined relation
42      * @return  The return value is an SCLRelation provided by any source included in the namespace,
43      *          or null if the name is not found.
44      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
45      */
46     SCLRelation getRelation(String name) throws AmbiguousNameException;
47     
48     /**
49      * Get an SCLEntityType for a given name. The same instance is returned on each call.
50      * @param name  the name of a defined entity type
51      * @return  The return value is an SCLEntityType provided by any source included in the namespace,
52      *          or null if the name is not found.
53      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
54      */
55     SCLEntityType getEntityType(String name) throws AmbiguousNameException;
56     
57     /**
58      * Get a TypeDescriptor for a given name. The same instance is returned on each call.
59      * @param name  the name of a defined entity type
60      * @return  The return value is a TypeDescriptor provided by any source included in the namespace,
61      *          or null if the name is not found.
62      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
63      */
64     TypeDescriptor getTypeDescriptor(String name) throws AmbiguousNameException;
65     
66     /**
67      * Get an EffectConstructor for a given name. The same instance is returned on each call.
68      * @param name  an effect name
69      * @return  The return value is an EffectConstructor provided by any source included in the namespace,
70      *          or null if the name is not found.
71      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
72      */
73     EffectConstructor getEffectConstructor(String name) throws AmbiguousNameException;
74     
75     CHRRuleset getRuleset(String name) throws AmbiguousNameException;
76     
77     /**
78      * Get a TypeClass for a given name. The same instance is returned on each call.
79      * @param name  the name of a defined entity type
80      * @return  The return value is a TypeClass provided by any source included in the namespace,
81      *          or null if the name is not found.
82      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
83      */
84     TypeClass getTypeClass(String name) throws AmbiguousNameException;
85     
86     TransformationRule getRule(String name) throws AmbiguousNameException;
87     MappingRelation getMappingRelation(String name) throws AmbiguousNameException;
88
89     /**
90      * Find all values that share a common prefix and call a procedure for them.
91      * @param prefix  A name prefix
92      * @param filter  A filter that restricts the set of found values
93      * @param proc    A procedure that is called for all found values
94      */
95     void findValuesForPrefix(String prefix, NamespaceFilter filter, TObjectProcedure<SCLValue> proc);
96     
97     /**
98      * Find all types that share a common prefix and call a consumer for them.
99      * @param prefix    A name prefix
100      * @param filter    A filter that restricts the set of found values
101      * @param consumer  A procedure that is called for all found values
102      */
103     void findTypesForPrefix(String prefix, NamespaceFilter filter, Consumer<TCon> consumer);
104 }