izhangzhihao / intellij-rainbow-brackets

🌈Rainbow Brackets for IntelliJ based IDEs/Android Studio/HUAWEI DevEco Studio/Fleet
https://plugins.jetbrains.com/plugin/10080-rainbow-brackets
GNU General Public License v3.0
4.35k stars 202 forks source link

Something weird with rainbow variables (and license checker) #2715

Closed Kos9078 closed 3 weeks ago

Kos9078 commented 1 month ago

Have you checked the issues and discussions to ensure there are no duplicates?

Yes

Your programming languages

Java

Free or paid?

Paid users

Expected Behavior

When I set option "Rainbow Brackets->Enable rainbow variables", "Rainbow Brackets->Color->Use color generator" and "Rainbow Brackets->Color->(paid feature)Use color generator for rainbow variables(restart required)" to true, I'm expecting usage of Editor->Color Scheme->Rainbow Brackets->Generated Rainbow Variables Color Scheme, and not just Editor->Color Scheme->Rainbow Brackets->Rainbow Variables Baseline. Also option "Rainbow Brackets->Color->(paid feature)Use color generator for rainbow variables(restart required)" shouldn't sometime threw Register Plugin popup when valid registration code used or linked to JB account with valid license. (Also - why licensed by evaluation?? It's licensed by JB account!)

Current Behavior

image image image image image image Tested on clean install of IDEA on clean PC. Still have issues. Also sometimes got Register Plugin popup after restart (currently can't reproduce, but looks like plugin's LicenseChecker doesen't wait for JB's LicensingFacade for (paid feature)Use color generator for rainbow variables(restart required) option)

This behaviour looks like #2596 and #2597 which is year old...

Code snippet for reproduce

{
            {
                {
                    {
                        final String dsadasd = "dsada";
                        final String ds1adasd = "dsada";
                        final String ds2adasd = "dsada";
                        final String ds3adasd = "dsada";
                        final String ds4adasd = "dsada";
                        final String ds5adasd = "dsada";
                        System.out.println(ds5adasd + ds4adasd + dsadasd + ds1adasd + ds2adasd + ds3adasd);
                    }

                    {
                        final String dsadasd = "dsada";
                        final String ds1adasd = "dsada";
                        final String ds2adasd = "dsada";
                        final String ds3adasd = "dsada";
                        final String ds4adasd = "dsada";
                        final String ds5adasd = "dsada";
                        System.out.println(ds5adasd + ds4adasd + dsadasd + ds1adasd + ds2adasd + ds3adasd);
                    }

                    {
                        final String dsadasd = "dsada";
                        final String ds1adasd = "dsada";
                        final String ds2adasd = "dsada";
                        final String ds3adasd = "dsada";
                        final String ds4adasd = "dsada";
                        final String ds5adasd = "dsada";
                        System.out.println(ds5adasd + ds4adasd + dsadasd + ds1adasd + ds2adasd + ds3adasd);
                    }

                    {
                        final String dsadasd = "dsada";
                        final String ds1adasd = "dsada";
                        final String ds2adasd = "dsada";
                        final String ds3adasd = "dsada";
                        final String ds4adasd = "dsada";
                        final String ds5adasd = "dsada";
                        System.out.println(ds5adasd + ds4adasd + dsadasd + ds1adasd + ds2adasd + ds3adasd);
                    }
                    {
                        final String dsadasd="dsada";
                        final String ds1adasd="dsada";
                        final String ds2adasd="dsada";
                        final String ds3adasd="dsada";
                        final String ds4adasd="dsada";
                        final String ds5adasd="dsada";
                        System.out.println(ds5adasd+ds4adasd+dsadasd+ds1adasd+ds2adasd+ds3adasd);
                        {
                            {
                                {
                                    Package d;
                                }

                            }
                            Package aa;

                        }

                    }
                }
            }
        }

Your Environment

IntelliJ IDEA 2023.3.6 (Ultimate Edition) Build #IU-233.15026.9, built on March 21, 2024 Licensed to Trial User Subscription is active until April 30, 2024. Runtime version: 17.0.10+1-b1087.23 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10.0 GC: G1 Young Generation, G1 Old Generation Memory: 2048M Cores: 8 Non-Bundled Plugins: izhangzhihao.rainbow.brackets (2024.2.2-233) Kotlin: 233.15026.9-IJ

Kos9078 commented 1 month ago

Also, I'm not on cracked IDE. Custom VM Options: image C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.6\bin\idea64.exe.vmoptions: image

Kos9078 commented 1 month ago

Rainbow Brackets XML config:

<application>
  <component name="RainbowSettings">
    <option name="applyColorsOfRoundForAllBrackets" value="true" />
    <option name="colorGenHueOption" value="blue" />
    <option name="colorGenLuminosityOption" value="light" />
    <option name="cycleCountOnAllBrackets" value="true" />
    <option name="enableRainbowVariables" value="true" />
    <option name="enableRainbowVariablesBySemanticHighlighting" value="true" />
    <option name="indentGuidesOptions" value="Only selected indent guide" />
    <option name="numberOfColors" value="10" />
    <option name="rainbowifyPythonKeywords" value="true" />
    <option name="rainbowifyTagNameInXML" value="true" />
    <option name="rainbowifyTagNameInYAML" value="true" />
    <option name="showNotificationOnUpdate" value="false" />
    <option name="showRainbowIndentGuides" value="false" />
    <option name="useColorGenerator" value="true" />
    <option name="useColorGeneratorForRainbowVariables" value="true" />
    <option name="version" value="2024.2.2-233" />
  </component>
</application>
izhangzhihao commented 1 month ago

Pls try to refresh the license as below(you may have 2 active license now):

image image image image
izhangzhihao commented 1 month ago

"sometimes threw Register Plugin popup" might be because the license module of the IDE has not finished initializing yet after a fresh start, if you opened the IDE, pls wait for like 1 or 2 minutes to change the options.

izhangzhihao commented 1 month ago

I'm expecting usage of Editor->Color Scheme->Rainbow Brackets->Generated Rainbow Variables Color Scheme, and not just Editor->Color Scheme->Rainbow Brackets->Rainbow Variables Baseline

I understand, but currently, there is no way to explore the generated rainbow variables color.

Kos9078 commented 1 month ago

Pls try to refresh the license as below(you may have 2 active license now):

Nope, i have only one license on my account. image

"sometimes threw Register Plugin popup" might be because the license module of the IDE has not finished initializing yet after a fresh start, if you opened the IDE, pls wait for like 1 or 2 minutes to change the options.

I'm not changing any options after startup. This sometimes just happens if option Use color generator for rainbow variables activated. And only this option leads to this behavior. Other paid options works flawlessly.

izhangzhihao commented 1 month ago

I see, never mind the 'evaluation' then and this plugin will work full-featured for you, and I will try to enhance the msg in the next release. For the option 'Use color generator for rainbow variables', I will take a look.

izhangzhihao commented 1 month ago

pls try this build snapshot, I add a fixed 30-second delay to enable Rainbow Variables to avoid the license module init issue.(don't unzip) intellij-rainbow-brackets-2024.2.2-233.zip

Kos9078 commented 1 month ago

Small test report:

Yesterday I tested the release version. It looks like on medium projects registration popup may appear during indexing in about 60% of cases, IDEA must be in cold-start state. (Or after full invalidate and restart task). This is not observed with the snapshot version, and it seems to work well.

However, I don’t really like a way with constant delay. Maybe it would be better to move the license check to a separate thread and, for example, check in a loop if the LicensingFacade has been initialized? Let’s say, this is a regular while((facade = LicensingFacade()) == null) with thread.sleep(5s) inside? Yes, this is also not very beautiful, but it will help not to play guessing games with it.

izhangzhihao commented 1 month ago

Thanks for your testing! my logic is similar to yours, but without the while loop, just try to activate paid features instantly if cannot(won't pop up the active license window here) try again 30s later.

And seems since 2023.3 or 2024.1, the LicensingFacade() not returned null but the license module is still not initialized yet.

Kos9078 commented 1 month ago

I did some research as the "evaluation" license status was bothering me and found out that if IDEA is activated with a trial license, and the plugin with a full license - the plugin will still write that it is activated with a evaluation license. This is a very rare case, but I think it should be clearly reflected in discussion #2630. Or even better on plugin' settings page. Now I'm calm)

And seems since 2023.3 or 2024.1, the LicensingFacade() not returned null but the license module is still not initialized yet.

That’s really strange because I made test plugin and hooked all accesses to LicensingFacade class:

But I didn't get null from LicensingFacade' intance in both cases and this is really strange. Also, seems like JetBrains left all fields public for their internal purpose (e.g. setting their value via reflection API;I make this assumption based on the fact that I did not find a single direct call to the LicensingFacade fromJson(String json) method or other similar calls).
Unfortunately, IDEA is obfuscated with help of ZKM and I don’t have time to investigate such a huge project…

All test was performed on IDEA Ultimate 2023.3.6

izhangzhihao commented 1 month ago

That's what I'm currently using to get the license, and I do believe that LicensingFacade.getInstance() will return null just after you start the IDE.

val facade = LicensingFacade.getInstance()
if (facade == null) {
    return WaitInit
}
image