xtext formatter questions, including linewraping, keywords replacing
I have few questions about formatter of xtext. I'm dealing with a SQL-like
language.
I'm using three default setLinewrap() commands for comments. However it
will insert a space after SL_COMMENT,
like
UPDATE plays SET scores = scores - [ 12, 21 ] WHERE id = '123-afde'; //
removes all occurences of 12 and 21 from scores
SELECT * FROM myTable WHERE t = now();
become
UPDATE plays SET scores = scores - [ 12, 21 ] WHERE id = '123-afde';
// removes all occurences of 12 and 21 from scores
SELECT * FROM myTable WHERE t = now ( );
could I remove that extra space?
How to wrap at specific place only if line is too long? I tried
setLinewrap(0, 1, 1) but doesn't work.
For example
UPDATE table SET a = a + 1 WHERE a > 0;
UPDATE tablelongna SET c = c + 1 WHERE c IN (1, 2, 3, 4, 4, 5, 6, 7, 0, 7,
8);
become
UPDATE table SET a = a + 1 WHERE a > 0;
UPDATE tablelongna SET c = c + 1
WHERE c IN (1, 2, 3, 4, 4, 5, 6, 7, 0, 7, 8);
I use setLinewrap(2).after(T_SEMICOLON); and it works fine for usual case.
However for batch query
like this
BEGIN BATCH
UPDATE ......;
UPDATE ......;
APPLY BATCH;
NEXT QUERY.....
I try to use setLinewrap(1).before(K_APPLY); to overwrite it but it
doesn't work. Can't use setNoSpace() or setNoLinewrap() otherwise APPLY
BATCH will not have it's own line.
Can I replace all keyword to upper case in formatter? ex. select * from
foo; to SELECT * FROM foo;. It looks like all APIs can only manipulating
whitespaces/newlines?
Not sure it's my problem or not, I can't hot swap formatter in debug mode.
Such that I have to quit another Eclipse instance and run again to see
change.
No comments:
Post a Comment