eclipse-archived / ceylon.formatter

A formatter for the Ceylon programming language, written in Ceylon.
Apache License 2.0
14 stars 11 forks source link

FormattingWriter: fast-forwarding non-AntlrTokens #9

Closed lucaswerkmeister closed 10 years ago

lucaswerkmeister commented 10 years ago

currently, FormattingWriter only fast-forwards AntlrTokens. I noticed now that this leads to problems; for example, the ,s in a PositionalArgumentList are written as "," (that is, as String instead of as AntlrToken). Of course, they are still in the TokenStream, and the next fastForward will break on them.

I’m not sure how to solve this. Should I change addToken to fast-forward in any case? This wouldn’t be difficult: The fast-forward tokenConsumer only uses token.text, which would be replaced by token for strings. Or should I try to somehow pry the , from the TokenStream in order to be able to give it to addToken for proper fast-forwarding?

lucaswerkmeister commented 10 years ago

I’m leaning towards the first solution, not only because I’m lazy, but also because trying to somehow get the , token will make the visitor much less readable.