1
1
mirror of https://github.com/google/ormolu.git synced 2024-11-27 13:13:23 +03:00
ormolu/data/examples
Utku Demir 7268eb1e98 Handle operator chains better
I implemented a custom logic where we assign a score to every occurance of
an operator based on their location, and the average of that score determine
the fixity of the operator.

As you can imagine, the solution is a bit brittle; and it is easy to mislead
it if you knowingly craft an input, but it gave acceptable results for every
code snippet I found online. And since it returns the same AST no matter how
we infer the fixities, it is not the end of the world if we infer something
incorrectly.

The code is not really optimised, and I think it has quadratic time
complexity. Notably, we use opTreeLoc function quite often and it traverses
the whole tree every time. Memoizing that on the OpBranch constructor would
make formatting files with reeeally long operator chains a lot faster. We
can do this once we decide to optimize for speed.
2019-09-10 18:27:15 +02:00
..
declaration Handle operator chains better 2019-09-10 18:27:15 +02:00
import Change parens style and how separated lists of items are printed 2019-08-04 13:32:06 +02:00
module-header Tweak formatting of warning pragmas 2019-08-09 11:00:06 +02:00
other Better handle multi-line following comments 2019-09-09 11:54:18 +02:00