[stringtemplate-interest] Way to merge/save changes to generated code
Gerald Rosenberg
gerald at certiv.net
Fri Mar 26 14:49:58 PDT 2010
XText uses a convenient strategy of external fragments, thereby avoiding
most if not all diff/merge issues. Empty fragments are generated iff
the files do not exist. The generated code just delegates to named
fragments where customization is anticipated.
// regenerable
public class SessionFacade1 {
public String method1(Object arg) {
String response = SessionFacade1Fragment.method1(arg);
if (!response.isEmpty()) return response;
return "hello";
}
}
// generated once
public class SessionFacade1Fragment {
public static String method1(Object arg) {
/* User hand-written code */
return "";
/* end User hand-written code */
}
}
On 3/26/2010 2:16 PM, Richard Catlin wrote:
> I am using Antlr/StringTemplate to generate a SessionFacde class. I
> then need to fill in some of the methods. Is there a way to
> merge/save the user hand written code, if the file is regenerated. I
> thought using SVN would at least allow me to diff the file and cut and
> paste the user hand written code, but was wondering if anyone has a
> better strategy for automating. Other tools like Acceleo have a
> merge/lost feature. "lost" is user code that could not be merged due
> to a change in the generated code, such as a method deletion.
>
> For instance, a Session Facade may be:
>
> public class SessionFacade1 {
> public String method1() {
> /* User hand-written code */
> return "hello";
> /* end User hand-written code */
> }
> }
>
> Thanks for any help.
> Richard Catlin
>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20100326/7b49483a/attachment.html
More information about the stringtemplate-interest
mailing list