Home » Archived » IMP » Toggle comment behavior in LPG editor
|
Re: Toggle comment behavior in LPG editor [message #485945 is a reply to message #485543] |
Tue, 15 September 2009 15:23 |
Robert M. Fuhrer 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 |
Brian Payton 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 |
Robert M. Fuhrer 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 |
Ed Willink Messages: 7670 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 |
Robert M. Fuhrer 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 |
Brian Payton 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 |
Robert M. Fuhrer 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 |
Ed Willink Messages: 7670 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)
>>>
>
>
|
|
|
Goto Forum:
Current Time: Tue Sep 24 03:41:09 GMT 2024
Powered by FUDForum. Page generated in 0.04056 seconds
|