#region ?

Hi,

I recently used Microsoft Visual C#, and there's one feature that is
cool : "regions".
In C# you can mark code like this :

#region Part of the code that handles requests

... (code) ...

#endregion

Then the editor will allow collapsing of this part of the code and draw
a small box with the text inside

Now wouldn't it be cool to have an Idea plugin that does the same (with
//region and //endregion instead, of course (or other user-definable
keywords))?

So my questions are :
1/ does it already exist (I looked quickly at the repository, didn't
notice anything like that, but there's a lot so maybe I missed it)
2/ (if not) is there everything needed in the openApi to do it?

Thanks !

BoD

12 comments

BoD wrote:

Hi,

I recently used Microsoft Visual C#, and there's one feature that is
cool : "regions".
In C# you can mark code like this :

#region Part of the code that handles requests

... (code) ...

#endregion

Then the editor will allow collapsing of this part of the code and draw
a small box with the text inside

Now wouldn't it be cool to have an Idea plugin that does the same (with
//region and //endregion instead, of course (or other user-definable
keywords))?

So my questions are :
1/ does it already exist (I looked quickly at the repository, didn't
notice anything like that, but there's a lot so maybe I missed it)
2/ (if not) is there everything needed in the openApi to do it?

Thanks !

BoD


IDEA already does this. It is called folding.

Just highlight the "Region" you want to collapse and press {ctrl+.] or use the
View->Folding->Fold Selection.

0

It's not quite the same thing.
I want the code to have folding information (so it will be available
to other developpers), and to allow folding by default.
Also the folding outline displays the name of the region (instead of "...")

See what I mean?


BoD



Tim Haley wrote:

BoD wrote:

>> Hi,
>>
>> I recently used Microsoft Visual C#, and there's one feature that is
>> cool : "regions".
>> In C# you can mark code like this :
>>
>> #region Part of the code that handles requests
>>
>> ... (code) ...
>>
>> #endregion
>>
>> Then the editor will allow collapsing of this part of the code and
>> draw a small box with the text inside
>>
>> Now wouldn't it be cool to have an Idea plugin that does the same
>> (with //region and //endregion instead, of course (or other
>> user-definable keywords))?
>>
>> So my questions are :
>> 1/ does it already exist (I looked quickly at the repository, didn't
>> notice anything like that, but there's a lot so maybe I missed it)
>> 2/ (if not) is there everything needed in the openApi to do it?
>>
>> Thanks !
>>
>> BoD


IDEA already does this. It is called folding.

Just highlight the "Region" you want to collapse and press {ctrl+.] or
use the View->Folding->Fold Selection.

0

This is similar to an Apple Xcode feature which allows you to mark sections like
#pragma mark Component Handling

Which then shows up in Xcode's "structure view"-like menu at the top of the
editor, as a separator between class members.

I would like some feature like this, if integrated with structure view.

BoD wrote:

Hi,

I recently used Microsoft Visual C#, and there's one feature that is
cool : "regions".
In C# you can mark code like this :

#region Part of the code that handles requests

.... (code) ...

#endregion

Then the editor will allow collapsing of this part of the code and draw
a small box with the text inside

Now wouldn't it be cool to have an Idea plugin that does the same (with
//region and //endregion instead, of course (or other user-definable
keywords))?

So my questions are :
1/ does it already exist (I looked quickly at the repository, didn't
notice anything like that, but there's a lot so maybe I missed it)
2/ (if not) is there everything needed in the openApi to do it?

Thanks !

BoD

0

Agree! Although I'm using rearranger to do it now...

0

I agree that it would be even more useful if it's integrated with the
structure view.

BoD


Keith Lea wrote:

This is similar to an Apple Xcode feature which allows you to mark
sections like
#pragma mark Component Handling

Which then shows up in Xcode's "structure view"-like menu at the top of
the editor, as a separator between class members.

I would like some feature like this, if integrated with structure view.

BoD wrote:

>> Hi,
>>
>> I recently used Microsoft Visual C#, and there's one feature that is
>> cool : "regions".
>> In C# you can mark code like this :
>>
>> #region Part of the code that handles requests
>>
>> .... (code) ...
>>
>> #endregion
>>
>> Then the editor will allow collapsing of this part of the code and
>> draw a small box with the text inside
>>
>> Now wouldn't it be cool to have an Idea plugin that does the same
>> (with //region and //endregion instead, of course (or other
>> user-definable keywords))?
>>
>> So my questions are :
>> 1/ does it already exist (I looked quickly at the repository, didn't
>> notice anything like that, but there's a lot so maybe I missed it)
>> 2/ (if not) is there everything needed in the openApi to do it?
>>
>> Thanks !
>>
>> BoD

0

BoD wrote:

It's not quite the same thing.
I want the code to have folding information (so it will be available
to other developpers), and to allow folding by default.
Also the folding outline displays the name of the region (instead of "...")

See what I mean?


BoD


I do see what you mean...

However, I don't want my code to have anything in it that is used exclusively for the IDE.
My code is java code, designed for execution. Anything that is exclusively for the IDE
should be stored external to my code. After all, other developers who look at the code may
not be using IDEA.

If you want to share code with other developers who are using IDEA, try the IDEATalk plugin,
or vote for the recent requests to incorporate team/remote pair programming functionality
into IDEA.

Tim

0

????[/url]
sql?????[/url]
????[/url]
sql?????[/url]
???????[/url]
??????[/url]
???[/url]
?????[/url]
????[/url]
sql server??[/url]
????[/url]
??????[/url]
?????[/url]
?????[/url]
??????[/url]
?????[/url]
???????[/url]
raid????[/url]
????[/url]
sql?????[/url]
????????[/url]
raid????[/url]
sql??[/url]
????[/url]
??????[/url]
???[/url]
??????[/url]
?????[/url]
sql server??[/url]

???????[/url]
????[/url]

0

????[/url]
sql?????[/url]
????[/url]
sql?????[/url]
???????[/url]
??????[/url]
???[/url]
?????[/url]
????[/url]
sql server??[/url]
????[/url]
??????[/url]
?????[/url]
?????[/url]
??????[/url]
?????[/url]
???????[/url]
raid????[/url]
????[/url]
sql?????[/url]
????????[/url]
raid????[/url]
sql??[/url]
????[/url]
??????[/url]
???[/url]
??????[/url]
?????[/url]
sql server??[/url]

???????[/url]
????[/url]

0

Well I understand your point of view. The nice people who designed the
C# language did not have the same opinion.
Furthermore the concept of annotation can sometimes be used only for the
IDE, and I don't think it is a "bad practice" per se.

About this #region thing, I just see it as a special comment that
describe the beginning and the end of a section, I think these comments
already exist in most projects, but in various forms. Ultimately the
plugin I'd like to do (some day, if I have time) would be configurable
so it could use the already existing comment convention of a particular
project.

BoD



Tim Haley wrote:

BoD wrote:

>> It's not quite the same thing.
>> I want the code to have folding information (so it will be available
>> to other developpers), and to allow folding by default.
>> Also the folding outline displays the name of the region (instead of
>> "...")
>>
>> See what I mean?
>>
>>
>> BoD
>>


I do see what you mean...

However, I don't want my code to have anything in it that is used
exclusively for the IDE. My code is java code, designed for execution.
Anything that is exclusively for the IDE should be stored external to my
code. After all, other developers who look at the code may not be using
IDEA.

If you want to share code with other developers who are using IDEA, try
the IDEATalk plugin, or vote for the recent requests to incorporate
team/remote pair programming functionality into IDEA.

Tim

0

BoD wrote:

Well I understand your point of view. The nice people who designed the
C# language did not have the same opinion.


The nice people who designed C# want you to be locked into their IDE. One of the nice
things about java is that it can be developed in any IDE or editor without having to worry
about breaking IDE functionality as long as the java code is valid.

Furthermore the concept of annotation can sometimes be used only for the
IDE, and I don't think it is a "bad practice" per se.


I disagree, annotations help the developer understand the code, whether the IDE is using
them or not. They can also be used to enhance the functionality and reliability of the
code. The compiler/jvm can use them, unlike special comments.


About this #region thing, I just see it as a special comment that
describe the beginning and the end of a section, I think these comments
already exist in most projects, but in various forms. Ultimately the
plugin I'd like to do (some day, if I have time) would be configurable
so it could use the already existing comment convention of a particular
project.


As a configurable plugin, I have no problem with it. Used in conjunction with the
rearranger plugin, which can insert special comments around different sections of code, I
can see that it could be quite useful. However, be sure to handle gracefully the situation
where your special comments are mismatched because someone went in and manually screwed
them up or removed them entirely because they thought that they were just in the way. That
was one of the big issues that many developers had with VisualCafe.

Tim

0

Tim Haley wrote:


The nice people who designed C# want you to be locked into their IDE.


I hear you :)
But actually another IDE for C# can just ignore these comments. You're
not exactly "locked" because of that...

As a configurable plugin, I have no problem with it. Used in
conjunction with the rearranger plugin, which can insert special
comments around different sections of code, I can see that it could be
quite useful. However, be sure to handle gracefully the situation where
your special comments are mismatched because someone went in and
manually screwed them up or removed them entirely because they thought
that they were just in the way. That was one of the big issues that
many developers had with VisualCafe.


Well.. If there are two "begin" markers in a row, I guess the code can
assume the second one marks the begin of a new section AND the end of
the previous one.
What's the worst thing that can happen anyway? The folding not being
correct... I don't see this as "dangerous" :)

BoD

0

Please sign in to leave a comment.