]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Namespace.java
migrated to svn revision 33108
[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.modules.SCLValue;
6 import org.simantics.scl.compiler.elaboration.modules.TypeAlias;
7 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
8 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
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 TypeConstructor 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 TypeConstructor 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     TypeConstructor getTypeConstructor(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     /**
73      * Get a TypeClass for a given name. The same instance is returned on each call.
74      * @param name  the name of a defined entity type
75      * @return  The return value is a TypeClass provided by any source included in the namespace,
76      *          or null if the name is not found.
77      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
78      */
79     TypeClass getTypeClass(String name) throws AmbiguousNameException;
80     
81     /**
82      * Get a TypeAlias for a given name. The same instance is returned on each call.
83      * @param name  the name of a defined entity type
84      * @return  The return value is a TypeAlias provided by any source included in the namespace,
85      *          or null if the name is not found.
86      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
87      */
88     TypeAlias getTypeAlias(String name) throws AmbiguousNameException;
89     
90     TransformationRule getRule(String name) throws AmbiguousNameException;
91     MappingRelation getMappingRelation(String name) throws AmbiguousNameException;
92
93     /**
94      * Find all values that share a common prefix and call a procedure for them.
95      * @param prefix  A name prefix
96      * @param filter  A filter that restricts the set of found values
97      * @param proc    A procedure that is called for all found values
98      */
99     void findValuesForPrefix(String prefix, NamespaceFilter filter, TObjectProcedure<SCLValue> proc);
100     
101     /**
102      * Find all types that share a common prefix and call a consumer for them.
103      * @param prefix    A name prefix
104      * @param filter    A filter that restricts the set of found values
105      * @param consumer  A procedure that is called for all found values
106      */
107     void findTypesForPrefix(String prefix, NamespaceFilter filter, Consumer<TCon> consumer);
108 }