The analysis server code for running the formatter calls AnalysisDriver.getResolvedUnit, which means that it won't be able to format the file until it's fully resolved it. It would be nice if it could use an analysis API that didn't require resolution, since that could in principle make formatting much faster.
The reason it currently uses AnalysisDriver.getResolvedUnit is because it needs unit.libraryElement2.effectiveLanguageVersion in order to tell the formatter which language version to use for formatting. But this feels like overkill; it should be possible to figure out the langauge version based on the unresolved AST and some information from the context.
See discussion here: https://dart-review.googlesource.com/c/sdk/+/391840/comment/5e5314af_b5c7db9a/