Eclipse save actions removes "import lombok.var;"

171 views
Skip to first unread message

pcouton

unread,
Jul 4, 2018, 6:00:32 AM7/4/18
to Project Lombok
I am experiencing a strange Eclipse behavior when I save a file that uses lombok.var.
  • My Eclipse is configured to organize imports when I save a file (but not to remove unused imports)
  • "import lombok.var;" is not marked as an unused import
  • However, when I save my file, Eclipse removes the import, leading to a compile error

Have you already seen such a problem ? Is there a workaround ?


Seen with Lombok 1.18.0, Eclipse 4.7.3  ; code used:


import lombok.var;

public class VarImportTest {

   
public static void main(String[] args) {
       
var myVar = "Foo";
       
System.out.println(myVar);
   
}

}


Reinier Zwitserloot

unread,
Jul 17, 2018, 3:24:59 PM7/17/18
to Project Lombok
We delete the import on purpose in javac-land, but definitely not in eclipse-land, so this is befuddling to me. We explicitly turn 'var myVar = "Foo"' into '@var String myVar = "Foo"' in order to avoid the import being marked as unused somehow.

If this is still happening, can you file a bug on github? Thanks!

pcouton

unread,
Jul 18, 2018, 6:00:13 AM7/18/18
to Project Lombok
Bug filed : #1783.

While entering the bug description, I found that this problem is caused by the "Organize Imports" action. Since this one is often used in "Save Actions", it was easy to have a confusion between tthe two.

Reinier Zwitserloot

unread,
Jul 25, 2018, 4:05:18 PM7/25/18
to Project Lombok
... aaaaand bug fixed :)

pcouton

unread,
Jul 26, 2018, 4:21:32 AM7/26/18
to Project Lombok
Great, works fine now! Thanks.
Reply all
Reply to author
Forward
0 new messages