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

Upper case fields aren't colorized in C# #2709

Open darthdeus opened 2 months ago

darthdeus commented 2 months ago

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

Yes

Your programming languages

C#

Free or paid?

On trial

Expected Behavior

All fields should be colorized no matter how they're named. Unfortunately the way it works right now doesn't work with the coding convention that public fields should be named Uppercase.

Current Behavior

Only fields named with lowercase or _underscore are colorized, but Uppercase are not, as in this example

image

It also seems to affect local variables, but since those are generally not named with Uppercase that's probably not a big issue. For fields however this is very inconvenient. I love the plugin otherwise, but many of the codebases I work on use an uppercase convention.

Code snippet for reproduce

class Test {
    readonly float foo = 5;
    readonly float _bar = 6;
    readonly float Baz = 7;

    void F() {
        int hello = 1;
        int _world = 2;
        int Uppercase = 3;

        Console.WriteLine($"{foo} {_bar} {Baz} {hello} {_world} {Uppercase}");
    }
}

Your Environment

JetBrains Rider 2023.3.3 Build #RD-233.14015.60, built on January 18, 2024 Runtime version: 17.0.9+7-b1087.11 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 11.0 .NET Core v7.0.10 x64 (Server GC) GC: G1 Young Generation, G1 Old Generation Memory: 4096M Cores: 32 Registry: editor.config.csharp.support=true ide.experimental.ui=true Non-Bundled Plugins: com.intellij.javafx (1.0.4) avalonia-rider (1.3.0) com.intellij.ml.llm (233.14015.147) com.github.copilot (1.4.14.4554) izhangzhihao.rainbow.brackets (2024.2.1)

izhangzhihao commented 2 months ago

Due to incomplete syntax support in the IDE, it is challenging to determine whether it's a variable or a type based solely on the syntax count. The current implementation roughly considers uniformly capitalizing the initial letter as a type and ignores highlighting. As this is rule-based and lacks further IDE syntax tree support, alternative approaches are needed for this issue. But I still don't have a good way to do this.

darthdeus commented 2 months ago

Hmm that's quite unfortunate, do you know if there's any kind of open issue on Jetbrains' issue tracker (https://youtrack.jetbrains.com/) that they could implement this so Rainbow Brackets could distinguish variables? It may be a long shot, but they do sometimes listen to feature requests :)

izhangzhihao commented 2 months ago

Ah, The Rider team already opened a ticket here: https://youtrack.jetbrains.com/issue/RIDER-12931/Semantic-Highlighting