Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsToggle comment behavior in LPG editor
https://www.eclipse.org/forums/index.php/mv/msg/154158/485543/#msg_485543
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:
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.]]>Brian Payton2009-09-13T01:37:30-00:00Re: Toggle comment behavior in LPG editor
https://www.eclipse.org/forums/index.php/mv/msg/154158/485945/#msg_485945
> 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)]]>Robert M. Fuhrer2009-09-15T15:23:51-00:00Re: Toggle comment behavior in LPG editor
https://www.eclipse.org/forums/index.php/mv/msg/154158/576576/#msg_576576
> 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)]]>Robert M. Fuhrer2009-09-15T15:23:51-00:00Re: Toggle comment behavior in LPG editor
https://www.eclipse.org/forums/index.php/mv/msg/154158/576597/#msg_576597
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)
>]]>Brian Payton2009-09-16T21:04:34-00:00Re: Toggle comment behavior in LPG editor
https://www.eclipse.org/forums/index.php/mv/msg/154158/486244/#msg_486244
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)
>]]>Brian Payton2009-09-16T21:04:34-00:00Re: Toggle comment behavior in LPG editor
https://www.eclipse.org/forums/index.php/mv/msg/154158/576661/#msg_576661
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)]]>Robert M. Fuhrer2009-09-28T14:43:55-00:00Re: Toggle comment behavior in LPG editor
https://www.eclipse.org/forums/index.php/mv/msg/154158/488408/#msg_488408
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)]]>Robert M. Fuhrer2009-09-28T14:43:55-00:00Re: Toggle comment behavior in LPG editor
https://www.eclipse.org/forums/index.php/mv/msg/154158/488518/#msg_488518
> 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)
>>>
>
>]]>Ed Willink2009-09-29T04:52:48-00:00Re: Toggle comment behavior in LPG editor
https://www.eclipse.org/forums/index.php/mv/msg/154158/576675/#msg_576675
> 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)
>>>
>
>]]>Ed Willink2009-09-29T04:52:48-00:00