]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Namespace.java
Resolve some dependency problems with SDK features
[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.List;
4 import java.util.function.Consumer;
5
6 import org.simantics.scl.compiler.constants.Constant;
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     /**
29      * Get an SCLValue for a given name. The same instance is returned on each call.
30      * @param name  the name of a defined value
31      * @return  The return value is an SCLValue provided by any source included in the namespace,
32      *          or null if the name is not found.
33      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
34      */
35     SCLValue getValue(String name) throws AmbiguousNameException;
36     
37     /**
38      * Get an SCLRelation for a given name. The same instance is returned on each call.
39      * @param name  the name of a defined relation
40      * @return  The return value is an SCLRelation provided by any source included in the namespace,
41      *          or null if the name is not found.
42      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
43      */
44     SCLRelation getRelation(String name) throws AmbiguousNameException;
45     
46     /**
47      * Get an SCLEntityType for a given name. The same instance is returned on each call.
48      * @param name  the name of a defined entity type
49      * @return  The return value is an SCLEntityType provided by any source included in the namespace,
50      *          or null if the name is not found.
51      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
52      */
53     SCLEntityType getEntityType(String name) throws AmbiguousNameException;
54     
55     /**
56      * Get a TypeDescriptor for a given name. The same instance is returned on each call.
57      * @param name  the name of a defined entity type
58      * @return  The return value is a TypeDescriptor provided by any source included in the namespace,
59      *          or null if the name is not found.
60      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
61      */
62     TypeDescriptor getTypeDescriptor(String name) throws AmbiguousNameException;
63     
64     /**
65      * Get an EffectConstructor for a given name. The same instance is returned on each call.
66      * @param name  an effect name
67      * @return  The return value is an EffectConstructor provided by any source included in the namespace,
68      *          or null if the name is not found.
69      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
70      */
71     EffectConstructor getEffectConstructor(String name) throws AmbiguousNameException;
72     
73     /**
74      * Get a TypeClass for a given name. The same instance is returned on each call.
75      * @param name  the name of a defined entity type
76      * @return  The return value is a TypeClass provided by any source included in the namespace,
77      *          or null if the name is not found.
78      * @exception  AmbiguousNameException  if the name matches with multiple imported modules. 
79      */
80     TypeClass getTypeClass(String name) throws AmbiguousNameException;
81     
82     TransformationRule getRule(String name) throws AmbiguousNameException;
83     MappingRelation getMappingRelation(String name) throws AmbiguousNameException;
84
85     /**
86      * Find all values that share a common prefix and call a procedure for them.
87      * @param prefix  A name prefix
88      * @param filter  A filter that restricts the set of found values
89      * @param proc    A procedure that is called for all found values
90      */
91     void findValuesForPrefix(String prefix, NamespaceFilter filter, TObjectProcedure<SCLValue> proc);
92     
93     /**
94      * Find all types that share a common prefix and call a consumer for them.
95      * @param prefix    A name prefix
96      * @param filter    A filter that restricts the set of found values
97      * @param consumer  A procedure that is called for all found values
98      */
99     void findTypesForPrefix(String prefix, NamespaceFilter filter, Consumer<TCon> consumer);
100 }