Closed baulig closed 11 months ago
This is fantastic. I would love to integrate these changes into Floskell. Would you be willing to separate this into a separate PR without the test suite changes for now?
One comment on the implementation. You're using let pos = length (biLines iter) + length (biComments iter)
to compute the line number for the SrcSpan
. I think this will lead to quadratic runtime in file with a large number of comments. It's probably better to add a dedicated line counter to BlockIter
.
I have added your improvements wrt multi-line CPP directives, #enum directives, and disabled regions in floskell-0.11.0
. At this point, I think full hsc2hs support is not viable, but it might be possible to accept and format some additional hsc2hs features.
It seems to me that Floskell supports some basic CPP constructs, but is still missing full hsc2hs support.
I have already fixed a few of the more trivial issues in my fork but this is still far from complete, and I would like to write some tests prior to submitting a PR for it.
Adding support for
#const
,#enum
and multi-line directives was not too hard - for instance, Floskell now just silently skips over the following:How would you feel about adding an option to disable an entire region? I was using
brittany
before before it became unmaintained and unsupported, and it had a way of doing so by inserting special comments.For instance, we could do something like this:
This is also an example for something that isn't working yet; so far, I only looked at the line-based filter that's called right in the beginning and still need to figure out how to do that
#{type int}
thing.