Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Iterating over extensions
Iterating over extensions [message #541996] Wed, 23 June 2010 13:38 Go to next message
Nadya is currently offline NadyaFriend
Messages: 1
Registered: June 2010
Junior Member

I want to use my extension file as a library where I storage different functions. In order to implement a matching method which picks a function from the library for me, I want to iterate over the extensions (i.e. these functions) from a Java class. XtendFacade has not an access to the extensions. Has anyone here an idea how can I do that? Thanks for your comments!

Regards, Nadya
Re: Iterating over extensions [message #545575 is a reply to message #541996] Thu, 08 July 2010 10:02 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 7679
Registered: July 2009
Senior Member
Hi, it is right that the extension facade hides this but a look into its code shows that something like this can done:

import org.eclipse.internal.xtend.xtend.ast.Extension;
import org.eclipse.xtend.expression.ExecutionContext;
import org.eclipse.xtend.expression.ExecutionContextImpl;
import org.eclipse.xtend.expression.Resource;
import org.eclipse.xtend.expression.TypeSystemImpl;

public class Main {
	public static void main(String[] args) {
		ExecutionContext executionContext = createExecutionContext("template::test");
		((ExecutionContextImpl)executionContext).registerMetaModel(new JavaBeansMetaModel());
		for (Extension e : executionContext.getAllExtensions()) {
	private static ExecutionContext createExecutionContext(final String... extensions) {
		ExecutionContext executionContext = new ExecutionContextImpl(new TypeSystemImpl());
		executionContext = executionContext.cloneWithResource(new Resource() {

			public String getFullyQualifiedName() {
				return null;

			public void setFullyQualifiedName(final String fqn) {


			public String[] getImportedNamespaces() {
				return null;

			public String[] getImportedExtensions() {
				return extensions;
		return executionContext;


This prints all extensions in the given extension file.
This might solve your problem although i do not understand your usecase.


[Updated on: Thu, 08 July 2010 10:21]

Report message to a moderator

Previous Topic:[XPAND] WorkflowInterruptedException: EvaluationException : Nullevaluation
Next Topic:[xpand] fixed indentation
Goto Forum:

Current Time: Tue Oct 06 08:14:36 GMT 2015

Powered by FUDForum. Page generated in 0.03451 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software