javaeclipsesyntax-highlighting

Very slow Eclipse syntax highlighting


I'm contributing to a big Java project with around 30k source files. Last week, I switched from Eclipse 2023-09 to Eclipse 2024-09, and now it looks like some of the syntax coloring (e.g. for fields, variables, arguments and annotations, but not keywords nor String literals) takes ages to appear (I can't tell how long, but most of the time I give up after a few minutes), and warnings take even longer. Both only took a few seconds when I used Eclipse 2023-09.

To make it clearer, this is how it looks like most of the time:
partial highlighting

And this is what I expect:
complete highlighting

This problem does not occur on a new project created from scratch. Moreover, when I first open a JDK source file by following a hyperlink (Ctrl+click) from a class in the big project, I have the same highlighting problem, while I don't if I first open it by browsing the JRE library or with a hyperlink from the tiny project.

I installed Eclipse again without any plugin and edited eclipse.ini to replace the default JRE VM with a regular JDK (21.0.5+9) and add some RAM (-Xms2g and -Xmx15g), then I created a new workspace and only imported the raw project from the file system. When I open any Java file in this project, syntax coloring still takes minutes to complete (if it does at all) as opposed to seconds in my previous Eclipse.

I suspect this is a bug and I am considering reporting it, but I'm still hoping for a temporary workaround while it gets fixed.


Solution

  • It turned out my old workspace and my fresh one had unrelated problems, and I managed to fix my old workspace.

    My old workspace and its project were originally set up to have a Java 1.7 "Compiler compliance level" (resp. Preferences -> General -> Java -> Compiler, and right click on project -> Properties -> Java Compiler), which isn't supported anymore. When I accessed these menus, Eclipse showed me a warning telling they changed it to 1.8, but obviously the change wasn't effective. I had to set it manually to 1.8 even though it appeared to be 1.8.

    In my fresh workspace, Eclipse waits for me to edit a file before finishing highlighting it. I don't know why but I won't investigate because I'll keep using my old workspace, which is now OK.