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