Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Conditional parsing
Conditional parsing [message #769139] Wed, 21 December 2011 13:18 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I have a DSL, i.e. an Ecore model and Xtext grammar, that includes
features and rules that refer to JvmTypes. The code generator for the
DSL can have different targets, so in some cases some of the references
will not link because the corresponding JvmType isn't available. To
avoid processing elements that don't belong to the target (and hence
cannot be linked), the model include simple flags that turn elements
off, depending on some flags I can set. The problem is that I anyhow get
a validation error in the workflow that prevents the generator from
being executed:
299: Couldn't resolve reference to JvmGenericType 'viewers.Viewer'.
java.lang.RuntimeException: Problems running workflow
org.eclipse.gmt.generator.EmfacadeRwtGenerator: Validation problems:
1 error:
swt.xef -
/Users/hal/java/workspaces/emfacade/org.eclipse.gmt.emfacade.rwt.builder.dev/model/swt.xef
299: Couldn't resolve reference to JvmGenericType 'viewers.Viewer'.
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:99)

I essentially want to ignore linking errors for elements that are turned
off, but how can I hook into the validator, to implement this?

Hallvard
Re: Conditional parsing [message #769154 is a reply to message #769139] Wed, 21 December 2011 13:44 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hallvard,

please bind a custom
org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 21.12.11 14:18, schrieb Hallvard Trætteberg:
> Hi,
>
> I have a DSL, i.e. an Ecore model and Xtext grammar, that includes
> features and rules that refer to JvmTypes. The code generator for the
> DSL can have different targets, so in some cases some of the references
> will not link because the corresponding JvmType isn't available. To
> avoid processing elements that don't belong to the target (and hence
> cannot be linked), the model include simple flags that turn elements
> off, depending on some flags I can set. The problem is that I anyhow get
> a validation error in the workflow that prevents the generator from
> being executed:
> 299: Couldn't resolve reference to JvmGenericType 'viewers.Viewer'.
> java.lang.RuntimeException: Problems running workflow
> org.eclipse.gmt.generator.EmfacadeRwtGenerator: Validation problems:
> 1 error:
> swt.xef -
> /Users/hal/java/workspaces/emfacade/org.eclipse.gmt.emfacade.rwt.builder.dev/model/swt.xef
>
> 299: Couldn't resolve reference to JvmGenericType 'viewers.Viewer'.
> at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:99)
>
> I essentially want to ignore linking errors for elements that are turned
> off, but how can I hook into the validator, to implement this?
>
> Hallvard
Re: Conditional parsing [message #769180 is a reply to message #769154] Wed, 21 December 2011 14:28 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 21.12.11 14.44, Sebastian Zarnekow wrote:
>
> please bind a custom
> org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider

Fantastic, it worked! For each error I just walk up the container
hierarchy and if one of the parents is flagged as not part of the
target, I just return null instead of creating an error message.

The way you design for and use injection is really neat and fascinating.

Hallvard
Previous Topic:Override getExportedObjects
Next Topic:Discouraged access warnings from Xbase
Goto Forum:
  


Current Time: Thu Apr 25 23:11:46 GMT 2024

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

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

Back to the top