Does "<lang.foldingBuilder .../>" belong into frontend or backend module?

While preparing a plugin for split mode, I’m often not sure where an extension belongs.
Is there a good guideline, metadata or similar to find out what’s best?

This is a case from intellij-community and I’d appreciate insights what’s correct.

The EditorConfig declares its foldingBuilder in the frontend module intellij.editorconfig.frontend:

<lang.foldingBuilder language="EditorConfig"
                     implementationClass="com.intellij.editorconfig.frontend.lang.editor.EditorConfigFoldingBuilder"/>

But the TOML declares it in the backend intellij.toml.backend:

<lang.foldingBuilder language="TOML" implementationClass="org.toml.ide.folding.TomlFoldingBuilder"/>

What’s the correct module?

I’ve the feeling that everything related to language and files are backend. I’ve similar question for inlay, that at least looking at the one on Diff are backend (for my understanding), but better if the authors give their point of view and guidelines.

Hey! Public documentation and inspections are a work in progress, so stay tuned.

Editor markup is synchronized between the frontend and backend, which means it can be implemented on either side and will eventually be propagated to the other. When possible, it usually makes sense to implement it on the frontend, because users can see the result immediately in the UI when interacting with foldings, without running into latency-related issues.

However, some plugins still implement it on the backend, either because the computation depends on knowledge available only there, or because the plugin has not been fully refactored yet and some parts still remain on the backend.

2 Likes

Thank you! That’s very helpful.

A related problem is that I don’t know where to put a syntax highlighter.
In intellij-community, the EditorConfig plugin implements it in the frontend: com.intellij.editorconfig.frontend.highlighting.EditorConfigSyntaxHighlighterFactory.

When I do the same, my syntax highlighter (with a factory and without) is never invoked when I run the IDE in split mode.
I couldn’t find anything in my frontend logs.
(It started working when I moved this into the backend)

Is syntax highlighting supposed to be implemented in backend or frontend?

Thanks!

Language support is expected to be implemented in the following way:

  • parserDefinition and lexer are registered in a shared plugin module, which makes them available on both the frontend and the backend. This is done so that your language’s PSI is exposed everywhere, allowing a broader range of plugins to benefit from reusing it.

  • Syntax highlighting belongs on the frontend, because there it works regardless of latency.

Is it only this specific extension that is not working on the frontend, or are other extensions also affected?

Could I ask you to try registering a dummy action or tool window in the frontend plugin module and check whether it is accessible? That would help us diagnose the issue more precisely.