[Xtend] Relative Qualified Names in my Template [message #716024] |
Tue, 16 August 2011 08:35 |
Daniel Missing name Messages: 101 Registered: July 2011 |
Senior Member |
|
|
Hi again.
I want to produce Java Classes of my DSL files. In my grammar it's possible to reference elements within expressions.
The built in scope provider optimizes full qualified names perfectly (relative to the current position). I want the same behavior during Java code generation.
I have a set of rules for the generation:
1. A global package for generation is set: at.myproject.lib
2. Each file gets an own subpackage: at.myproject.lib.$file
3. Global Constants are written to a globals class: at.myproject.lib.${file}.${file}Globals
4. Each Type Declaration is written to it's own class: at.myproject.lib.${file}.${type-name}
Its just like a qualified name generator. My idea was to create a new IQualifiedNameProvider for java output and use it during code-generation. (<<myelement.javaQualifiedName>>)
But this would lead me to the problem that all names are fully qualified even if they are local variables:
module test;
type MyType {
int Size;
int Test = Size + 1;
}
becomes to:
package at.myproject.lib.test;
class MyType {
private int size;
private int test = at.myproject.lib.test.MyType.size;
}
Is there a way to use an own qualified name provider during generation which gets optimized like it's done within the dsl itself during scoping?
Greetings Daniel
[Updated on: Tue, 16 August 2011 08:53] Report message to a moderator
|
|
|
|
Re: [Xtend] Relative Qualified Names in my Template [message #716040 is a reply to message #716032] |
Tue, 16 August 2011 09:23 |
Daniel Missing name Messages: 101 Registered: July 2011 |
Senior Member |
|
|
Hi Alex.
Okay, therefore I will need to write everything myself. I thought there already might be such a system for creating qualified names during generation.
One of the next steps will be to create import statements instead of writing fully qualified names everywhere in my generated file.
How did you solve this problem in Xtend/Xbase itself? Does this feature come with the Jvm integration or did you solve the "relative" qualified names by yourself?
[Updated on: Tue, 16 August 2011 09:28] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03180 seconds