Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How do I set the package for my generated Java files?(Noob)
How do I set the package for my generated Java files? [message #1168050] Sun, 03 November 2013 03:17 Go to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
I'm guessing that it is a setting in the GenerateSpinCAD.mwe2 file, however I'm pretty reluctant to change things without knowing what I'm doing. I just recovered from a couple days digression based on trying to change the package definition via refactoring in Eclipse. Won't try that again! Embarrassed

I want my generated Java files to be part of this package:

package com.holycityaudio.SpinCAD.CADBlocks;

(which code is inserted into the Java source file).

However they are being generated in the /SpinCADBuilder/src-gen/(default package) package.

What do I need to do?

Thanks,

GW

[Updated on: Sun, 03 November 2013 03:17]

Report message to a moderator

Re: How do I set the package for my generated Java files? [message #1168405 is a reply to message #1168050] Sun, 03 November 2013 09:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

it is actually derived from the grammar name

grammar org.xtext.example.mydsl2.MyDsl

leads to package

org.xtext.example.mydsl2


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How do I set the package for my generated Java files? [message #1168767 is a reply to message #1168405] Sun, 03 November 2013 14:57 Go to previous messageGo to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
Hmmm I'm a bit confused.

In my 1st instance of Eclipse, all the generated code that parses the grammar is located in packages that I defined in my grammar file. That part of it is fine.

Now I launch my second instance of Eclipse, and I created some new files of the type which my grammar is supposed to parse. When I save one of these files, the translated version (a Java file) is created. How do I set the package where THAT file gets created?

As it stands now, I am keeping my Xtext grammar and Xtend code generator (Eclipse instance #1) in a different package/path than the source code for my actual Java application (Eclipse instance #2). The application uses a combination of hand written Java code and the classes which are generated using my grammar.
Re: How do I set the package for my generated Java files? [message #1168821 is a reply to message #1168767] Sun, 03 November 2013 15:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

do you mean the stuff you generate in your IGenerator or Inferred by JvmModelInferrer?
in both cases your are the one to blame. if you do not give the file a path (IGenerator)
or a QualifiedName (Inferrer) you may not complain if there is no package


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How do I set the package for my generated Java files? [message #1168827 is a reply to message #1168821] Sun, 03 November 2013 15:55 Go to previous message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
Certainly I am to blame! LOL.

Anyway it is the IGenerator. So I guess what I have to do is determine the path (with slashes) of the desired package and then prepend that to the name of the desired generated file. What I had done previously was to use a "fully qualified name" prefix (with dots) and it simply added that to the file name of each generated file, but still put them in the (default package).

I'll give it a try. Thanks for the hint.

[Update] - got it working. Thanks again.

GW

[Updated on: Sun, 03 November 2013 18:56]

Report message to a moderator

Previous Topic:Calculating offset for SKIP instruction
Next Topic:endless Loop with extern lexer
Goto Forum:
  


Current Time: Fri Apr 19 06:50:24 GMT 2024

Powered by FUDForum. Page generated in 0.02178 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top