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;








1















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?










share|improve this question
























  • 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

















1















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?










share|improve this question
























  • 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













1












1








1








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












1 Answer
1






active

oldest

votes


















3
















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;
'''
]
]







share|improve this answer

























  • Thanks, I never thought of it.

    – Kartik Raut
    Mar 28 at 18:51










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
);



);














draft saved

draft discarded
















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









3
















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;
'''
]
]







share|improve this answer

























  • Thanks, I never thought of it.

    – Kartik Raut
    Mar 28 at 18:51















3
















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;
'''
]
]







share|improve this answer

























  • Thanks, I never thought of it.

    – Kartik Raut
    Mar 28 at 18:51













3














3










3









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;
'''
]
]







share|improve this answer













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;
'''
]
]








share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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








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.




















draft saved

draft discarded















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현