[Solved] How2 access top AST from Validator,Quickfix,Proposal [message #1385914] |
Thu, 12 June 2014 09:05 |
Uli Merkel Messages: 250 Registered: June 2013 |
Senior Member |
|
|
I'm a newbie in XTEXT as well as in JAVA,
so I need some detailed example for a kickstart:
I customise Validator and Quickfix for an issue deep down in the AST levels.
There I need to access to an attribute of the topmost (Model) level.
Something like:
if (model.isSimple) ....
In the generator, I use
makeTheCif(resource.contents.head as Model)
What is the easiest way to do so in Validator, Proposal and QuickFix?
[Updated on: Tue, 17 June 2014 14:30] Report message to a moderator
|
|
|
|
|
|
Re: How2 access top AST from Validator,Quickfix,Proposal [message #1386251 is a reply to message #1386146] |
Mon, 16 June 2014 07:49 |
Uli Merkel Messages: 250 Registered: June 2013 |
Senior Member |
|
|
ok, here is the code that works for me:
Both are based on the EcoreUtil2.getRootContainer method
in the validator:
def checkMergefileVariablesShouldNotBeEmpty(Mergefile mergefile) {
val EObject myObject = mergefile
var rootContainer = EcoreUtil2.getRootContainer(myObject) as Model
System.out.println(rootContainer.name)
in the quickfix, I had to extend the arguments to include "element" to make it work:
def addMergefileValues(Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, 'variables set empty', 'Generate variable set.', '')
[ element, context |
var rootContainer = EcoreUtil2.getRootContainer(element) as Model
System.out.println("quickfix-calls: " + rootContainer.name)
[Updated on: Mon, 16 June 2014 07:50] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.25598 seconds