[xcore] Error in the generated code, when a type with generics is wrapped and used as argument [message #1776433] |
Thu, 16 November 2017 12:31 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
Error in the generated code, when a type with generics is wrapped an used an argument
Here minimal example that produce compile errors:
@GenModel(
bundleManifest="false",
modelDirectory="xcore-maven-example/src/main/java-gen",
complianceLevel="8.0"
)
package simple.model
interface MyMap wraps java.util.Map<String, String> {}
class Author {
String name
op String operationA(MyMap tmp) {
"Hello " + this.name
}
}
I get these errors (java compilation errros):
| Description | Resource | Path | Location | Type |
+-----------------------------------------------------------------+-----------------------+----------------------------+----------+--------------+
| Syntax error on token "(", Expression expected after this token | ModelPackage.java | /src-gen/sample/model | line 234 | Java Problem |
| Syntax error on token "(", Expression expected after this token | ModelPackageImpl.java | /src-gen/sample/model/impl | line 213 | Java Problem |
| Syntax error on token ">", delete this token | ModelPackage.java | /src-gen/sample/model | line 123 | Java Problem |
| Syntax error on token ">", delete this token | ModelPackage.java | /src-gen/sample/model | line 175 | Java Problem |
| Syntax error on token ">", delete this token | ModelPackage.java | /src-gen/sample/model | line 234 | Java Problem |
| Syntax error on token ">", delete this token | ModelPackageImpl.java | /src-gen/sample/model/impl | line 136 | Java Problem |
| Syntax error on token ">", Expression expected after this token | AuthorImpl.java | /src-gen/sample/model/impl | line 172 | Java Problem |
| Syntax error on token ">", Expression expected after this token | ModelPackageImpl.java | /src-gen/sample/model/impl | line 172 | Java Problem |
| Void methods cannot return a value | ModelPackageImpl.java | /src-gen/sample/model/impl | line 137 | Java Problem |
When I look at the generated code, it is really broken. Example in ModelPackage:
EOperation getAuthor__OperationA__String>();
This is really due to generics, because if you change the wrapped type to a type without generics, everything works well:
@GenModel(
bundleManifest="false",
modelDirectory="xcore-maven-example/src/main/java-gen",
complianceLevel="8.0"
)
package simple.model
interface MyFile wraps java.io.File {}
class Author {
String name
op String operationA(MyFile tmp) {
"Hello " + this.name
}
}
Another fact: usage as Argument Type is relevant, because for return Types, it is OK:
@GenModel(
bundleManifest="false",
modelDirectory="xcore-maven-example/src/main/java-gen",
complianceLevel="8.0"
)
package simple.model
interface MyMap wraps java.util.Map<String, String> {}
class Author {
String name
op MyMap operationR() {
emptyMap
}
}
[Updated on: Thu, 16 November 2017 12:33] Report message to a moderator
|
|
|
|
|
Re: [xcore] Error in the generated code, when a type with generics is wrapped and used as argument [message #1776510 is a reply to message #1776483] |
Fri, 17 November 2017 08:11 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
This is what generates support for EObject.eInvoke, which is much like EObject.eGet/eSet/eIsSet/eUnset; the former provides reflective access to operations just as the latter provides reflective access to features. Very little (not so much) infrastructure has been built around reflective operation invocation, so it's unlikely that you'll lose any significant functionality that you'd otherwise use. Note that you can hover over anything in the *.xcore file and it will show you information about what Java things are all generated for the given artifact in the Xcore model, including support to navigate to that thing.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 3.99908 seconds