* @param environment
* @param driver
* @return a pair consisting of the path to the transformed model and a flag indicating a circular import (if true).
*/
public Pair<String, Boolean> transformModel(IStrategoTerm model, IStrategoTerm transformation, IStrategoTerm toplevelDecl) throws TokenExpectedException, IOException, ParseException, InvalidParseTableException, SGLRException, InterruptedException {
RelativePath modelPath = resolveModule(model, toplevelDecl, true);
RelativePath transformationPath = resolveModule(transformation, toplevelDecl, false);
if (modelPath == null) {
// something's wrong
String name;
try {
name = baseProcessor.getModulePath(model);
} catch (Exception e) {
name = model.toString();
}
driver.setErrorMessage(toplevelDecl, "model not found " + name);
return null;
}
if (transformationPath == null) {
// something's wrong
String name;
try {
name = baseProcessor.getModulePath(transformation);
} catch (Exception e) {
name = transformation.toString();
}
driver.setErrorMessage(toplevelDecl, "transformation not found " + name);
return null;
}
Log.log.beginTask("Transform model " + FileCommands.fileName(modelPath) + " with transformation " + FileCommands.fileName(transformationPath), Log.TRANSFORM);
try {
RelativePath transformedModelSourceFile = getTransformedModelSourceFilePath(modelPath, transformationPath, environment);
String transformedModelPath = FileCommands.dropExtension(transformedModelSourceFile.getRelativePath());
Result transformedModelResult = ModuleSystemCommands.locateResult(transformedModelPath, environment);
if (transformedModelResult != null && transformedModelResult.isUpToDate(environment)) {
// result of transformation is already up-to-date, nothing to do here.
driverResult.addDependency(transformedModelResult);