Class Resolver<M extends IResolvableModel<V,M>,O extends IResolvableOperation<V>,E extends ModelCallExpression<V,M,O>,V extends IMetaParameterDeclaration>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Resolver<V>
-
- net.ssehub.easy.instantiation.core.model.common.Resolver<M,O,E,V>
-
- Type Parameters:
M- the specific type of modelO- the specific type of operationE- the specific call expressionV- the specific class of variables
- All Implemented Interfaces:
IResolver<V>
public abstract class Resolver<M extends IResolvableModel<V,M>,O extends IResolvableOperation<V>,E extends ModelCallExpression<V,M,O>,V extends IMetaParameterDeclaration> extends Resolver<V>
A common resolver.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classResolver.CallExpressionTesterClass for successively testing and resolving call expressions (super calls, imported calls, recursive calls).-
Nested classes/interfaces inherited from class net.ssehub.easy.instantiation.core.model.expressions.Resolver
Resolver.IContextType
-
-
Constructor Summary
Constructors Constructor Description Resolver(IRuntimeEnvironment environment)Creates a new resolver considering the runtime environment.Resolver(TypeRegistry registry)Creates a new resolver instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private voidaddImportedVariables(M model, java.lang.String path, java.util.Set<M> done)Adds imported variables with their qualified name.EcreateCallExpression(boolean isSuper, java.lang.String name, ICallExpressionTester<M,O,E,V> tester, CallArgument... arguments)Creates a call to aIResolvableOperationfor one of the current model instances.EcreateCallExpression(boolean isSuper, java.lang.String name, CallArgument... arguments)Creates a call to aIResolvableOperationfor one of the current model instances.protected abstract EcreateCallExpression(M model, boolean isSuper, java.lang.String name, CallArgument... arguments)Creates a new model call expression.CallExpressioncreateExtensionCallExpression(java.lang.String name, CallArgument... arguments)Creates an extension call expression to functions provided by extension types (seeIResolvableModel.getExtensionType(int)).private MdetermineQualifiedModel(M model, boolean isSuper, java.lang.String name)Determines the model denoted by a qualified name.private MdetermineQualifiedModel(M model, java.lang.String name)Determines the model denoted by a qualified name.voidenumerateImports(M model)Enumerates the imports and adds relevant model elements such as qualified variable declarations to this resolver.MgetCurrentModel()Returns the current model.java.lang.ObjectgetIvmlElement(java.lang.String name)Resolves an IVML element.voidpopModel()Removes the top-level model instance from resolution.voidpushModel(M model)Adds a model instance for resolution.TypeDescriptor<?>resolveType(java.lang.String name)Resolves a type within the known contexts / models.private TypeDescriptor<?>resolveType(M model, java.lang.String name)Resolves a type within the given model, i.e., looks for model-specific type definitions.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.Resolver
add, add, add, add, addAlias, contains, contains, getContextType, getDefaultType, getLevelCount, getRuntimeEnvironment, getTypeRegistry, limitVariablesOnCurrentLevel, popLevel, pushLevel, remove, remove, resolve, resolve, setContextType
-
-
-
-
Field Detail
-
models
private java.util.Stack<M extends IResolvableModel<V,M>> models
-
-
Constructor Detail
-
Resolver
public Resolver(TypeRegistry registry)
Creates a new resolver instance.- Parameters:
registry- a specific (local) registry
-
Resolver
public Resolver(IRuntimeEnvironment environment)
Creates a new resolver considering the runtime environment. (for expression resolution only).- Parameters:
environment- the runtime environment
-
-
Method Detail
-
pushModel
public void pushModel(M model)
Adds a model instance for resolution.- Parameters:
model- the model instance
-
getCurrentModel
public M getCurrentModel()
Description copied from class:ResolverReturns the current model.- Overrides:
getCurrentModelin classResolver<V extends IMetaParameterDeclaration>- Returns:
- the current model (or null if there is none)
-
enumerateImports
public void enumerateImports(M model)
Enumerates the imports and adds relevant model elements such as qualified variable declarations to this resolver.- Parameters:
model- the model to add the imports for
-
addImportedVariables
private void addImportedVariables(M model, java.lang.String path, java.util.Set<M> done)
Adds imported variables with their qualified name.- Parameters:
model- the model to add the variables forpath- the qualified name path collected so fardone- already processed models (cycle prevention)
-
popModel
public void popModel()
Removes the top-level model instance from resolution.
-
createCallExpression
protected abstract E createCallExpression(M model, boolean isSuper, java.lang.String name, CallArgument... arguments) throws VilException
Creates a new model call expression.- Parameters:
model- the actual model to resolve the operation onisSuper- this is a super callname- the name of the operationarguments- the actual arguments- Returns:
- the created expression
- Throws:
VilException- in case of an erroneously qualified name
-
determineQualifiedModel
private M determineQualifiedModel(M model, java.lang.String name) throws VilException
Determines the model denoted by a qualified name.- Parameters:
model- the model to start search for, may be the first segment of a qualified name or provider of importsname- (qualified) name- Returns:
- null if
nameis not qualified, the qualified model else - Throws:
VilException- if qualified and cannot be resolved or qualified super call
-
determineQualifiedModel
private M determineQualifiedModel(M model, boolean isSuper, java.lang.String name) throws VilException
Determines the model denoted by a qualified name.- Parameters:
model- the model to start search for, may be the first segment of a qualified name or provider of importsisSuper- is it a super call?name- (qualified) name- Returns:
- null if
nameis not qualified, the qualified model else - Throws:
VilException- if qualified and cannot be resolved or qualified super call
-
createCallExpression
public E createCallExpression(boolean isSuper, java.lang.String name, CallArgument... arguments) throws VilException
Creates a call to aIResolvableOperationfor one of the current model instances. Uses the default call expression tester.- Parameters:
name- the name of the function to be calledisSuper- is it a super call?arguments- the arguments of the call- Returns:
- the resolved expression
- Throws:
VilException- in case that the function cannot be resolved.
-
createCallExpression
public E createCallExpression(boolean isSuper, java.lang.String name, ICallExpressionTester<M,O,E,V> tester, CallArgument... arguments) throws VilException
Creates a call to aIResolvableOperationfor one of the current model instances.- Parameters:
name- the name of the function to be calledisSuper- is it a super call?tester- the call expression testerarguments- the arguments of the call- Returns:
- the resolved expression
- Throws:
VilException- in case that the function cannot be resolved.
-
createExtensionCallExpression
public CallExpression createExtensionCallExpression(java.lang.String name, CallArgument... arguments) throws VilException
Creates an extension call expression to functions provided by extension types (seeIResolvableModel.getExtensionType(int)). This method works only on the top-level model!- Parameters:
name- the name of the function to be calledarguments- the arguments to that function- Returns:
- the resolved function
- Throws:
VilException- in case that the function cannot be resolved.
-
getIvmlElement
public java.lang.Object getIvmlElement(java.lang.String name)
Description copied from interface:IResolverResolves an IVML element.- Specified by:
getIvmlElementin interfaceIResolver<M extends IResolvableModel<V,M>>- Overrides:
getIvmlElementin classResolver<V extends IMetaParameterDeclaration>- Parameters:
name- the name to be resolved- Returns:
- the IVML element (value, containable model element), null else
-
resolveType
public TypeDescriptor<?> resolveType(java.lang.String name)
Description copied from class:ResolverResolves a type within the known contexts / models.- Overrides:
resolveTypein classResolver<V extends IMetaParameterDeclaration>- Parameters:
name- the name of the type- Returns:
- the type or null for unknown
-
resolveType
private TypeDescriptor<?> resolveType(M model, java.lang.String name)
Resolves a type within the given model, i.e., looks for model-specific type definitions.- Parameters:
model- the model to resolvenameas type onname- the name of the type- Returns:
- the type or null for unknown
-
-