Search code examples
javaantlrxtextxtend

XText Validation - Get the raw input during validation


I'm writing a grammar that has an existing validator. I'd like to use the existing validator to validate the code, and integrate it with the built in XText validation mechanism, so it will work seamlessley.

How can I :

A) - Access the raw code so I can pass it to the external validator?

B) - Having parsed the output of the validator, pass the result back to the eclipse UI?


Solution

  • if you want to have access to the textual part of the model aka "node model" NodeModelUtils will give you helper methods to get the node for an EObject.

    Alternatively your EObject may have a eResourcewhich may be a XtextResourcewhich may have a parseResultwhich gives you access to the rootNode.

    you can always ask an INodefor its text.

    you have to do creating the Xtext Errors from your "other Parsers" errors yourself manually.