[Xpand] Dynamic position of generated text [message #843658] |
Fri, 13 April 2012 04:46  |
Eclipse User |
|
|
|
Hi all,
Please take a look at my problem. Let's consider that we have 3 very simple templates in Xpand: class, variable and method.
«DEFINE class FOR X»
public class MyClass {
«EXPAND variableDec»
«EXPAND method»
}
«ENDDEFINE»
«DEFINE variable FOR X»
int a = 0;
int b = 0;
int c = 0;
«ENDDEFINE»
«DEFINE method FOR X»
public static String methodA() {
«EXPAND variable»
}
«ENDDEFINE»
The output shall be:
public class MyClass {
int a = 0;
int b = 0;
int c = 0;
public static String methodA() {
int a = 0;
int b = 0;
int c = 0;
}
}
So I wonder that do we have any way to make the text generated right at the place where EXPAND statement is placed. Specifically, if we update the template variable as:
«DEFINE variable FOR X»
int a = 0;
int b = 0;
int c = 0;
«ENDDEFINE»
And the calling of variable template in other templates:
«DEFINE class FOR X»
public class MyClass {
«EXPAND variableDec»
«EXPAND method»
}
«ENDDEFINE»
«DEFINE method FOR X»
public static String methodA() {
«EXPAND variable»
}
«ENDDEFINE»
Then the expected text is generated as:
public class MyClass {
int a = 0;
int b = 0;
int c = 0;
public static String methodA() {
int a = 0;
int b = 0;
int c = 0;
}
}
Hope that everyone could understand my situation. Thanks for any help!
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05230 seconds