Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Generating Java code for models with link errors
Generating Java code for models with link errors [message #1240934] Fri, 07 February 2014 08:43 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

As mentioned in a previous post, I've written a small DSL for writing
junit tests, as an example for a presentation and for use in a course
with test-based exercises. The typical way of using it is:
- preparing a solution (e.g. Person.java)
- writing the tests that link to the solution (Person.jextest)
- generating the test code (PersonTest.java) and provding it to the students

When the students start working (on their own version of the solution
(Person.java) there are naturally lots of error markers in the test
code, but the smart Eclipse parser is nevertheless able to generate and
execute it fairly quickly (with a minimal of working solution code). I'm
now looking at making the students use the DSL directly (not write, just
generate test code and executing the tests). This requires, that the
DSL's generator executes and generates meaningful code in the presences
of (lots of) linking errors (in JvmTypeReferences and XExpressions).
However, the generator isn't called until the model validates, which
won't happen until the student has written (stubs for) all the methods
required by the whole test. I would like to enable the generator as long
as the error markers are considered acceptable (in general local to in
JvmTypeReferences and XExpressions), and just make sure the generator is
fault tolerant.

How can this be done?

Hallvard
Re: Generating Java code for models with link errors [message #1240958 is a reply to message #1240934] Fri, 07 February 2014 09:12 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

After search for occurrences of IGenerator, I think I've found the
solution: Bind a custom BuilderParticipant in the UIModule and override
the shouldGenerate method. Here the Resource's Diagnostics are
available, and I can check the kind of error (XtextLinkingDiagnostic).
I'm currently looking for a way to find the offending model element, to
see if the linking problem is in an acceptable place.

Hallvard

On 07.02.14 09:43, Hallvard Trætteberg wrote:
> Hi,
>
> As mentioned in a previous post, I've written a small DSL for writing
> junit tests, as an example for a presentation and for use in a course
> with test-based exercises. The typical way of using it is:
> - preparing a solution (e.g. Person.java)
> - writing the tests that link to the solution (Person.jextest)
> - generating the test code (PersonTest.java) and provding it to the
> students
>
> When the students start working (on their own version of the solution
> (Person.java) there are naturally lots of error markers in the test
> code, but the smart Eclipse parser is nevertheless able to generate and
> execute it fairly quickly (with a minimal of working solution code). I'm
> now looking at making the students use the DSL directly (not write, just
> generate test code and executing the tests). This requires, that the
> DSL's generator executes and generates meaningful code in the presences
> of (lots of) linking errors (in JvmTypeReferences and XExpressions).
> However, the generator isn't called until the model validates, which
> won't happen until the student has written (stubs for) all the methods
> required by the whole test. I would like to enable the generator as long
> as the error markers are considered acceptable (in general local to in
> JvmTypeReferences and XExpressions), and just make sure the generator is
> fault tolerant.
>
> How can this be done?
>
> Hallvard
Previous Topic:Cross references in DSLs of xtext
Next Topic:Using step filters when debugging DSL
Goto Forum:
  


Current Time: Tue Sep 24 23:45:38 GMT 2024

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

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

Back to the top