The whole Formatter architecture is probably incredibly powerful, but it is near impossible to understand it, and it doesn't behave at all as I expect, and the result seems absolutely random.
I am trying to create a language plugin for "Pony", but I am stuck in the simplest of indentation problem.
1. Since I eventually want to support the spacing settings between operators, parenthesis, assignment and so on, the Block structure mimics the AST all the way down.
2. The PsiViewer shows me that the blocks are built correctly, and the inspection is great.
3. When it comes to indentation, what should most block do? Return null? Return Indentation.getNoneIndent()? What does "Normal Indent" really mean?
4. What about whitespace? I have PsiWhiteSpace in the AST, but I think I saw "improvement" by dropping that from formatting blocks, but not sure, because every time I try anything, I don't get result remotely to what I expect. (Added issue is that class reloading via debugger, is sometimes ok, but other times something is cached somewhere and restarting the session is needed. And since I now have noticed that, I must assume all previous tests are invalid, and all future tests must restart session every time, slowing me down incredibly)
It is hard to blame documentation, since too much information is also a problem. But I think a better description of the whole mental model is needed, and how that ties back into the Formatter.getInstance().createFormattingModelForPsiFile(file, rootBlock, settings); model. Pony Language Psi tree ends up being very deep, as "control blocks" (if/for/repeat/..) are expressions and can be nested arbitrarily in such, so if I don't get the mental model of what is, it is completely impossible to grok what should be used where, why and the result should be.
Sorry, to let my frustration shine through....
Plugin is on GitHub at https://github.com/niclash/pony-idea-plugin, and working code to try on is at https://github.com/niclash/pink2web/blob/master/main.pony