What is this feature called? Preview the ResourceBundle property value

Answered

In my plugin source code,  a ResourceBundle can be previewed:

Please tell me what is this feature called? How  could I enable/disable this feature, and how could I use this feature in my plugin?

Because I write another ResourceBundle in another non-plugin project, this feature doesn't work!

0
4 comments

Thank you so much. But seems folding is not the default behavior, I wrote a ResouceBundle like this:

    private static final String BUNDLE = "i18n.messages";

    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE);

    public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
        if (params == null) {
            return RESOURCE_BUNDLE.getString(key);
        } else {
            return MessageFormat.format(RESOURCE_BUNDLE.getString(key), params);
        }
    }
    
	public static void main(String[] args) {
        MessageBundle.message("test");
    }

The method MessageBundle.message can be folded only if I use the collapse shortcut, by deafult it's not folded, even if I close the file and reopen it.

How can I set folding as default?

And below is my setting:

1

I'm not sure if you try to implement this feature or just use it. If implement, see com.intellij.lang.folding.FoldingBuilderEx#isCollapsedByDefault.

If use, please use product support forums: https://www.jetbrains.com/support/

1

Because IDEA remembers whether a file was folded or unfolded the last time it was opened, the  com.intellij.lang.folding.FoldingBuilderEx#isCollapsedByDefault  method only controls the default state when the file is first opened.

If you want to implement the same folding state each time you open a file, you can use an event listener to detect when the file is opened. Each time the file is opened, you can retrieve and apply the specified folding state for that file.

You can refer to this:

https://github.com/xiaoyan94/Idea-Plugin-OneClickNavigation/blob/main/src/main/java/com/zhiyin/plugins/listeners/MyFileEditorManagerListener.java

2

Please sign in to leave a comment.