material-theme-issues icon indicating copy to clipboard operation
material-theme-issues copied to clipboard

[Bug]: Language Additions highlighted everywhere (e.g. even for variables, methods etc)

Open vhagedorn opened this issue 10 months ago • 11 comments

Describe the bug

Local variables and functions named with certain kotlin keywords (namely open and data as those are most common) are highlighted as keywords when they are in fact valid kotlin variable or function names.

NOTE: The current installed version of IntelliJU (Windows 10) is attached in the sysinfo section, however the bug exists in the latest IntelliJC version on MacOS as well, and it appears to be a direct result of the Material Theme UI plugin (as the issue goes away if you disable the plugin).

To Reproduce

1. Create a kotlin file (in this case, object Main.kt). 2. Create a method with a local variable called open, data, or some other soft keyword. 3. Observe that syntax highlighting is broken for open and data variables. Note that not all keywords are broken, for example enum and catch as local variables have the correct highlighting. 4. Compile and run with method of choice (in this case, the green play button was pressed).

Expected behavior

The variables/functions do not have keyword highlighting and remain looking like the rest of the code.

Material Theme Version

v8.11.0

IDE

IntelliJ IDEA

System Info

IntelliJ IDEA 2022.3 (Ultimate Edition)

Build #IU-223.7571.182, built on November 29, 2022

Licensed to XXXXXXXXXXX

Subscription is active until December 15, 2023.

For educational use only.

Runtime version: 17.0.5+1-b653.14 amd64

VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Windows 10 10.0

GC: G1 Young Generation, G1 Old Generation

Memory: 10240M

Cores: 6

Registry:

    editor.focus.mode.color.light=464b5d

    ide.editor.tab.selection.animation=true

    ide.new.editor.tabs.vertical.borders=true

    ide.balloon.shadow.size=0

    editor.focus.mode.color.dark=464b5d

Non-Bundled Plugins:

    com.darkyen.darkyenustimetracker (1.5.3)

    Batch Scripts Support (1.0.13)

    com.github.b3er.idea.plugins.arc.browser (0.32)

    IdeaVIM (2.1.0)

    Statistic (4.2.7)

    com.alayouni.ansiHighlight (22.3.5)

    Builder Generator (1.3.0)

    com.intellij.gwt (223.7571.182)

    me.serce.solidity (2.4.2)

    Pythonid (223.7571.182)

    com.chrisrm.idea.MaterialThemeUI (8.4.1)

    com.mallowigi (85.1.0)

    mobi.hsz.idea.gitignore (4.4.4)

Kotlin: 223-1.7.20-release-201-IJ7571.182

Logs/Screenshots

The bug in action: image

vhagedorn avatar Sep 01 '23 20:09 vhagedorn

Not possible. I tried fixing that but to no avail. If that bothers you that much turn off the Language Additions feature.

mallowigi avatar Sep 02 '23 07:09 mallowigi

Would there be any way to disable it per-language? It only seems to struggle with kotlin for some reason.

Thanks, Vadim

vhagedorn avatar Sep 04 '23 15:09 vhagedorn

Not currently, maybe in the future. But what is the problem exactly?

mallowigi avatar Sep 05 '23 06:09 mallowigi

I can live without it in Kotlin but not in Java 😬 BTW, there is an active JetBrains issue tracking this as well

--Regards

vhagedorn avatar Sep 05 '23 15:09 vhagedorn

Oh this, yeah, there's no fix for this issue yet. But why does it bother you? it's not like these names are used a lot, after all it's generally bad practice to name a variable with a reserved keyword.

Also, why are you opening issues from the plugin on YouTrack? These are not the JB folks' responsibility.

mallowigi avatar Sep 05 '23 15:09 mallowigi

I had created it before I realized the culprit. Then linking this issue reopened it.

Thanks for commenting on the YouTrack and reopening this one!

no rush fixing it btw -- it's just that I have a lib project which has a method called "open", and every month when I have to go and fix a bug I can't help but notice the highlighting is off 😛

You're right though; this is a very niche issue that could even be considered "bad practice deterrent"

vhagedorn avatar Sep 06 '23 05:09 vhagedorn

Closing such issues to focus on solvable ones.

mallowigi avatar Jan 27 '24 14:01 mallowigi

Hey, I am thinking this should be left open as I think it is a real and solvable issue.

For example, when I enable Language Additions I see this in my code:

Screenshot 2024-04-09 at 2 56 38 PM

This bothers me because it is normal for me to name some packages "data", for example and in principle I shouldn't feel like I have to change them just because of this plugin.

Kotlin supports naming packages "data" even though it is a keyword as well. You might say it is bad practice to use keywords as names if you are speaking very generally and broadly about programming but in this case naming packages "data" is supported by kotlin, so this plugin should support it as well.

I'm not understanding why this was considered unsolvable. The IntelliJ PSI API should be able to easily distinguish keywords from non-keywords, shouldn't it? I hope this can be reopened @mallowigi

mgroth0 avatar Apr 09 '24 19:04 mgroth0

The reasons above still stand. There are other plugins that might have found a better solution like the Better Highlights plugin. I encourage you to take a look at that plugin to see if it can provide an alternative that works as expected, but for my point of view I do not intend to refactor the whole code when the current solution exists, albeit with flaws.

mallowigi avatar Apr 09 '24 20:04 mallowigi

I am happy to take a closer look. If I understand correctly, Better Highlights is not open sourced so I am mostly limited to making vague suggestions which I already did in my previous comment:

The IntelliJ PSI API should be able to easily distinguish keywords from non-keywords

What is the current solution? Is it not using the PSI API?

mgroth0 avatar Apr 10 '24 02:04 mgroth0

I'm not particularly fond of discussing implementation details in public. You can come to the Slack channel to discuss if you want.

mallowigi avatar Apr 10 '24 04:04 mallowigi