this.translateOp = translateOp;
}
@Override
public Codebase createCodebase(ProjectContext context) throws CodebaseCreationError {
Codebase codebaseToTranslate = exToTranslate.createCodebase(context);
String toProjectSpace = translateOp.term.identifier;
TranslatorPath path = new TranslatorPath(
codebaseToTranslate.getProjectSpace(), toProjectSpace);
Translator translator = context.translators.get(path);
if (translator == null) {
throw new CodebaseCreationError(
String.format("Could not find translator from project space \"%s\" to \"%s\"",
codebaseToTranslate.getProjectSpace(), toProjectSpace));
}
Ui.Task translateTask = AppContext.RUN.ui.pushTask(
"translate",
String.format(
"Translating %s from project space \"%s\" to \"%s\"",
codebaseToTranslate.getPath(), codebaseToTranslate.getProjectSpace(), toProjectSpace));
Codebase translatedCodebase =
translator.translate(codebaseToTranslate, translateOp.term.options, context);
// Don't mark the translated codebase for persistence if it wasn't allocated by the Translator.
if (translatedCodebase.equals(codebaseToTranslate)) {
AppContext.RUN.ui.popTask(translateTask, translatedCodebase.getPath() + " (unmodified)");
} else {
AppContext.RUN.ui.popTaskAndPersist(translateTask, translatedCodebase.getPath());
}
return translatedCodebase.copyWithExpression(this).copyWithProjectSpace(toProjectSpace);
}