How can i create a plugin to create custom java code folding when every open java file ?


I hava see demo : SimpleFoldingBuilder in  sdk-code-example , but the deom can not collapse code every open file.

but in impl of AbstractBundle , when a param annoation by @propertyKey, every open file while folding code then display property value,   how can i get the same  effect: collapse   custom Java code when open file



I'm not sure I understand the case. Do you mean that some foldings are not enabled when you open the file? Is it random behavior?

Please describe what is happening in detail, with screenshots.



expect: file ,all folding area are collapsed

2.expand all filding area 

3.close file

4.reopen file

when reopen file,all folding area are collapsed,like first step.


“message” method is 

fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String {
	return CodeGlanceBundle.getAdaptedMessage(key, *params)

What's above is what I expect. i think it may achieve by PropertyFoldingBuilder,but i find there is non diff between   PropertyFoldingBuilder and SimpleFoldingBuilder .


but when i do like this,

1.first use Intellij idea open file, folding area are collapsed

2.expand folding area

3.close file 

4.reopen file , folding area don not collapse .


May I ask how to achieve the desired results?





Thank you for the explanation. This is the expected behavior. Folding state should be remembered even between IDE restarts.



But why does the code that calls the "message" method get folded every time the file is reopened, regardless of whether it was folded before opening? What can I do if I want to achieve this effect?

may this feature call i18n folding? i really want to know how this ,and use in my plugin .Please help me .


And i find the feature only effect in UE , CE is not support 



I can't reproduce your behavior with message(). When I open a file:

  1. Messages are collapsed (I see the values, not the code).
  2. I expand messages (I see the actual code).
  3. I close the file.
  4. I reopen the file.
  5. I see expanded messages (the actual code).
  6. I restart the IDE.
  7. I see expanded messages (the actual code).

In short, the state is remembered and restored on file reopening or the IDE restart.

If you experience it, I think this is an unexpected behavior. I don't see any configuration option that allows controlling it. Is it possible that your folding state is not remembered due to cleaning up the IDE state (e.g., when using sandbox IDE)?



Thinks for your reply,

I open same project use UE edition and CE edition  Intellij Idea,   the effect I want is in the video of UE.

Intellij Idea 2023.3.4 UE edition :


The project in two video is from :

For successful build you need to find and delete the following code, 

signPlugin {
		certificateChainFile.set(File(env.getOrDefault("CERTIFICATE_CHAIN", "$dir/pluginCert/chain.crt")))
		privateKeyFile.set(File(env.getOrDefault("PRIVATE_KEY", "$dir/pluginCert/private.pem")))
		password.set(File(env.getOrDefault("PRIVATE_KEY_PASSWORD", "$dir/pluginCert/password.txt")).readText(Charsets.UTF_8))

please  open file :com.nasller.codeglance.config.CodeGlanceConfigurable ,


	private fun EditorKind.getMessageWidth() = when(this){

then repeat your previous steps.

Looking forward to your reply.


My plugin is not executed once my file is opened.

I make a folding region for call of method named 'getBoolean' in com.example.myinlayhints.MyFoldingBuilder,
and the test class in video is in Test directory.

there is my plugin video :

and there is my code :

Looking forward to your reply.



This is the correct behavior, and your video looks like a bug (I suggest reporting it).

I checked both projects and everything worked as expected for me. In both projects, the folding state is remembered after a file is reopened. This is also presented on your last video (

Unfortunately, resetting the state after editor reopening is not currently supported. Please vote and follow this issue:


thinks for your reply,i will follow the issue