开发者

Does IntelliJ IDEA reveal the method body when folding anonymous classes?

开发者 https://www.devze.com 2023-03-06 07:40 出处:网络
Based on IntelliJ\'s documentation, when folding an anonymous class you should still be able to see the contents of the inner method.See image below taken from their documentation:

Based on IntelliJ's documentation, when folding an anonymous class you should still be able to see the contents of the inner method. See image below taken from their documentation:

Does IntelliJ IDEA reveal the method body when folding anonymous classes?

This isn't the behavior I'm seeing though. Here is what I s开发者_开发技巧ee:

Does IntelliJ IDEA reveal the method body when folding anonymous classes?

I can only seem to collapse the inner method contents or the entire anonymous class body. Is this just an error in their documentation or is there a way to actually achieve this behavior?

======= UPDATE =========

I've accepted the answer from Peter Gromov, but there still seems to be something amiss with my version. When I have files open and set folding closures by default (File -> Settings -> Editor -> Code Folding -> Select 'Closures' under 'Collapse by default:'), it does seem to fold correctly as seen in the following image:

Does IntelliJ IDEA reveal the method body when folding anonymous classes?

Notice that the expanded Because shows a single collapsible region in the margin. Closing the file and reopening produces the following (after I collapse the first one):

Does IntelliJ IDEA reveal the method body when folding anonymous classes?

When first opening the file, both of these statements are expanded (issue #1). After collapsing the outer most region for the first statement, it folds over the entire anonymous class (issue #2) rather than how it worked before I closed the file. Notice also that the second statement that I've left open has an additional collapsible region for the method of the anonymous class (issue #3). This is how it behaves with the default folding settings for closures are turned off. There's definitely something buggy here. Since I've posted this question, there has been a new version released so perhaps the issue is only with the version I have (10.0.3), but as far as I know this is a fairly old feature. I'd welcome any explanation as to why I might be seeing these issues (including "Works on my machine").


What you want is called 'Closure folding' and can be turned on in the Code Folding settings.

0

精彩评论

暂无评论...
验证码 换一张
取 消