Improving code folding

Hi,

I have couple of ideas how code folding in IDEA could be improved. Probably they
could have sense and somehow they could be integrated into IDEA or somebody will
write appropriate plug-in (I thinks this could be done via OpenApi,
unfortunately I don't have free time to implement it by myself).

1) Collapsing/expanding specific XML tags

I think that folding for XML may be improved if the user will be able to specify
folded regions based on particular XML tag. It will be great if it will be
possible to specify more than one tag that should be collapsed and, of course,
if IDEA will select list of available tags based on opened file.

2) Collapsing/folding of logging related code fragments.

Most logging related code fragments have regular structure. For example, if
Apache commons-logging is used, there are many fragments like this one:

if (fLog.isErrorEnabled())
{
fLog.error("Some Logging related message");
}

If other logging system is used (say Log4j), the same pattern will be used to.

As for me, it will be absolutely great if IDEA will have appropriate option that
will let the user to specify that logging related statements should be
collapsed automatically (exactly the same as it currently supported for imports
and JavaDoc comments, for example).

Do you think that these features could be usefull?


Best regards,
Andrew Sazonov

5 comments

I've just realized that potentially code folding could be integrated somehow
with structural search functionality and so the user will be able to specify own
patterns for collapsing/expanding regions...

Best regards,
Andrew Sazonov

0

My problem with improvements to folding is that folding is one-way. I
cannot edit the folded text. If I could collapse logger statements like
that to LOG(error,Some Logging related message) and then edit the
folded text to change "error" to "warning," it would be a huge
improvement. But until that exists, I think folding like this and like
the Camouflage plugin is not useful to me.

Andrew Sazonov wrote:

Hi,

I have couple of ideas how code folding in IDEA could be improved.
Probably they could have sense and somehow they could be integrated into
IDEA or somebody will write appropriate plug-in (I thinks this could be
done via OpenApi, unfortunately I don't have free time to implement it
by myself).

1) Collapsing/expanding specific XML tags

I think that folding for XML may be improved if the user will be able to
specify
folded regions based on particular XML tag. It will be great if it will
be possible to specify more than one tag that should be collapsed and,
of course, if IDEA will select list of available tags based on opened file.

2) Collapsing/folding of logging related code fragments.

Most logging related code fragments have regular structure. For example,
if Apache commons-logging is used, there are many fragments like this one:

if (fLog.isErrorEnabled())
{
fLog.error("Some Logging related message");
}

If other logging system is used (say Log4j), the same pattern will be
used to.

As for me, it will be absolutely great if IDEA will have appropriate
option that will let the user to specify that logging related
statements should be collapsed automatically (exactly the same as it
currently supported for imports and JavaDoc comments, for example).

Do you think that these features could be usefull?


Best regards,
Andrew Sazonov

0

What you are describing is not code folding. You're describing macros ala C/C++. I would LOVE IT if you could do something like that in IntelliJ. In fact, I thought about building a plugin to do something like it but I think that one would be a bit above my skill level since I haven't written a plugin yet. :)

0

I would like to see code folding functionality expanded as well. The structural search and replace style would definitely be nice. I would also like to colapse similar items in one large folded section. For example, instead of code folding individual setters and getters (which IntelliJ already does), I would like them collapsed into one chunk of folded code.

There's definitely lots of room for improvement here.

0

Marc Stock wrote:

What you are describing is not code folding. You're describing
macros ala C/C++. I would LOVE IT if you could do something like
that in IntelliJ. In fact, I thought about building a plugin to do
something like it but I think that one would be a bit above my skill
level since I haven't written a plugin yet. :)


I think it would be impossible to write such a plugin, because you would
have to present one view of the file to the editor and another to the
parser. Implementation of http://jetbrains.net/jira/browse/IDEABKL-3467
would allow for such a plugin, however, when combined with
implementation of http://www.jetbrains.net/jira/browse/IDEA-5955

0

Please sign in to leave a comment.