eclipse-archived / ceylon.formatter

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

Allow the formatter to run without a TokenStream #17

Closed lucaswerkmeister closed 10 years ago

lucaswerkmeister commented 10 years ago

If the formatter could run without a TokenStream, it would be a general code generator for Ceylon. In conjunction with a ceylon.ast module, I would love to see something like this:

formatter.format(
    CompilationUnit {
        imports = [];
        Function {
            name = "run";
            params = [];
            specifierExpression = Block {
                InvocationExpression(`function print`, [StringLiteral("Hello, World!")]);
            };
        };
    });
lucaswerkmeister commented 10 years ago

Oh wow, the TokenStream is used only in fastForward. That’s neat, that means that this is super easy – just return immediately there if the TokenStream is null!

lucaswerkmeister commented 10 years ago

Hm, not quite – apparently that eats some line breaks. I hope I’ll still be able to keep all changes in that method.