akshattandon / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

Delombok on GWT native source causes issue with javascript functions #707

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  Create a java source with a GWT native jsni function.
2.  Run delombok on the file.

Example:

@Getter
@Setter
@NoArgsConstructor
public GWTDelombokTest implements EntryPoint {

   private String text;

   @Override
   public void onModuleLoad() {
     setText("Show this message!");
     showMessage();
   }

   public native void showMessage() /*-{
       var msg = this.@GWTDelombokTest::getText()();
       $wnd.alert(msg);
   }-*/;

}

What is the expected output? 

Delomboked methods and constructors maintaining the native function formatting.

@Getter
@Setter
@NoArgsConstructor
public GWTDelombokTest implements EntryPoint {

   private String text;

   @Override
   public void onModuleLoad() {
     setText("Show this message!");
     showMessage();
   }

   public native void showMessage() /*-{
       var msg = this.@GWTDelombokTest::getText()();
       $wnd.alert(msg);
   }-*/;

   public String getText() {
      return this.text;
   }

   public void setText(String text) {
      this.text = text;
   }

   public GWTDelombokTest() {
   }

}

What do you see instead?

The native method formatting is incorrect.  The semi-colon is moved to the end 
of the method name and the comment is moved to after the semi-colon.  This 
causes a GWT compile using the delomboked source to fail.  (incorrect format 
shown)

   public native void showMessage();
 /*-{
       var msg = this.@GWTDelombokTest::getText()();
       $wnd.alert(msg);
   }-*/

What version of the product are you using? Reproduced in 1.12.6 and 1.14.4.  

On what operating system? Windows/Linux

Original issue reported on code.google.com by j...@percsolutions.com on 16 Jul 2014 at 10:48

GoogleCodeExporter commented 9 years ago
Found a work-around:  Place the native functions into a separate class from a 
file containing lomboked code.  Then, with no lombok anotations in the file, 
the code will not be delomboked.

Original comment by j...@percsolutions.com on 16 Jul 2014 at 10:55