Code folding - getPlaceholderText not executing?

Hi everyone,

I was able to implement a FoldingBuilderEx class, and it works pretty well. I am specifically trying to code fold annotations that have lots of values. This works really well when the annotation is "on top" like this:

(before folding)

retentionTime = "",
destination = "",
purposeDescription = "Heya how is it going",
encryptedInTransmission = false)
final<Object> add = queue.add(null)

(after folding)

@NetworkAnnotation ("Heya how is it going")
final<Object> add = queue.add(null)

However, if the annotation is embedded in a method to annotate its parameters, like below:

new LocationListener() {
public void onLocationChanged(
purposeDescription={"Provide location-based weather information"},
frequency={"When the app is open"},
Location location) {


Then the LocationAnnotation does not fold correctly. Instead it folds to this: @{ ... } and the getPlaceholderText method in the FoldingDescriptor I create is never even called.

Any help is greatly appreciated. Thanks!


It might be builtin Java annotation folding, please check whether com.intellij.codeInsight.folding.impl.JavaFoldingBuilderBase#addAnnotationsToFold interferes here.


Hi there,

I think I have a similar problem. I want to create a FoldingDescriptor for large swagger annotations, e.g. ApiOperation. Plugin source code at

My class extends FoldingBuilderEx.

During development I have found that the CompositeFoldingBuilder only registers one FoldingDescriptor per region, hence I set the order of my extension in plugin.xml to "first". This made my unit tests and "runIde" work. There is already another thread about a similar issue

Unit tests are green, gradle task runIde also works. Fine. But when I install the plugin from disk and open a Java project in Intellij, it does not work.

Yann Cebron says that it might be because com.intellij.codeInsight.folding.impl.JavaFoldingBuilderBase#addAnnotationsToFold interferes with my plugin code. According to the symptoms that is true (my plugin is loaded without errors, but annotation is still fold to @{...}). But what can I do to prevent this interference?

Then I stumbled upon this thread, stating java code folding can not simply be overwritten the same way code folding of a custom language plugin might be ovewritten. Is this true? If so, how exactly would I use the proposed TextEditorHighlightingPass to accomplish java code folding customization?


Thanks for any help, leading me into the right direction :)


Please sign in to leave a comment.