[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.technology.imp] Re: Toggle comment behavior in LPG editor
|
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)