Bug 468090 - [codegen] Better code generation error reporting
Summary: [codegen] Better code generation error reporting
Status: CLOSED FIXED
Alias: None
Product: Papyrus-rt
Classification: Modeling
Component: codegen (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal
Target Milestone: 1.0.0   Edit
Assignee: Ernesto Posse CLA
QA Contact:
URL:
Whiteboard:
Keywords: Documentation
Depends on:
Blocks:
 
Reported: 2015-05-22 17:24 EDT by Ernesto Posse CLA
Modified: 2017-07-17 11:58 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ernesto Posse CLA 2015-05-22 17:24:18 EDT
Many errors in code generation are due to model errors. Many of these result in
errors while translating to the new intermediate meta-model.

The translator should catch these errors and provide better error reporting,
pointing to the relevant UML element that caused the problem.



A patch has been merged which catches many errors but not all.

It catches several of the most common errors, like missing types in features (parameters, ports, parts, etc.)

When the error occurs, it produces an exception with some detailed information:

- A message
- The fully qualified name of the UML Element under consideration
- The name of the feature within the element which is causing a problem
- The expected UML type for the feature in question
- The expected type returned by the translation to the intermediate meta-model
- The actual UML type for the feature 
- The actual translated type in the new meta-model

More errors should be catched, not only by the translator, but in later stages.
Comment 1 Ernesto Posse CLA 2015-06-19 11:04:48 EDT
Changed component to 'codegen' and marked as accepted.
Comment 2 Simon Redding CLA 2016-02-05 16:28:50 EST
Does not gate the June release 1.0 Papyrus-RT release
Comment 3 Charles Rivet CLA 2016-10-31 12:33:48 EDT
Such error reporting would help in supporting the product.
Need evaluation of effort required
Moving to 0.9.0 for assessment.
Comment 4 Eclipse Genie CLA 2017-06-08 16:44:59 EDT
New Gerrit change created: https://git.eclipse.org/r/98962
Comment 6 Eclipse Genie CLA 2017-06-13 15:18:53 EDT
New Gerrit change created: https://git.eclipse.org/r/99274
Comment 7 Eclipse Genie CLA 2017-06-13 15:26:21 EDT
New Gerrit change created: https://git.eclipse.org/r/99276
Comment 9 Eclipse Genie CLA 2017-07-14 16:20:03 EDT
New Gerrit change created: https://git.eclipse.org/r/101303
Comment 11 Ernesto Posse CLA 2017-07-14 17:31:51 EDT
The change with the latest improvements is merged, but should we marked it as "resolved"? The bug is a bit too open-ended. We could move it to future, to add further improvements later, or we could mark it as resolved and future improvements would be addressed by explicit bugs.
Comment 12 Peter Cigehn CLA 2017-07-17 05:34:40 EDT
(In reply to Ernesto Posse from comment #11)
> The change with the latest improvements is merged, but should we marked it
> as "resolved"? The bug is a bit too open-ended. We could move it to future,
> to add further improvements later, or we could mark it as resolved and
> future improvements would be addressed by explicit bugs.

As you say, these kind of "open-ended" bugs is hard to mark as resolve and could continue to stay open forever. I suggest to mark it as resolved fixed as "good enough" for 1.0. Further improvements should then be tracked by separate, more explicit bugs. One such future improvement is of course the integration with the problems view and the double-click support to navigate to the offending model element.

In my view, the most important is that we have a "framework" in place for reporting any kind of error/warning from the code-generator, where it should be very easy (a few lines of code) to add a check and reporting of a new error/warning (which is then tracked with an explicit bug). I hope/assume that this bug has ensured that such a "framework" is in place, and if so then it can be considered to be resolved.
Comment 13 Charles Rivet CLA 2017-07-17 09:04:32 EDT
(In reply to Peter Cigehn from comment #12)
> (In reply to Ernesto Posse from comment #11)
> > The change with the latest improvements is merged, but should we marked it
> > as "resolved"? The bug is a bit too open-ended. We could move it to future,
> > to add further improvements later, or we could mark it as resolved and
> > future improvements would be addressed by explicit bugs.
> 
> As you say, these kind of "open-ended" bugs is hard to mark as resolve and
> could continue to stay open forever. I suggest to mark it as resolved fixed
> as "good enough" for 1.0. Further improvements should then be tracked by
> separate, more explicit bugs. One such future improvement is of course the
> integration with the problems view and the double-click support to navigate
> to the offending model element.
> 
> In my view, the most important is that we have a "framework" in place for
> reporting any kind of error/warning from the code-generator, where it should
> be very easy (a few lines of code) to add a check and reporting of a new
> error/warning (which is then tracked with an explicit bug). I hope/assume
> that this bug has ensured that such a "framework" is in place, and if so
> then it can be considered to be resolved.

I concur with Peter's statement. I think we should move this but to closure and create a "Future" bug to address new bugs, starting with Peter's suggestion for "Integration with the problems view and the double-click support to navigate to the offending model element".
Comment 14 Ernesto Posse CLA 2017-07-17 10:29:52 EDT
(In reply to Peter Cigehn from comment #12)
> (In reply to Ernesto Posse from comment #11)
> > The change with the latest improvements is merged, but should we marked it
> > as "resolved"? The bug is a bit too open-ended. We could move it to future,
> > to add further improvements later, or we could mark it as resolved and
> > future improvements would be addressed by explicit bugs.
> 
> As you say, these kind of "open-ended" bugs is hard to mark as resolve and
> could continue to stay open forever. I suggest to mark it as resolved fixed
> as "good enough" for 1.0. Further improvements should then be tracked by
> separate, more explicit bugs. One such future improvement is of course the
> integration with the problems view and the double-click support to navigate
> to the offending model element.
> 
> In my view, the most important is that we have a "framework" in place for
> reporting any kind of error/warning from the code-generator, where it should
> be very easy (a few lines of code) to add a check and reporting of a new
> error/warning (which is then tracked with an explicit bug). I hope/assume
> that this bug has ensured that such a "framework" is in place, and if so
> then it can be considered to be resolved.

The "framework" put in place is essentially this: in the code generator, we have validation performed in different places:

1) on the UML model, before translating to XtUML-RT
2) on the UML model, during the translation to XtUML-RT
3) on the XtUML-RT model, after the translation

The bulk of the validation is done in steps 1 and 2.

Step 1 is the natural place to put new validation rules. This corresponds more closely with the semantic validation of the language.

Most of the validation done in step 2 pertains translation: it consists of checking that whenever a UML Element's feature is being translated, the feature is not null (unless it is allowed), that the feature's content has the expected type, and the translated feature has the expected type.

Steps 2 and 3 will eventually disappear when we remove the XtUML-RT model altogether. Nevertheless, validation in step 3 was added manly with the idea of supporting code generation directly from XtUML-RT (e.g. starting with a textual model) or possibly from other models translated into XtUML-RT, like XtUML, as it was originally designed for that purpose. 

I just want to state for the record something that I've said before: codegen validation is not a "catch-all" validation, and in particular, there are problems that it cannot resolve. For example if a UML Property intended to be a capsule part doesn't have the CapsulePart stereotype. In such cases, the translator cannot guess the user's intentions, so we cannot issue either a warning or an error (because perhaps the user did intend to make it into a normal Property) but the later phases may result in errors that may seem unrelated. This sort or problem should not occur if we have models which are "correct by construction", but there are several scenarios which may lead to such errors:

1) there could be bugs in the tooling that do not make the model correct-by-construction
2) there could be bugs introduced by new versions of the tooling (I've seen this happening all the time with diagrams; I would expect that the models are a bit more "solid", but I'm not 100% sure that's always the case)
3) the model could be corrupted somehow
4) the model may have been produced, not by our tooling, but by something else, e.g. some user customization of the tooling, or some programmatically generated model.

So in summary, codegen validation should not be considered a replacement to proper validation.
Comment 15 Ernesto Posse CLA 2017-07-17 10:30:08 EDT
Verified.
Comment 16 Ernesto Posse CLA 2017-07-17 10:30:23 EDT
Closing.
Comment 17 Peter Cigehn CLA 2017-07-17 10:37:39 EDT
(In reply to Ernesto Posse from comment #14)
> So in summary, codegen validation should not be considered a replacement to
> proper validation.

Yes, and validations are tracked separately with Bug 492833.