Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » IMP » Toggle comment behavior in LPG editor
Toggle comment behavior in LPG editor [message #485543] Sun, 13 September 2009 01:37 Go to next message
Brian Payton is currently offline Brian PaytonFriend
Messages: 154
Registered: July 2009
Senior Member
Here's a minor fit'n'finish item I came across in the LPG source editor.

In the editor, the "Toggle comment" action (Ctrl+/) adds LPG comments in
a way that is kind of ugly. Let's say you have a rule like this:

col_expr_cl ::=
col_expr_spec
| col_expr_cl , col_expr_spec

The toggle comment action does this:

-- col_expr_cl ::=
-- col_expr_spec
-- | col_expr_cl , col_expr_spec

The equivalent action in the Java editor works a little differently. If
you toggle comments on this:

if (uniqueOpt != null) {
index.setUnique(true);
}

you get this:

// if (uniqueOpt != null) {
// index.setUnique(true);
// }

which I think makes it easier to spot sections of code that are
commented out.
Re: Toggle comment behavior in LPG editor [message #485945 is a reply to message #485543] Tue, 15 September 2009 15:23 Go to previous messageGo to next message
Robert M. Fuhrer is currently offline Robert M. FuhrerFriend
Messages: 294
Registered: July 2009
Senior Member
Brian Payton wrote:
> Here's a minor fit'n'finish item I came across in the LPG source editor.

Thanks for the report!

> In the editor, the "Toggle comment" action (Ctrl+/) adds LPG comments in
> a way that is kind of ugly. Let's say you have a rule like this:
>
> col_expr_cl ::=
> col_expr_spec
> | col_expr_cl , col_expr_spec
>
> The toggle comment action does this:
>
> -- col_expr_cl ::=
> -- col_expr_spec
> -- | col_expr_cl , col_expr_spec
>
> The equivalent action in the Java editor works a little differently. If
> you toggle comments on this:
>
> if (uniqueOpt != null) {
> index.setUnique(true);
> }
>
> you get this:
>
> // if (uniqueOpt != null) {
> // index.setUnique(true);
> // }
>
> which I think makes it easier to spot sections of code that are
> commented out.

You're right; the present heuristic - to place the line comment prefix
just before the first non-whitespace character only works well if all
the lines in question have the same indentation, e.g.:

int x, y;
x = 15;
y++;

becomes:

// int x, y;
// x = 15;
// y++;

But as you saw, the heuristic fails when the lines don't all have the
same indentation.

By the way, this isn't a problem just for LPG; this is what the IMP
runtime support for toggling comments does.

We can do either of two things:

1) Just insert the line comment start at the very beginning of the
line (as shown above).

2) Find the common whitespace prefix of all the lines in question
and insert just after that. That would produce instead:

// int x, y;
// x = 15;
// y++;

Comments? (No pun intended)

--
Cheers,
-- Bob

--------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center

IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
X10: Productive High-Performance Parallel Programming (http://x10.sf.net)
Re: Toggle comment behavior in LPG editor [message #486244 is a reply to message #485945] Wed, 16 September 2009 21:04 Go to previous messageGo to next message
Brian Payton is currently offline Brian PaytonFriend
Messages: 154
Registered: July 2009
Senior Member
I kind of like the common whitespace prefix approach. That's more like
I might do if I was commenting out by hand, and the commented-out code
doesn't stick out TOO much from the code around it.

Robert M. Fuhrer wrote:
> Brian Payton wrote:
>> Here's a minor fit'n'finish item I came across in the LPG source editor.
>
> Thanks for the report!
>
>> In the editor, the "Toggle comment" action (Ctrl+/) adds LPG comments
>> in a way that is kind of ugly. Let's say you have a rule like this:
>>
>> col_expr_cl ::=
>> col_expr_spec
>> | col_expr_cl , col_expr_spec
>>
>> The toggle comment action does this:
>>
>> -- col_expr_cl ::=
>> -- col_expr_spec
>> -- | col_expr_cl , col_expr_spec
>>
>> The equivalent action in the Java editor works a little differently.
>> If you toggle comments on this:
>>
>> if (uniqueOpt != null) {
>> index.setUnique(true);
>> }
>>
>> you get this:
>>
>> // if (uniqueOpt != null) {
>> // index.setUnique(true);
>> // }
>>
>> which I think makes it easier to spot sections of code that are
>> commented out.
>
> You're right; the present heuristic - to place the line comment prefix
> just before the first non-whitespace character only works well if all
> the lines in question have the same indentation, e.g.:
>
> int x, y;
> x = 15;
> y++;
>
> becomes:
>
> // int x, y;
> // x = 15;
> // y++;
>
> But as you saw, the heuristic fails when the lines don't all have the
> same indentation.
>
> By the way, this isn't a problem just for LPG; this is what the IMP
> runtime support for toggling comments does.
>
> We can do either of two things:
>
> 1) Just insert the line comment start at the very beginning of the
> line (as shown above).
>
> 2) Find the common whitespace prefix of all the lines in question
> and insert just after that. That would produce instead:
>
> // int x, y;
> // x = 15;
> // y++;
>
> Comments? (No pun intended)
>
Re: Toggle comment behavior in LPG editor [message #488408 is a reply to message #486244] Mon, 28 September 2009 14:43 Go to previous messageGo to next message
Robert M. Fuhrer is currently offline Robert M. FuhrerFriend
Messages: 294
Registered: July 2009
Senior Member
Thanks for the feedback! Anyone else want to voice their vote?

Brian Payton wrote:
> I kind of like the common whitespace prefix approach. That's more like
> I might do if I was commenting out by hand, and the commented-out code
> doesn't stick out TOO much from the code around it.
>
> Robert M. Fuhrer wrote:
>> Brian Payton wrote:
>>> Here's a minor fit'n'finish item I came across in the LPG source editor.
>>
>> Thanks for the report!
>>
>>> In the editor, the "Toggle comment" action (Ctrl+/) adds LPG comments
>>> in a way that is kind of ugly. Let's say you have a rule like this:
>>>
>>> col_expr_cl ::=
>>> col_expr_spec
>>> | col_expr_cl , col_expr_spec
>>>
>>> The toggle comment action does this:
>>>
>>> -- col_expr_cl ::=
>>> -- col_expr_spec
>>> -- | col_expr_cl , col_expr_spec
>>>
>>> The equivalent action in the Java editor works a little differently.
>>> If you toggle comments on this:
>>>
>>> if (uniqueOpt != null) {
>>> index.setUnique(true);
>>> }
>>>
>>> you get this:
>>>
>>> // if (uniqueOpt != null) {
>>> // index.setUnique(true);
>>> // }
>>>
>>> which I think makes it easier to spot sections of code that are
>>> commented out.
>>
>> You're right; the present heuristic - to place the line comment prefix
>> just before the first non-whitespace character only works well if all
>> the lines in question have the same indentation, e.g.:
>>
>> int x, y;
>> x = 15;
>> y++;
>>
>> becomes:
>>
>> // int x, y;
>> // x = 15;
>> // y++;
>>
>> But as you saw, the heuristic fails when the lines don't all have the
>> same indentation.
>>
>> By the way, this isn't a problem just for LPG; this is what the IMP
>> runtime support for toggling comments does.
>>
>> We can do either of two things:
>>
>> 1) Just insert the line comment start at the very beginning of the
>> line (as shown above).
>>
>> 2) Find the common whitespace prefix of all the lines in question
>> and insert just after that. That would produce instead:
>>
>> // int x, y;
>> // x = 15;
>> // y++;
>>
>> Comments? (No pun intended)
>>


--
Cheers,
-- Bob

--------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center

IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
X10: Productive High-Performance Parallel Programming (http://x10.sf.net)
Re: Toggle comment behavior in LPG editor [message #488518 is a reply to message #488408] Tue, 29 September 2009 04:52 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Robert M. Fuhrer wrote:
> Thanks for the feedback! Anyone else want to voice their vote?
>
I abstain; I'm not convinced either is better.

Perhaps a preference option.

Regards

Ed Willink



> Brian Payton wrote:
>> I kind of like the common whitespace prefix approach. That's more
>> like I might do if I was commenting out by hand, and the commented-out
>> code doesn't stick out TOO much from the code around it.
>>
>> Robert M. Fuhrer wrote:
>>> Brian Payton wrote:
>>>> Here's a minor fit'n'finish item I came across in the LPG source
>>>> editor.
>>>
>>> Thanks for the report!
>>>
>>>> In the editor, the "Toggle comment" action (Ctrl+/) adds LPG
>>>> comments in a way that is kind of ugly. Let's say you have a rule
>>>> like this:
>>>>
>>>> col_expr_cl ::=
>>>> col_expr_spec
>>>> | col_expr_cl , col_expr_spec
>>>>
>>>> The toggle comment action does this:
>>>>
>>>> -- col_expr_cl ::=
>>>> -- col_expr_spec
>>>> -- | col_expr_cl , col_expr_spec
>>>>
>>>> The equivalent action in the Java editor works a little
>>>> differently. If you toggle comments on this:
>>>>
>>>> if (uniqueOpt != null) {
>>>> index.setUnique(true);
>>>> }
>>>>
>>>> you get this:
>>>>
>>>> // if (uniqueOpt != null) {
>>>> // index.setUnique(true);
>>>> // }
>>>>
>>>> which I think makes it easier to spot sections of code that are
>>>> commented out.
>>>
>>> You're right; the present heuristic - to place the line comment prefix
>>> just before the first non-whitespace character only works well if all
>>> the lines in question have the same indentation, e.g.:
>>>
>>> int x, y;
>>> x = 15;
>>> y++;
>>>
>>> becomes:
>>>
>>> // int x, y;
>>> // x = 15;
>>> // y++;
>>>
>>> But as you saw, the heuristic fails when the lines don't all have the
>>> same indentation.
>>>
>>> By the way, this isn't a problem just for LPG; this is what the IMP
>>> runtime support for toggling comments does.
>>>
>>> We can do either of two things:
>>>
>>> 1) Just insert the line comment start at the very beginning of the
>>> line (as shown above).
>>>
>>> 2) Find the common whitespace prefix of all the lines in question
>>> and insert just after that. That would produce instead:
>>>
>>> // int x, y;
>>> // x = 15;
>>> // y++;
>>>
>>> Comments? (No pun intended)
>>>
>
>
Re: Toggle comment behavior in LPG editor [message #576576 is a reply to message #485543] Tue, 15 September 2009 15:23 Go to previous message
Robert M. Fuhrer is currently offline Robert M. FuhrerFriend
Messages: 294
Registered: July 2009
Senior Member
Brian Payton wrote:
> Here's a minor fit'n'finish item I came across in the LPG source editor.

Thanks for the report!

> In the editor, the "Toggle comment" action (Ctrl+/) adds LPG comments in
> a way that is kind of ugly. Let's say you have a rule like this:
>
> col_expr_cl ::=
> col_expr_spec
> | col_expr_cl , col_expr_spec
>
> The toggle comment action does this:
>
> -- col_expr_cl ::=
> -- col_expr_spec
> -- | col_expr_cl , col_expr_spec
>
> The equivalent action in the Java editor works a little differently. If
> you toggle comments on this:
>
> if (uniqueOpt != null) {
> index.setUnique(true);
> }
>
> you get this:
>
> // if (uniqueOpt != null) {
> // index.setUnique(true);
> // }
>
> which I think makes it easier to spot sections of code that are
> commented out.

You're right; the present heuristic - to place the line comment prefix
just before the first non-whitespace character only works well if all
the lines in question have the same indentation, e.g.:

int x, y;
x = 15;
y++;

becomes:

// int x, y;
// x = 15;
// y++;

But as you saw, the heuristic fails when the lines don't all have the
same indentation.

By the way, this isn't a problem just for LPG; this is what the IMP
runtime support for toggling comments does.

We can do either of two things:

1) Just insert the line comment start at the very beginning of the
line (as shown above).

2) Find the common whitespace prefix of all the lines in question
and insert just after that. That would produce instead:

// int x, y;
// x = 15;
// y++;

Comments? (No pun intended)

--
Cheers,
-- Bob

--------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center

IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
X10: Productive High-Performance Parallel Programming (http://x10.sf.net)
Re: Toggle comment behavior in LPG editor [message #576597 is a reply to message #485945] Wed, 16 September 2009 21:04 Go to previous message
Brian Payton is currently offline Brian PaytonFriend
Messages: 154
Registered: July 2009
Senior Member
I kind of like the common whitespace prefix approach. That's more like
I might do if I was commenting out by hand, and the commented-out code
doesn't stick out TOO much from the code around it.

Robert M. Fuhrer wrote:
> Brian Payton wrote:
>> Here's a minor fit'n'finish item I came across in the LPG source editor.
>
> Thanks for the report!
>
>> In the editor, the "Toggle comment" action (Ctrl+/) adds LPG comments
>> in a way that is kind of ugly. Let's say you have a rule like this:
>>
>> col_expr_cl ::=
>> col_expr_spec
>> | col_expr_cl , col_expr_spec
>>
>> The toggle comment action does this:
>>
>> -- col_expr_cl ::=
>> -- col_expr_spec
>> -- | col_expr_cl , col_expr_spec
>>
>> The equivalent action in the Java editor works a little differently.
>> If you toggle comments on this:
>>
>> if (uniqueOpt != null) {
>> index.setUnique(true);
>> }
>>
>> you get this:
>>
>> // if (uniqueOpt != null) {
>> // index.setUnique(true);
>> // }
>>
>> which I think makes it easier to spot sections of code that are
>> commented out.
>
> You're right; the present heuristic - to place the line comment prefix
> just before the first non-whitespace character only works well if all
> the lines in question have the same indentation, e.g.:
>
> int x, y;
> x = 15;
> y++;
>
> becomes:
>
> // int x, y;
> // x = 15;
> // y++;
>
> But as you saw, the heuristic fails when the lines don't all have the
> same indentation.
>
> By the way, this isn't a problem just for LPG; this is what the IMP
> runtime support for toggling comments does.
>
> We can do either of two things:
>
> 1) Just insert the line comment start at the very beginning of the
> line (as shown above).
>
> 2) Find the common whitespace prefix of all the lines in question
> and insert just after that. That would produce instead:
>
> // int x, y;
> // x = 15;
> // y++;
>
> Comments? (No pun intended)
>
Re: Toggle comment behavior in LPG editor [message #576661 is a reply to message #486244] Mon, 28 September 2009 14:43 Go to previous message
Robert M. Fuhrer is currently offline Robert M. FuhrerFriend
Messages: 294
Registered: July 2009
Senior Member
Thanks for the feedback! Anyone else want to voice their vote?

Brian Payton wrote:
> I kind of like the common whitespace prefix approach. That's more like
> I might do if I was commenting out by hand, and the commented-out code
> doesn't stick out TOO much from the code around it.
>
> Robert M. Fuhrer wrote:
>> Brian Payton wrote:
>>> Here's a minor fit'n'finish item I came across in the LPG source editor.
>>
>> Thanks for the report!
>>
>>> In the editor, the "Toggle comment" action (Ctrl+/) adds LPG comments
>>> in a way that is kind of ugly. Let's say you have a rule like this:
>>>
>>> col_expr_cl ::=
>>> col_expr_spec
>>> | col_expr_cl , col_expr_spec
>>>
>>> The toggle comment action does this:
>>>
>>> -- col_expr_cl ::=
>>> -- col_expr_spec
>>> -- | col_expr_cl , col_expr_spec
>>>
>>> The equivalent action in the Java editor works a little differently.
>>> If you toggle comments on this:
>>>
>>> if (uniqueOpt != null) {
>>> index.setUnique(true);
>>> }
>>>
>>> you get this:
>>>
>>> // if (uniqueOpt != null) {
>>> // index.setUnique(true);
>>> // }
>>>
>>> which I think makes it easier to spot sections of code that are
>>> commented out.
>>
>> You're right; the present heuristic - to place the line comment prefix
>> just before the first non-whitespace character only works well if all
>> the lines in question have the same indentation, e.g.:
>>
>> int x, y;
>> x = 15;
>> y++;
>>
>> becomes:
>>
>> // int x, y;
>> // x = 15;
>> // y++;
>>
>> But as you saw, the heuristic fails when the lines don't all have the
>> same indentation.
>>
>> By the way, this isn't a problem just for LPG; this is what the IMP
>> runtime support for toggling comments does.
>>
>> We can do either of two things:
>>
>> 1) Just insert the line comment start at the very beginning of the
>> line (as shown above).
>>
>> 2) Find the common whitespace prefix of all the lines in question
>> and insert just after that. That would produce instead:
>>
>> // int x, y;
>> // x = 15;
>> // y++;
>>
>> Comments? (No pun intended)
>>


--
Cheers,
-- Bob

--------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center

IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
X10: Productive High-Performance Parallel Programming (http://x10.sf.net)
Re: Toggle comment behavior in LPG editor [message #576675 is a reply to message #488408] Tue, 29 September 2009 04:52 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Robert M. Fuhrer wrote:
> Thanks for the feedback! Anyone else want to voice their vote?
>
I abstain; I'm not convinced either is better.

Perhaps a preference option.

Regards

Ed Willink



> Brian Payton wrote:
>> I kind of like the common whitespace prefix approach. That's more
>> like I might do if I was commenting out by hand, and the commented-out
>> code doesn't stick out TOO much from the code around it.
>>
>> Robert M. Fuhrer wrote:
>>> Brian Payton wrote:
>>>> Here's a minor fit'n'finish item I came across in the LPG source
>>>> editor.
>>>
>>> Thanks for the report!
>>>
>>>> In the editor, the "Toggle comment" action (Ctrl+/) adds LPG
>>>> comments in a way that is kind of ugly. Let's say you have a rule
>>>> like this:
>>>>
>>>> col_expr_cl ::=
>>>> col_expr_spec
>>>> | col_expr_cl , col_expr_spec
>>>>
>>>> The toggle comment action does this:
>>>>
>>>> -- col_expr_cl ::=
>>>> -- col_expr_spec
>>>> -- | col_expr_cl , col_expr_spec
>>>>
>>>> The equivalent action in the Java editor works a little
>>>> differently. If you toggle comments on this:
>>>>
>>>> if (uniqueOpt != null) {
>>>> index.setUnique(true);
>>>> }
>>>>
>>>> you get this:
>>>>
>>>> // if (uniqueOpt != null) {
>>>> // index.setUnique(true);
>>>> // }
>>>>
>>>> which I think makes it easier to spot sections of code that are
>>>> commented out.
>>>
>>> You're right; the present heuristic - to place the line comment prefix
>>> just before the first non-whitespace character only works well if all
>>> the lines in question have the same indentation, e.g.:
>>>
>>> int x, y;
>>> x = 15;
>>> y++;
>>>
>>> becomes:
>>>
>>> // int x, y;
>>> // x = 15;
>>> // y++;
>>>
>>> But as you saw, the heuristic fails when the lines don't all have the
>>> same indentation.
>>>
>>> By the way, this isn't a problem just for LPG; this is what the IMP
>>> runtime support for toggling comments does.
>>>
>>> We can do either of two things:
>>>
>>> 1) Just insert the line comment start at the very beginning of the
>>> line (as shown above).
>>>
>>> 2) Find the common whitespace prefix of all the lines in question
>>> and insert just after that. That would produce instead:
>>>
>>> // int x, y;
>>> // x = 15;
>>> // y++;
>>>
>>> Comments? (No pun intended)
>>>
>
>
Previous Topic:IMP depends on jdt?
Next Topic:errors in LEGHoverHelper.java
Goto Forum:
  


Current Time: Thu Apr 18 16:57:12 GMT 2024

Powered by FUDForum. Page generated in 0.02325 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top