Skip to main content



      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] Sat, 02 November 2013 23:17 Go to next message
Eclipse UserFriend
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: Sat, 02 November 2013 23:17] by 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 04:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

it is actually derived from the grammar name

grammar org.xtext.example.mydsl2.MyDsl

leads to package

org.xtext.example.mydsl2
Re: How do I set the package for my generated Java files? [message #1168767 is a reply to message #1168405] Sun, 03 November 2013 09:57 Go to previous messageGo to next message
Eclipse UserFriend
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 10:48 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: How do I set the package for my generated Java files? [message #1168827 is a reply to message #1168821] Sun, 03 November 2013 10:55 Go to previous message
Eclipse UserFriend
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 13:56] by Moderator

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


Current Time: Sat Jul 12 17:02:41 EDT 2025

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

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

Back to the top