Is it possible to model operation parameters as vararg in Eclipse/EMF?
I'm trying to find a way to model an operation with a vararg input parameter.
The model should generate an interface as shown below.
/**
* ...
* @generated
*/
public interface Content extends EObject
/**
* ...
* @generated
*/
List<Definition> getDefinitionsByLabels(String... label);
Please don't answer with workarounds because I'm trying to update a model of an existing (large) code base (that was "manually" developed further post generation).
So far investigating this didn't look promising, but I didn't want to give up on this aspect without asking a question here.
java eclipse emf eclipse-emf
add a comment |
I'm trying to find a way to model an operation with a vararg input parameter.
The model should generate an interface as shown below.
/**
* ...
* @generated
*/
public interface Content extends EObject
/**
* ...
* @generated
*/
List<Definition> getDefinitionsByLabels(String... label);
Please don't answer with workarounds because I'm trying to update a model of an existing (large) code base (that was "manually" developed further post generation).
So far investigating this didn't look promising, but I didn't want to give up on this aspect without asking a question here.
java eclipse emf eclipse-emf
add a comment |
I'm trying to find a way to model an operation with a vararg input parameter.
The model should generate an interface as shown below.
/**
* ...
* @generated
*/
public interface Content extends EObject
/**
* ...
* @generated
*/
List<Definition> getDefinitionsByLabels(String... label);
Please don't answer with workarounds because I'm trying to update a model of an existing (large) code base (that was "manually" developed further post generation).
So far investigating this didn't look promising, but I didn't want to give up on this aspect without asking a question here.
java eclipse emf eclipse-emf
I'm trying to find a way to model an operation with a vararg input parameter.
The model should generate an interface as shown below.
/**
* ...
* @generated
*/
public interface Content extends EObject
/**
* ...
* @generated
*/
List<Definition> getDefinitionsByLabels(String... label);
Please don't answer with workarounds because I'm trying to update a model of an existing (large) code base (that was "manually" developed further post generation).
So far investigating this didn't look promising, but I didn't want to give up on this aspect without asking a question here.
java eclipse emf eclipse-emf
java eclipse emf eclipse-emf
edited Dec 7 at 14:24
Lii
6,84044159
6,84044159
asked Nov 5 at 13:55
KayleeTheMech
11310
11310
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
The bug report is pending, i.e. the requested feature is not available:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052
makes sense, thanks erdal
– KayleeTheMech
Nov 15 at 14:17
add a comment |
If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:
Make your model class implement a Java interface, where the vararg method is declared.
Java file:
public interface InterfaceWithVarargMethod
public void varArgMethod(String... arg);
Xcore file:
@GenModel(modelDirectory="/EMF_Trying/src-gen")
package emf_trying
interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod
class ModelObject extends InterfaceWithVarargMethod
An implementation of ModelObjectImpl
without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:
public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject
/**
* @generated NOT
*/
@Override
public void m(String... arg)
// Implementation of var-arg method
...
Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53155801%2fis-it-possible-to-model-operation-parameters-as-vararg-in-eclipse-emf%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
The bug report is pending, i.e. the requested feature is not available:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052
makes sense, thanks erdal
– KayleeTheMech
Nov 15 at 14:17
add a comment |
Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
The bug report is pending, i.e. the requested feature is not available:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052
makes sense, thanks erdal
– KayleeTheMech
Nov 15 at 14:17
add a comment |
Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
The bug report is pending, i.e. the requested feature is not available:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052
Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
The bug report is pending, i.e. the requested feature is not available:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052
answered Nov 12 at 6:03
erdal.karaca
4451318
4451318
makes sense, thanks erdal
– KayleeTheMech
Nov 15 at 14:17
add a comment |
makes sense, thanks erdal
– KayleeTheMech
Nov 15 at 14:17
makes sense, thanks erdal
– KayleeTheMech
Nov 15 at 14:17
makes sense, thanks erdal
– KayleeTheMech
Nov 15 at 14:17
add a comment |
If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:
Make your model class implement a Java interface, where the vararg method is declared.
Java file:
public interface InterfaceWithVarargMethod
public void varArgMethod(String... arg);
Xcore file:
@GenModel(modelDirectory="/EMF_Trying/src-gen")
package emf_trying
interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod
class ModelObject extends InterfaceWithVarargMethod
An implementation of ModelObjectImpl
without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:
public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject
/**
* @generated NOT
*/
@Override
public void m(String... arg)
// Implementation of var-arg method
...
Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.
add a comment |
If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:
Make your model class implement a Java interface, where the vararg method is declared.
Java file:
public interface InterfaceWithVarargMethod
public void varArgMethod(String... arg);
Xcore file:
@GenModel(modelDirectory="/EMF_Trying/src-gen")
package emf_trying
interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod
class ModelObject extends InterfaceWithVarargMethod
An implementation of ModelObjectImpl
without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:
public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject
/**
* @generated NOT
*/
@Override
public void m(String... arg)
// Implementation of var-arg method
...
Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.
add a comment |
If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:
Make your model class implement a Java interface, where the vararg method is declared.
Java file:
public interface InterfaceWithVarargMethod
public void varArgMethod(String... arg);
Xcore file:
@GenModel(modelDirectory="/EMF_Trying/src-gen")
package emf_trying
interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod
class ModelObject extends InterfaceWithVarargMethod
An implementation of ModelObjectImpl
without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:
public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject
/**
* @generated NOT
*/
@Override
public void m(String... arg)
// Implementation of var-arg method
...
Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.
If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:
Make your model class implement a Java interface, where the vararg method is declared.
Java file:
public interface InterfaceWithVarargMethod
public void varArgMethod(String... arg);
Xcore file:
@GenModel(modelDirectory="/EMF_Trying/src-gen")
package emf_trying
interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod
class ModelObject extends InterfaceWithVarargMethod
An implementation of ModelObjectImpl
without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:
public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject
/**
* @generated NOT
*/
@Override
public void m(String... arg)
// Implementation of var-arg method
...
Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.
answered 9 hours ago
Lii
6,84044159
6,84044159
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53155801%2fis-it-possible-to-model-operation-parameters-as-vararg-in-eclipse-emf%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown