mirror of
https://github.com/google/ormolu.git
synced 2024-11-27 13:13:23 +03:00
7268eb1e98
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. |
||
---|---|---|
.. | ||
declaration | ||
import | ||
module-header | ||
other |