Loading XText resources in eclipse plugin does not resolve proxies [message #1270319] |
Wed, 12 March 2014 21:26 |
Mario Mohr 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 |
|
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
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04730 seconds