This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 236885

Summary: Most refactoring operations in the IDE are broken when using Lombok
Product: java Reporter: Michel Graciano <hmichel>
Component: SourceAssignee: Svata Dedic <sdedic>
Status: RESOLVED WONTFIX    
Severity: normal CC: andidev, andrzejo, FrantaM, jkovalsky, makos, pjiricka, ralphbenjamin, rjdkolb, thpe
Priority: P4 Keywords: JDK_8
Version: 7.4   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: Sample project
Log file

Description Michel Graciano 2013-10-08 14:42:04 UTC
[ BUILD # : 201310012201 ]
[ JDK VERSION : 1.7.0_40 ]

When using Lombok in a project, most refactoring operations are broken
(generate invalid code). I can enumerate some as: Copy a class file, create a
constructor, create a setter etc. I will attach a project with this issue. I
consider it a P1 because it creates code that is note compilable, but I am not
sure if it is a NB or Lombok fault.
Comment 1 Michel Graciano 2013-10-08 14:46:04 UTC
Created attachment 140891 [details]
Sample project

To reproduce:
1. Open the Bean class
2. Try to add a constructor using Alt + Insert.
Result: The constructor will be generated but the final bracket will be lost.
Comment 2 Michel Graciano 2013-10-08 15:00:27 UTC
I have tested it at 7.3.1, and it does not work either with the latest edge Lombok build (which supports Java 8). If I use NB 7.3.1 with latest Lombok stable build, it works as expected. So I suspect something that NB expects are not correctly informed by Lombok or Java 8 APT.

I will decrease the priority to P2, because we need to understand if it is a NB, JavaC or Lombok issue. Jirka asked me to add JDK8 keyword too, so I did it too.

I hope to hear from you soon. Thanks in advance :)
Comment 3 Michel Graciano 2013-10-08 17:33:09 UTC
Created attachment 140898 [details]
Log file

I am attaching the log file from 7.3.1. I have a similar log message for 7.4, but due to issue 236831 the 7.4 log are far verbose, so I choose to attache the 7.3.1 one. Looks like the source is invalid somehow.
Comment 4 Michel Graciano 2013-10-09 13:16:45 UTC
I was wondering if _maybe_ it has something related to issue #232284. Looks like there is something "wrong" with the source file in some point of the processing.
Comment 5 Michel Graciano 2013-10-11 13:30:59 UTC
Lombok has just released version 1.2.12 which will make this issue even more visible now. It happen in NetBeans 7.3.1 too.
Comment 6 Michel Graciano 2013-10-11 13:44:24 UTC
I have escalated this issue to Lomboko guys too [1]. Since now they have a new stable version, they will probably heard a lot about it soon. Have anyone from NB team analysed it already? Please, let me know when you have any results.

[1] https://code.google.com/p/projectlombok/issues/detail?id=591
Comment 7 Svata Dedic 2013-10-16 14:10:55 UTC
Please see evaluation in issue #237156; the root cause is the same. The source tree contains synthetic items generated by Lombok, anchored in the source, but not marked as synthetic in any way. The patch/diff code that computes necessary changes to the source text gets confused by such information. 

The issue will be hardly fixed on NetBeans side, except if a concept adopted by both NetBeans code and Lombok is defined. I expect Lombok people to provide appropriate support on NetBeans' side (if needed, after the generated content is somehow distinguishable from physical content) - Lombok project declares to support NB.

From the point of view of base Java development features covered by (and missing! in) NetBeans, the focus to support specifically Lombok should be marginal, IMHO.

Patches are warmly welcomed.
Comment 8 Michel Graciano 2013-10-16 14:40:04 UTC
If Lombok guys mark the generated code with SYNTHETIC or GENERATEDCONSTR, will it be ignored by Navigator, Find Usages and other tools?
Comment 9 Jiri Prox 2014-01-27 08:33:07 UTC
*** Bug 240977 has been marked as a duplicate of this bug. ***
Comment 10 thpe 2014-03-15 14:05:00 UTC
*** Bug 242920 has been marked as a duplicate of this bug. ***
Comment 11 Ralph Ruijs 2014-03-22 09:55:48 UTC
*** Bug 242240 has been marked as a duplicate of this bug. ***
Comment 12 Ralph Ruijs 2014-07-15 12:25:09 UTC
*** Bug 242422 has been marked as a duplicate of this bug. ***
Comment 13 Ralph Ruijs 2014-07-16 09:32:05 UTC
*** Bug 236830 has been marked as a duplicate of this bug. ***