Alternatives for @Internal

Hi, folks:
I developed an IDEA plugin, but during the compatibility verification before publishing, it was flagged for using an internal API.

I used the class DocumentFragmentTooltipRenderer, which has now been marked as an internal API, to display tooltips.

I initially attempted to replace it with the following code:

DocumentFragment range = createDocumentFragment(editorEx, region);  
HintManager.getInstance().showInformationHint(editorEx, editorEx.getDocument().getText(range.getTextRange()));  

However, the tooltip no longer displays syntax highlighting as it originally did:

Any suggestions would be greatly appreciated.

Additionally, I have created this issue in the issue tracker.

Thanks for highlighting, discussion should continue in the created issue.

Hello @yann.cebron,

Regarding the previously mentioned plugin, to be precise, I have forked an outdated plugin.
It creates custom FoldRegions and uses

TooltipController.getInstance().showTooltip(  
    editor,  
    point,  
    new DocumentFragmentTooltipRenderer(documentFragment),  
    false,  
    FOLDING_TOOLTIP_GROUP  
);  

to display the original text of the folded region.

The effect is similar to:

Since DocumentFragmentTooltipRenderer has been marked as an internal API,
I would like to replace it with an alternative method, such as

HintManager.getInstance().showInformationHint

However, I noticed that other custom FoldRegions automatically display the original folded text when the mouse moves, even without using showTooltip.

How can I programmatically disable the automatic display of folded text for FoldRegion?

Why? Users should have opportunity to quickly inspect the folded context using the provided placeholderText.

Because I found that only this specific FOLDREGION requires calling DocumentFragmentTooltipRenderer manually to display the folded text when the mouse is moved, while other regions can display the folded text automatically,
I wanted to disable the automatic display for all regions and use an alternative method to show it manually.
Actually, I don’t quite understand when IDEA automatically displays the original text of a FoldRegion…

You can specify the placeholder text when building the fold region, not sure why there would be any need for anything else.
This behaviour with showing placeholder text (or ... if not specified) is consistent within the platform and should not be overridden by plugins.

@yann.cebron Thanks for the tip! I changed the placeholder text from an empty string to a zero-width space, so now even hidden FoldRegions will show the tooltip text when hovered over with the mouse.