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