Bug 506328 - [cs2as] Supporting a qvtd-based CS2AS for the Delphi example
Summary: [cs2as] Supporting a qvtd-based CS2AS for the Delphi example
Status: NEW
Alias: None
Product: QVTd
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 8
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 506388 506626 506751
Blocks:
  Show dependency tree
 
Reported: 2016-10-21 07:22 EDT by Adolfo Sanchez-Barbudo Herrera CLA
Modified: 2016-10-30 12:47 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adolfo Sanchez-Barbudo Herrera CLA 2016-10-21 07:22:38 EDT
Hi Ed,

I'm starting to execute some CS2AS transformation for the Gra2Mol Delphi example, but they are not doing what I expect. I'm raising this bugzilla to discuss and track any issue that arises during the compilation and execution of the this example.

There are two repros, one for producing the java CS2AS transformation, and another one to execute the examples. From my github repository (master branch) [1]

1) Compilation:
- Download org.xtext.example.delphi and org.xtext.example.delphi.build.
- Execute GenerateCS2ASTx.mwe2 [2].
- Currently, the compilation process finishes without errors.

2) Execution:
- Download org.xtext.example.delphi
- Select DelphiTester [3]
- Right click -> Run As -> Java Application
- Currently, the transformation executes but the output models are incorrect (e.g. lots of objects as root model elements).

I'll do some investigation about what could be going wrong, but for the time being, I think there is something you could look at: I see some errors in the generated Delphi.qvtias [4] transformation that need attention.

[1] https://github.com/adolfosbh/cs2as
[2] org.xtext.example.delphi.build\src\org\xtext\example\companies\build\mwe\GenerateCS2ASTx.mwe2
[3] org.xtext.example.delphi\src\org\xtext\example\delphi\test\DelphiTester.java
[4] org.xtext.example.delphi\model\temp\Delphi.qvtias
Comment 1 Ed Willink CLA 2016-10-21 10:08:42 EDT
(In reply to Adolfo Sanchez-Barbudo Herrera from comment #0)
> 1) Compilation:
> - Download org.xtext.example.delphi and org.xtext.example.delphi.build.

Edit the hardwired path to the QVTd GIT projects.

> I see some errors in
> the generated Delphi.qvtias transformation that need attention.

A major problem is an NPE in Iterables.size() if a type has no properties.

Lesser problems are failures to generate non-clashing names for working variables. Need to excluide all possible type names since the author may be pursuing the really bad practice of same feature/type spelling.

The above are all in AS2CS, so the generated Java should be unaffected; just harder to debug without the QVTi source visibility.
Comment 2 Ed Willink CLA 2016-10-21 10:32:41 EDT
(In reply to Adolfo Sanchez-Barbudo Herrera from comment #0) 
> I'll do some investigation about what could be going wrong

At least one problem comes from

context tryStmt
def : ast() : as::astm::TryStatement =
as::astm::TryStatement {
	guardedStatement = stmtList.statments->first().ast(),  
	finalStatement = final.statments->first().ast() 
}

where "stmtList" is interpreted as a type giving a Class in the generated code. There is already one warning on the line.

The 'PropertyCallExp::NonStaticSourceTypeIsConformant' constraint
   is violated for 'delphi::stmtList.statments'

which is perhaps not as explicit as it could be about static/non-static usage.

But the Complete OCL editor has useful validation. Ignoring it is very foolish.
Comment 3 Ed Willink CLA 2016-10-21 10:49:21 EDT
(In reply to Ed Willink from comment #1)
> A major problem is an NPE in Iterables.size() if a type has no properties.

Introduced by Bug 506228.

> Lesser problems are failures to generate non-clashing names for working
> variables. Need to excluide all possible type names since the author may be
> pursuing the really bad practice of same feature/type spelling.

Bug 506352.
Comment 4 Adolfo Sanchez-Barbudo Herrera CLA 2016-10-21 11:30:28 EDT
I've revised (and pushed) the two missing disambiguating self expressions. When assigning "incompatible" collections to shadow parts, I tend to simply ignore them, because I think the M2M engine (must) work well with them.

I'm trying to analyse/detect more issues on the source files (i.e the Complete OCL documents).
Comment 5 Adolfo Sanchez-Barbudo Herrera CLA 2016-10-21 11:54:52 EDT
Another issue. Not sure if you experience the same, but I'm also having different issues when opening either qvtp.qvtcas nor qvtias with the reflective tree-form editor. For instance, a first error appears saying:

- Resource '/org.xtext.example.delphi/model/delphi.qvtp.qvtcasas' does not exist
- Resource '/org.xtext.example.delphi/model/temp/Delphi.qvtiasas' does not exist

Validation also shows many problems.
Comment 6 Ed Willink CLA 2016-10-21 12:00:15 EDT
(In reply to Adolfo Sanchez-Barbudo Herrera from comment #5)
> - Resource '/org.xtext.example.delphi/model/delphi.qvtp.qvtcasas' does not
> exist

I'm looking at this right now. It seems to be a side effect of stale Problem View Markers. If you delete them, I think it goes away.
Comment 7 Ed Willink CLA 2016-10-21 12:10:18 EDT
(In reply to Ed Willink from comment #6)
> (In reply to Adolfo Sanchez-Barbudo Herrera from comment #5)
> > - Resource '/org.xtext.example.delphi/model/delphi.qvtp.qvtcasas' does not
> > exist
> 
> I'm looking at this right now. It seems to be a side effect of stale Problem
> View Markers. If you delete them, I think it goes away.
I think it is the same problem as Bug 502289.

Stepping, I see that 

      String relatedURIsAttribute = marker.getAttribute(EValidator.RELATED_URIS_ATTRIBUTE, null);

is

175:platform:/resource/org.xtext.example.delphi/model/Delphi.qvtp.qvtcasas#//@ownedPackages.0/@ownedClasses.0/@rule.24/@bottomPattern/@assignment.0/@value/@ownedParts.1/@ownedInit

even though

      String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);

is

platform:/resource/org.xtext.example.delphi/model/Delphi.qvtp.qvtcas#//@ownedMappings.24/@ownedMiddle/@ownedBottomPattern/@ownedConstraints.0/@ownedInitExpression/@ownedCurlyBracketedClause/@ownedParts.1/@ownedInitExpression

--

"ownedMappings" is a stale feature name.
Comment 8 Ed Willink CLA 2016-10-21 13:39:32 EDT
(In reply to Ed Willink from comment #7)
> "ownedMappings" is a stale feature name.

No. An AS Feature used in a CS URI.

There are two underlying problems.

When using an AS editor, the CSResource is incorrectly named *.qvtcasas rather than *.qvtc. Fixing this inverts the markers problem. *.qvtc is now missing.

----

Validation is performed on the AS.

When using a CS editor the problem markers are re-URI-ed to replace the AS URIs by CS URIs in PivotDiagnosticConverter.getCauser(). The problem markers then refer consistently to the CS.

This re-URI-ing should not occur for an AS editor so that problem markers refer consistently to the AS.
Comment 9 Ed Willink CLA 2016-10-22 06:09:03 EDT
Seems much better, but tidying up and making it work for OCLinEcore too and it all falls apart.....

Problem is doubly horrible code. The 'clever' Xtext overloads to enable an auto AS2CS and CS2AS to wrap a CS edit are horrible. Making the code dual purpose to support AS or CS editing pushes it beyond intelligibility.

One level of horrible can be removed by using distinct editor classes for CS and AS editing. Raised as Bug 506380.
Comment 10 Ed Willink CLA 2016-10-22 10:11:19 EDT
(In reply to Ed Willink from comment #9)
> Seems much better, but tidying up and making it work for OCLinEcore too and
> it all falls apart.....

Problem is that PivotResourceValidator.getCauser must return an AS element when the primary edit is of the AS, but must return a CS element when returning the location. Horrible locationInProgress status workaround added.

Hopefully "much better" again. Pushed to master for M3.

Main outstanding validation bug is Bug 412341.
Comment 11 Adolfo Sanchez-Barbudo Herrera CLA 2016-10-22 10:19:34 EDT
Hi Ed,

How do you want to deal with the bugzilla about all the problems which arisen from the example ? I was thinking of creating more bugzillas having this one as the central (blocked) one. The repro is basically the same.

Do you prefer completely "unrelated" new bugzillas ?

Regards,
Adolfo.
Comment 12 Adolfo Sanchez-Barbudo Herrera CLA 2016-10-22 10:22:14 EDT
Sorry... 

(In reply to comment #11)
> How do you want to deal with the bugzilla about all the problems which arisen
> from the example ? I was thinking of creating more bugzillas having this one as
> the central (blocked) one. The repro is basically the same.
> 
> Do you prefer completely "unrelated" new bugzillas ?
> 

Otherwise (third alternative), go on adding more comments in this one.
Comment 13 Ed Willink CLA 2016-10-22 10:28:39 EDT
I think it works better if I fork off specific Bugzillas and you add observations.

I'm not aware of anything outstanding. Hopefully the recent [506328] commits make validation more useful. I-builds soon.
Comment 14 Adolfo Sanchez-Barbudo Herrera CLA 2016-10-22 10:37:18 EDT
(In reply to comment #13)
> I think it works better if I fork off specific Bugzillas and you add
> observations.
Ok. I think I'll take the same approach. 

> I'm not aware of anything outstanding. Hopefully the recent [506328] commits
> make validation more useful. I-builds soon.

Well, this bug is not solved as the transformation is not doing what I expected to do :P, but your fixes on the tooling wil definitelyl help me/us to more easily identify what's going on wrong. If something wrong in the transformation definition, or something in the QVTd code. I've already discovered a problem for which I'm working on a report.