How to add custom import statements in the generated java file in xtext using jvmmodelInferrer?How to add multiple outlets for generated XText DSLDisable “Add Xtext nature” dialog in EclipseIs there a java grammar file for Xtext?Xtext multiple generatorsAlways add a specific 'import static extension' to an XText DSLGenerate DSL file with XText from Java modelHow to split Xtext grammar file into multiple ones?Validate xtext editor content which is generated by Grammar fileValidation error if Import is not present in xtextHow to generate a parser generator using Xtext?
"Literally" Vs "In the true sense of the word"
Is there a real-world mythological counterpart to WoW's "kill your gods for power" theme?
How to stabilise the bicycle seatpost and saddle when it is all the way up?
Why don't Wizards use wrist straps to protect against disarming charms?
What hard drive connector is this?
I was promised a work PC but still awaiting approval 3 months later so using my own laptop - Is it fair to ask employer for laptop insurance?
Why is my fire extinguisher emptied after one use?
Should you only use colons and periods in dialogues?
Why is template constructor preferred to copy constructor?
Are space camera sensors usually round, or square?
Why do sellers care about down payments?
How to publish superseding results without creating enemies
Do ibuprofen or paracetamol cause hearing loss?
How are aircraft depainted?
Bash, import output from command as command
Make 2019 with single digits
Why did they ever make smaller than full-frame sensors?
Some Prime Peerage
Can I tap all my opponent's lands while they're casting a spell to negate it?
What are uses of the byte after BRK instruction on 6502?
Why is the T-1000 humanoid?
why car dealer is insisting on loan v/s cash
Real mode flat model
Is the Dodge action perceptible to other characters?
How to add custom import statements in the generated java file in xtext using jvmmodelInferrer?
How to add multiple outlets for generated XText DSLDisable “Add Xtext nature” dialog in EclipseIs there a java grammar file for Xtext?Xtext multiple generatorsAlways add a specific 'import static extension' to an XText DSLGenerate DSL file with XText from Java modelHow to split Xtext grammar file into multiple ones?Validate xtext editor content which is generated by Grammar fileValidation error if Import is not present in xtextHow to generate a parser generator using Xtext?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have written a grammar for my domain specific language in xtext and I am using jvmmodelInferrer to generate java code. I can generate fields and custom methods but how can I add custom import statements like 'import java.util.*' in the generated java file without the user having to explicitly write the import statement?
dsl xtext xtend xbase
add a comment
|
I have written a grammar for my domain specific language in xtext and I am using jvmmodelInferrer to generate java code. I can generate fields and custom methods but how can I add custom import statements like 'import java.util.*' in the generated java file without the user having to explicitly write the import statement?
dsl xtext xtend xbase
there should be no need for that. can you give more context about what you do in the inferrer
– Christian Dietrich
Mar 28 at 17:34
I have to execute SQL queries. So I have generated code for execution of SQL queries but I need to generate an import statement 'import java.sql.*'. So how can i generate the import statement?
– Kartik Raut
Mar 28 at 18:06
add a comment
|
I have written a grammar for my domain specific language in xtext and I am using jvmmodelInferrer to generate java code. I can generate fields and custom methods but how can I add custom import statements like 'import java.util.*' in the generated java file without the user having to explicitly write the import statement?
dsl xtext xtend xbase
I have written a grammar for my domain specific language in xtext and I am using jvmmodelInferrer to generate java code. I can generate fields and custom methods but how can I add custom import statements like 'import java.util.*' in the generated java file without the user having to explicitly write the import statement?
dsl xtext xtend xbase
dsl xtext xtend xbase
asked Mar 28 at 10:25
Kartik RautKartik Raut
61 bronze badge
61 bronze badge
there should be no need for that. can you give more context about what you do in the inferrer
– Christian Dietrich
Mar 28 at 17:34
I have to execute SQL queries. So I have generated code for execution of SQL queries but I need to generate an import statement 'import java.sql.*'. So how can i generate the import statement?
– Kartik Raut
Mar 28 at 18:06
add a comment
|
there should be no need for that. can you give more context about what you do in the inferrer
– Christian Dietrich
Mar 28 at 17:34
I have to execute SQL queries. So I have generated code for execution of SQL queries but I need to generate an import statement 'import java.sql.*'. So how can i generate the import statement?
– Kartik Raut
Mar 28 at 18:06
there should be no need for that. can you give more context about what you do in the inferrer
– Christian Dietrich
Mar 28 at 17:34
there should be no need for that. can you give more context about what you do in the inferrer
– Christian Dietrich
Mar 28 at 17:34
I have to execute SQL queries. So I have generated code for execution of SQL queries but I need to generate an import statement 'import java.sql.*'. So how can i generate the import statement?
– Kartik Raut
Mar 28 at 18:06
I have to execute SQL queries. So I have generated code for execution of SQL queries but I need to generate an import statement 'import java.sql.*'. So how can i generate the import statement?
– Kartik Raut
Mar 28 at 18:06
add a comment
|
1 Answer
1
active
oldest
votes
you dont generate import strings. you just use rich strings in a proper way and everything happens automatically
def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase)
for (greeting : element.greetings)
acceptor.accept(greeting.toClass("demo." + greeting.name)) [
members += greeting.toMethod("demo", Void.TYPE.typeRef) [
body = '''
«JFrame» f = null;
«"java.util.List".typeRef("java.lang.String".typeRef)» l = null;
return;
'''
]
]
Thanks, I never thought of it.
– Kartik Raut
Mar 28 at 18:51
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/4.0/"u003ecc by-sa 4.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%2f55395272%2fhow-to-add-custom-import-statements-in-the-generated-java-file-in-xtext-using-jv%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you dont generate import strings. you just use rich strings in a proper way and everything happens automatically
def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase)
for (greeting : element.greetings)
acceptor.accept(greeting.toClass("demo." + greeting.name)) [
members += greeting.toMethod("demo", Void.TYPE.typeRef) [
body = '''
«JFrame» f = null;
«"java.util.List".typeRef("java.lang.String".typeRef)» l = null;
return;
'''
]
]
Thanks, I never thought of it.
– Kartik Raut
Mar 28 at 18:51
add a comment
|
you dont generate import strings. you just use rich strings in a proper way and everything happens automatically
def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase)
for (greeting : element.greetings)
acceptor.accept(greeting.toClass("demo." + greeting.name)) [
members += greeting.toMethod("demo", Void.TYPE.typeRef) [
body = '''
«JFrame» f = null;
«"java.util.List".typeRef("java.lang.String".typeRef)» l = null;
return;
'''
]
]
Thanks, I never thought of it.
– Kartik Raut
Mar 28 at 18:51
add a comment
|
you dont generate import strings. you just use rich strings in a proper way and everything happens automatically
def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase)
for (greeting : element.greetings)
acceptor.accept(greeting.toClass("demo." + greeting.name)) [
members += greeting.toMethod("demo", Void.TYPE.typeRef) [
body = '''
«JFrame» f = null;
«"java.util.List".typeRef("java.lang.String".typeRef)» l = null;
return;
'''
]
]
you dont generate import strings. you just use rich strings in a proper way and everything happens automatically
def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase)
for (greeting : element.greetings)
acceptor.accept(greeting.toClass("demo." + greeting.name)) [
members += greeting.toMethod("demo", Void.TYPE.typeRef) [
body = '''
«JFrame» f = null;
«"java.util.List".typeRef("java.lang.String".typeRef)» l = null;
return;
'''
]
]
answered Mar 28 at 18:31
Christian DietrichChristian Dietrich
8,9694 gold badges18 silver badges29 bronze badges
8,9694 gold badges18 silver badges29 bronze badges
Thanks, I never thought of it.
– Kartik Raut
Mar 28 at 18:51
add a comment
|
Thanks, I never thought of it.
– Kartik Raut
Mar 28 at 18:51
Thanks, I never thought of it.
– Kartik Raut
Mar 28 at 18:51
Thanks, I never thought of it.
– Kartik Raut
Mar 28 at 18:51
add a comment
|
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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.
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%2f55395272%2fhow-to-add-custom-import-statements-in-the-generated-java-file-in-xtext-using-jv%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
there should be no need for that. can you give more context about what you do in the inferrer
– Christian Dietrich
Mar 28 at 17:34
I have to execute SQL queries. So I have generated code for execution of SQL queries but I need to generate an import statement 'import java.sql.*'. So how can i generate the import statement?
– Kartik Raut
Mar 28 at 18:06