[WIP] make ASTs cachable

This is only used with FormatterAST, so it could stay here.