Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Loading XText resources in eclipse plugin does not resolve proxies
Loading XText resources in eclipse plugin does not resolve proxies [message #1270319] Wed, 12 March 2014 21:26 Go to next message
Mario Mohr is currently offline Mario MohrFriend
Messages: 3
Registered: June 2011
Junior Member
Hi,

I've created two Xtext DSLs (CalculationTypes, VariableTypes). The CalculationTypes dsl contains references to VariableTypes. The XText editor is working fine.

Now I want to read the dsl files in a Graphiti editor to fill the editor palette.

The following code in standalone context is working fine and printing the name of the variable type:

public class TestStandaloneLoading {
	
	public static void main(String[] args) {
		CalculationTypesStandaloneSetup.doSetup();
		VarTypesStandaloneSetup.doSetup();
		VarTypesPackage einstance = VarTypesPackage.eINSTANCE;
		CalculationTypePackage einstance2 = CalculationTypePackage.eINSTANCE;
		ResourceSet set = new ResourceSetImpl();
		Resource vartypesRes = set.getResource(URI.createFileURI("E:/Projects/calculation-engine/example/DSLExample/src/basic.vartypesdsl"), true);
		Resource calctypesRes = set.getResource(URI.createFileURI("E:/Projects/calculation-engine/example/DSLExample/src/basic.calctypesdsl"), true);
		EcoreUtil.resolveAll(vartypesRes);
		EcoreUtil.resolveAll(calctypesRes);
		CalculationDefinitions calcDefs = (CalculationDefinitions) calctypesRes.getContents().get(0);
		System.out.println(calcDefs.getDefinitions().get(0).getParameters().get(0).getVariableType().getName());
	}
	
}


The following code in an eclipse plugin (Graphiti Editor) prints "Varibale Type name: null" because the reference to the variable type is not resolved.

public Loader2(){
		resourceSetImpl = new ResourceSetImpl();
		Resource vartypes = resourceSetImpl.getResource(URI.createPlatformResourceURI("DSLExample/src/basic.vartypesdsl",true), true);
		EcoreUtil.resolveAll(vartypes);
		Resource calctypes = resourceSetImpl.getResource(URI.createPlatformResourceURI("DSLExample/src/basic.calctypesdsl",true), true);
		EcoreUtil.resolveAll(calctypes);
		CalculationDefinitions calcDefs = (CalculationDefinitions) calctypes.getContents().get(0);
		System.out.println("Varibale Type name " + calcDefs.getDefinitions().get(0).getParameters().get(0).getVariableType().getName());
}


The editor plugin has dependencies to the dsl plugins and the loading itself works fine. Only the proxys are not resolved.

Does anybody have any clue on what I'm doing wrong?

Thanks,
Mario
Re: Loading XText resources in eclipse plugin does not resolve proxies [message #1270337 is a reply to message #1270319] Wed, 12 March 2014 22:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i just gave it a little try. i have two dsl plugins and one command plugins that has a dep to both ui plugins and it works fine.
in which context do you execute that code
public class ZHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		ResourceSet resourceSet = new ResourceSetImpl();
		Resource vartypes = resourceSet.getResource(URI.createPlatformResourceURI("Dully/src/a.mydsla",true), true);
		Resource calctypes = resourceSet.getResource(URI.createPlatformResourceURI("Dully/src/b.mydslb",true), true);
		Model calcDefs = (Model) calctypes.getContents().get(0);
		System.out.println("Varibale Type name " + calcDefs.getUses().get(0).getDef().getName());
		return null;
	}
}



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Loading XText resources in eclipse plugin does not resolve proxies [message #1270344 is a reply to message #1270337] Wed, 12 March 2014 22:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.s: please check if you have build automatically on and the project has xtext nature

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Loading XText resources in eclipse plugin does not resolve proxies [message #1270927 is a reply to message #1270319] Thu, 13 March 2014 21:25 Go to previous messageGo to next message
Mario Mohr is currently offline Mario MohrFriend
Messages: 3
Registered: June 2011
Junior Member
Hi Christian,

thanks for your reply. My project has the Xtext nature and automatic building enabled. The files are loaded when the palette for a Graphiti editor is created. The dsl also has a dependency to XBase, might that be a problem?

Thanks,
Mario
Re: Loading XText resources in eclipse plugin does not resolve proxies [message #1271045 is a reply to message #1270927] Fri, 14 March 2014 05:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Yes. Maybe. I will have a look

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Loading XText resources in eclipse plugin does not resolve proxies [message #1271048 is a reply to message #1271045] Fri, 14 March 2014 06:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
P.s can you please share the two sample grammars and models ...

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Loading XText resources in eclipse plugin does not resolve proxies [message #1271062 is a reply to message #1271048] Fri, 14 March 2014 06:47 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Pps. Did you try to obtain the resource set by a injected
iresourcesetprovider

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Error in Xtext/Xbase tutorial
Next Topic:Simplified include
Goto Forum:
  


Current Time: Thu Apr 25 13:43:58 GMT 2024

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

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

Back to the top