eclipse-archived / ceylon.formatter

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

by default, formatter removes newlines before extends/satisfies #62

Closed gavinking closed 10 years ago

gavinking commented 10 years ago

By default, this:

class Bar() 
    extends Foo() 
    satisfies Baz {}

Gets turned into this:

class Bar() extends Foo() satisfies Bar {}
lucaswerkmeister commented 10 years ago

Not on the command line (although extends and satisfies are indented by 2 levels instead of 1). Probably an IDE integration issue.

lucaswerkmeister commented 10 years ago

Oh, I know what’s happening, and it should’ve been obvious. I’m stupid.

The code I hacked together (without ever being able to test it – it’s remarkable it works as well as it does :D ), and that’s now in the IDE, doesn’t pass a TokenStream to the formatter – which means the formatter can’t know that you have line breaks in your code. I assume the IDE already has a token stream somewhere? (Needs to be a BufferedTokenStream though – CommonTokenStream removes WS.)

(At the moment, the IDE is a big, unindented test case for #17. Glad to know it actually works :) )

lucaswerkmeister commented 10 years ago

Okay, I can get a List<CommonToken> from the CeylonParseController (and it includes WS tokens)… can I turn that into a TokenSource somehow?

lucaswerkmeister commented 10 years ago

Well TokenSource is a very basic interface (I thought it had all that LT stuff I’d have to worry about), so I can just implement it directly.

ceylon-ide-eclipse PR incoming…

gavinking commented 10 years ago

The token stream is available from the CeylonParseController.

Sent from my iPhone

On 26 Jun 2014, at 3:41 pm, Lucas Werkmeister notifications@github.com wrote:

Oh, I know what’s happening, and it should’ve been obvious. I’m stupid.

The code I hacked together (without ever being able to test it – it’s remarkable it works as well as it does :D ), and that’s now in the IDE, doesn’t pass a TokenStream to the formatter – which means the formatter can’t know that you have line breaks in your code. I assume the IDE already has a token stream somewhere? (Needs to be a BufferedTokenStream though – CommonTokenStream removes WS.)

(At the moment, the IDE is a big, unindented test case for #17. Glad to know it actually works :) )

— Reply to this email directly or view it on GitHub.