Files
sdk/pkg/analysis_server/test/services/correction
Sam Rawlins a8a42cffd2 Simplify some CorrectionUtils code
The big one is `getIndent`, which I think can be simpler, and also used a handwritten implementation of `String.operator *`. It turns out:

* > 90% of calls to `getIndent` were `getIndent(1)`, which can be
  replaced with a constant `'  '`.
* Then 4 calls to `getIndent` were `getIndent(2)`, which can be replaced
  with a constant `'  ' + '  '`.
* Then one last call, in CorrectionUtils itself, used a variable number
  of indents which can be replaced with `'  ' * n`. This is in the
  `indentRight` function.

Also:

* Privatize `getInsertionLocationTop`, `isClassWithEmptyBody`, `isJustWhitespaceOrComment`, `skipEmptyLinesLeft`
* Rewrite CorrectionUtils.findSimplePrintInvocation as an extension
  method on AstNode; does not need the `_buffer`.

Change-Id: I15c19b8c0cc354adcd4ffea5803b3a182cf28336
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-03-19 17:05:49 +00:00
..