junichi11 / netbeans-rainbow-braces

Rainbow Parenthesis / Brackets / Braces for NetBeans
https://plugins.netbeans.apache.org/catalogue/?id=25
Apache License 2.0
35 stars 4 forks source link

Classes with Lombok annotations cause Apache NetBeans 12.2 to hang #11

Closed cbm64chris closed 3 years ago

cbm64chris commented 3 years ago

Describe the bug When Rainbow-Braces is installed with the below configuration - a maven project with org.projectlombok-lombok-edge-SNAPSHOT annotations of classes cause NetBeans to hang when opening the file.

Product Version: Apache NetBeans IDE 12.2 Java: 15.0.1; OpenJDK 64-Bit Server VM 15.0.1+9 Runtime: OpenJDK Runtime Environment 15.0.1+9 System: Mac OS X version 10.16 running on x86_64; UTF-8; en_GB (nb) User directory: /Users/cl011157/Library/Application Support/NetBeans/12.2 Cache directory: /Users/cl011157/Library/Caches/NetBeans/12.2

To Reproduce Steps to reproduce the behavior:

  1. Create a maven project with lombok-edge as a dependency
  2. Create a class and include lombok annotations - such as @Data and @Builder(toBuilder = true)
  3. Compile the project
  4. Close the file
  5. Restart NetBeans
  6. Attempt to open the annotated class

Expected behavior A title for the class will display but the editor will not display the contents. NetBeans will start to thrash on at least one core of the CPU. No actions will be possible, eventually macOS will report the application is not responding. The only resolution is to ForceQuit.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context

junichi11 commented 3 years ago

@cbm64chris Could you please attach an example project(as a zip file) to reproduce it?

cbm64chris commented 3 years ago

@junichi11 I have isolated the problem;

The hang will occur if 'Skip Comments' is enabled and the class has a comments, such as a licence, above the package declaration. It does not matter as previously reported if the class has any annotations. You can invoke the problem reliably by simply turning on, as is by default, 'Skip Comments' and type/paste above the package. NetBeans will begin to thrash and become unresponsive. I cannot see anything in the log that suggest why this happens and I have not looked at your implementation at this time.

Thanks Chris

/**
 * Licence Header
 */
package com.rainbow.braces.test;

import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * LombokBuilder
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Builder(toBuilder = true)
public class LombokBuilder1 {
    private int myInt;
}
junichi11 commented 3 years ago

@cbm64chris Reproducible. Thank you for investigating it.

junichi11 commented 3 years ago

I found the cause. An infinite loop occurs. I'll fix it ASAP. Your instruction was helpful. Thank you!

junichi11 commented 3 years ago

@cbm64chris Could you please verify it? https://github.com/junichi11/netbeans-rainbow-braces/releases/tag/v1.3.0 (netbeans-rainbow-braces-1.3.0.1-dev.nbm)

If there is no problem, I'll upload it to the Plugin Portal as version 1.3.1. Thanks.

cbm64chris commented 3 years ago

@junichi11 looks good, no issue found!

junichi11 commented 3 years ago

@cbm64chris Thank you for your verification :) I'll add the new version to PP.