EditorAction on Acceleo-Editor [message #1413685] |
Fri, 29 August 2014 06:56 |
Alexander R Messages: 211 Registered: July 2013 |
Senior Member |
|
|
Hello,
I want to do the following, and wanted to ask for the best way to achieve it:
1. I want to select some text in an acceleo editor
2. I want to find the underlying model-element to the selected text (find the metamodel-instance, and the selected element)
At the moment I am able to achieve 1 by implementing IEditorActionDelegate and using the selectionChanged-method. So I have the lenght and offset of the selected textpart. Then I looked around the acceleo-code and found this class: AcceleoSourceContent. With an instance of this class I can get a
CSTNode by using following code:
int startPos = sel.getOffset();
int endPos = sel.getOffset() + sel.getLength();
AcceleoSourceContent mtlSource = this.editor.getContent();
// create the model
mtlSource.createCST();
org.eclipse.acceleo.parser.cst.Module modelModule = mtlSource.getCST();
CSTNode foundCSTNode = mtlSource.getCSTNode(startPos, endPos);
But I think this is not the right way, because the modelModule is not the expected mtl-model. In the org.eclipse.acceleo.model project I found several metamodels.
What are these models: mtl.ecore, MTLCST.ecore, AST-model ?
Is there maybe a nice way to find an mtl-element corresponding to the selected text? Or is there maybe a mechanisn to map an CST-Element to a MTL-Element?
All hints are welcome!
~Alex
[Updated on: Fri, 29 August 2014 07:50] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03765 seconds