Search in sources :

Example 1 with Extension

use of org.eclipse.internal.xtend.xtend.ast.Extension in project xtext-core by eclipse.

the class XtendXtext2EcorePostProcessor method process.

@Override
public void process(GeneratedMetamodel metamodel) {
    Resource xtendFile = loadXtendFile(metamodel);
    if (xtendFile != null) {
        ExecutionContext ctx = getExecutionContext(metamodel);
        ctx = ctx.cloneWithResource(xtendFile);
        ResourceLoader currentThreadResourceLoader = null;
        try {
            currentThreadResourceLoader = getCurrentThreadResourceLoader();
            setCurrentThreadResourceLoader(getResourceLoader(metamodel));
            final Object[] params = new Object[] { metamodel };
            Extension extension = ctx.getExtension("process", params);
            if (extension != null) {
                extension.evaluate(params, ctx);
            }
        } catch (EvaluationException e) {
            logger.error("Error encountered processing metamodel " + metamodel.getName() + " with " + xtendFile.getFullyQualifiedName(), e);
        } finally {
            setCurrentThreadResourceLoader(currentThreadResourceLoader);
        }
    }
}
Also used : Extension(org.eclipse.internal.xtend.xtend.ast.Extension) ResourceLoaderFactory.setCurrentThreadResourceLoader(org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory.setCurrentThreadResourceLoader) ResourceLoader(org.eclipse.emf.mwe.core.resources.ResourceLoader) ResourceLoaderFactory.getCurrentThreadResourceLoader(org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory.getCurrentThreadResourceLoader) ExecutionContext(org.eclipse.xtend.expression.ExecutionContext) Resource(org.eclipse.xtend.expression.Resource) EvaluationException(org.eclipse.xtend.expression.EvaluationException)

Aggregations

ResourceLoader (org.eclipse.emf.mwe.core.resources.ResourceLoader)1 ResourceLoaderFactory.getCurrentThreadResourceLoader (org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory.getCurrentThreadResourceLoader)1 ResourceLoaderFactory.setCurrentThreadResourceLoader (org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory.setCurrentThreadResourceLoader)1 Extension (org.eclipse.internal.xtend.xtend.ast.Extension)1 EvaluationException (org.eclipse.xtend.expression.EvaluationException)1 ExecutionContext (org.eclipse.xtend.expression.ExecutionContext)1 Resource (org.eclipse.xtend.expression.Resource)1