public interface IJvmModelInferrer
Model inference is done after a resource has been loaded. It is used to map you language's constructs to the elements
defined in TypesPackage
. Those elements closely reflect the Java type model.
For example if you have a language representing state machines with its states, transitions and actions, one way to
map them to the types model would be to create a single class per state machine, an Enum
for the different states,
methods for the various actions and one method which contains the state machine logic. You would do that mapping in
your language's implementation of this interface.
The inferred Jvm type model is used to compute how scoping is done and how the language compiles to Java. That is having a proper implementation of this interface is often the only thing you need to do to make your language executable on the JVM.
Implementers should use the JvmTypesBuilder
API to create a model of Jvm elements in a convenient way.
Implementors have to traverse the given source object in infer(..)
and decide which types to
create according to the state of the model.
IJvmModelAssociations
,
IJvmModelAssociator
AbstractModelInferrer
instead.Modifier and Type | Interface and Description |
---|---|
static class |
IJvmModelInferrer.NullImpl
A null-implementation.
|
Modifier and Type | Method and Description |
---|---|
void |
infer(org.eclipse.emf.ecore.EObject e,
IJvmDeclaredTypeAcceptor acceptor,
boolean preIndexingPhase)
This method is called at two different times in a resource's life-cycle, reflected by whether {preIndexingPhase}
is set to
true or false . |
void infer(org.eclipse.emf.ecore.EObject e, IJvmDeclaredTypeAcceptor acceptor, boolean preIndexingPhase)
This method is called at two different times in a resource's life-cycle, reflected by whether {preIndexingPhase}
is set to true
or false
. When set to true
everything is still in a
pre-indexing phase, that means linking hasn't been done yet. In this phase you just need to create the Jvm-elements
which should be indexed (i.e. found globally). For regular Xbase expressions only the JvmTypes with the correct
qualified name are needed at this point.
You must only infer Jvm elements which directly result from elements contained in the current resource!
When this method is called with preIndexingPhase set to false
, you need to do the full inference
including setting all links. But still you have to it in a particular order. First you need to create the
complete tree structure and make sure you have passed the created JvmTypes to the acceptor. Only pass top level
JvmType
s to the acceptor. Only if the tree structure is created and its
root types have been passed to the acceptor, you are free to resolve any cross references.
e
- the root element from the parse resultacceptor
- an acceptor awaiting derived root JvmDeclaredType
spreIndexingPhase
- whether the call is done in before indexing. During this phase clients may not rely on any global indexing information
and only need to to provide the information needed by the language's IDefaultResourceDescriptionStrategy
.
IF not implemented differently this is just the JvmDeclaredType
s with their qualified name, but no members and no other data.