Package org.eclipse.epsilon.hutn
Class HutnModule
- java.lang.Object
-
- org.eclipse.epsilon.common.module.AbstractModuleElement
-
- org.eclipse.epsilon.eol.AbstractModule
-
- org.eclipse.epsilon.eol.EolModule
-
- org.eclipse.epsilon.hutn.HutnModule
-
- All Implemented Interfaces:
IModule
,ModuleElement
,IEolModule
,IHutnModule
public class HutnModule extends EolModule implements IHutnModule
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.File
configFileDirectory
protected HutnDocument
document
protected boolean
hutnIsValid
protected boolean
metaModelIsValid
protected Spec
spec
-
Fields inherited from class org.eclipse.epsilon.eol.EolModule
compilationContext, context, declaredModelDeclarations, declaredOperations, imports, main, modelDeclarations, operations, postOperationStatements
-
Fields inherited from class org.eclipse.epsilon.eol.AbstractModule
parseProblems, parser, sourceFile, sourceUri
-
-
Constructor Summary
Constructors Constructor Description HutnModule()
HutnModule(IHutnContext context)
Instantiates the module with the specified execution context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModuleElement
adapt(AST cst, ModuleElement parentAst)
void
build(AST cst, IModule module)
protected org.antlr.runtime.Lexer
createLexer(org.antlr.runtime.ANTLRInputStream inputStream)
EpsilonParser
createParser(org.antlr.runtime.TokenStream tokenStream)
AbstractEmfModel
generateEmfModel()
IHutnContext
getContext()
Spec
getIntermediateModel()
java.lang.String
getMainRule()
java.lang.String
getModelFile()
java.util.List<java.lang.String>
getNsUris()
boolean
hasValidHutn()
Returns false only if the HUTN source passed to parse is not valid HUTN.boolean
hasValidMetaModel()
protected boolean
invokeMainRule(java.util.List<org.antlr.runtime.CommonToken> comments)
protected boolean
parsingWasSuccessful()
void
setConfigFileDirectory(java.io.File configFileDirectory)
java.util.List<java.io.File>
storeEmfModel(java.io.File baseDirectory, java.lang.String defaultModelPath, java.lang.String inferredMetamodelPath)
Generates an EMF model for the HUTN source passed to parse.void
storeIntermediateModel(java.io.File destination)
void
storeIntermediateModelTransformation(java.io.File destination)
void
storeIntermediateModelTransformationForAllInputModels(java.io.File destination)
protected void
translateAst(AST ast)
-
Methods inherited from class org.eclipse.epsilon.eol.EolModule
checkImports, clearCache, compile, execute, executeImpl, getCompilationContext, getDeclaredModelDeclarations, getDeclaredOperations, getImportConfiguration, getImports, getImportsByExtension, getMain, getModelDelcarations, getOperations, getParentModule, getPostOperationStatements, prepareContext, setContext, setMain, setParentModule, toString
-
Methods inherited from class org.eclipse.epsilon.eol.AbstractModule
assignAnnotations, assignComment, assignComments, createAst, extractComments, getParseProblems, getSourceFile, getSourceUri, parse, parse
-
Methods inherited from class org.eclipse.epsilon.common.module.AbstractModuleElement
equals, getChildren, getComments, getData, getDebugInfo, getFile, getModule, getParent, getRegion, getUri, hashCode, setModule, setParent, setRegion, setUri
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.epsilon.eol.IEolModule
configure, getConfigurationProperties, getParseProblems, parse
-
Methods inherited from interface org.eclipse.epsilon.common.module.IModule
compile, createAst, getSourceUri, parse, parse, parse, parse, parse
-
Methods inherited from interface org.eclipse.epsilon.common.module.ModuleElement
getChildren, getComments, getData, getFile, getModule, getParent, getRegion, getUri, setModule, setParent, setRegion, setUri
-
-
-
-
Field Detail
-
document
protected HutnDocument document
-
spec
protected Spec spec
-
metaModelIsValid
protected boolean metaModelIsValid
-
configFileDirectory
protected java.io.File configFileDirectory
-
hutnIsValid
protected boolean hutnIsValid
-
-
Constructor Detail
-
HutnModule
public HutnModule()
-
HutnModule
public HutnModule(IHutnContext context)
Instantiates the module with the specified execution context.- Parameters:
context
- The execution context- Since:
- 1.6
-
-
Method Detail
-
createLexer
protected org.antlr.runtime.Lexer createLexer(org.antlr.runtime.ANTLRInputStream inputStream)
- Overrides:
createLexer
in classEolModule
-
createParser
public EpsilonParser createParser(org.antlr.runtime.TokenStream tokenStream)
- Overrides:
createParser
in classEolModule
-
adapt
public ModuleElement adapt(AST cst, ModuleElement parentAst)
-
getMainRule
public java.lang.String getMainRule()
- Overrides:
getMainRule
in classEolModule
-
getContext
public IHutnContext getContext()
- Specified by:
getContext
in interfaceIEolModule
- Overrides:
getContext
in classEolModule
-
invokeMainRule
protected boolean invokeMainRule(java.util.List<org.antlr.runtime.CommonToken> comments) throws java.lang.Exception
- Overrides:
invokeMainRule
in classAbstractModule
- Throws:
java.lang.Exception
-
parsingWasSuccessful
protected boolean parsingWasSuccessful()
-
build
public void build(AST cst, IModule module)
- Specified by:
build
in interfaceModuleElement
- Overrides:
build
in classEolModule
-
translateAst
protected void translateAst(AST ast) throws HutnException
- Throws:
HutnException
-
hasValidHutn
public boolean hasValidHutn()
Description copied from interface:IHutnModule
Returns false only if the HUTN source passed to parse is not valid HUTN. True is returned when the HUTN is valid, regardless of whether it conforms to the metamodel specified in the preamble.- Specified by:
hasValidHutn
in interfaceIHutnModule
-
setConfigFileDirectory
public void setConfigFileDirectory(java.io.File configFileDirectory)
- Specified by:
setConfigFileDirectory
in interfaceIHutnModule
-
hasValidMetaModel
public boolean hasValidMetaModel()
- Specified by:
hasValidMetaModel
in interfaceIHutnModule
-
getNsUris
public java.util.List<java.lang.String> getNsUris()
- Specified by:
getNsUris
in interfaceIHutnModule
-
getModelFile
public java.lang.String getModelFile()
- Specified by:
getModelFile
in interfaceIHutnModule
-
generateEmfModel
public AbstractEmfModel generateEmfModel() throws HutnGenerationException
- Specified by:
generateEmfModel
in interfaceIHutnModule
- Returns:
- an in-memory EMF model for the HUTN source passed to parse.
- Throws:
HutnGenerationException
-
storeEmfModel
public java.util.List<java.io.File> storeEmfModel(java.io.File baseDirectory, java.lang.String defaultModelPath, java.lang.String inferredMetamodelPath) throws HutnGenerationException
Description copied from interface:IHutnModule
Generates an EMF model for the HUTN source passed to parse.
The model is stored in the given baseDirectory, with filename defaultModelPath. The HUTN source may contain a modelFile attribute (in a model package, in the Spec preamble). When a modelFile attribute is specified in the HUTN source, that value takes precedence over defaultModelPath.
When a metamodel is inferred (because no metamodel is specfied in the Spec preamble), it is generated in the given baseDirectory, with filename inferredMetamodelPath.
- Specified by:
storeEmfModel
in interfaceIHutnModule
- Returns:
- the list of Files generated by this method invocation.
- Throws:
HutnGenerationException
-
getIntermediateModel
public Spec getIntermediateModel()
- Specified by:
getIntermediateModel
in interfaceIHutnModule
-
storeIntermediateModel
public void storeIntermediateModel(java.io.File destination)
- Specified by:
storeIntermediateModel
in interfaceIHutnModule
-
storeIntermediateModelTransformation
public void storeIntermediateModelTransformation(java.io.File destination) throws HutnGenerationException
- Specified by:
storeIntermediateModelTransformation
in interfaceIHutnModule
- Throws:
HutnGenerationException
-
storeIntermediateModelTransformationForAllInputModels
public void storeIntermediateModelTransformationForAllInputModels(java.io.File destination) throws HutnGenerationException
- Specified by:
storeIntermediateModelTransformationForAllInputModels
in interfaceIHutnModule
- Throws:
HutnGenerationException
-
-