[analysis_server] Support formatter page width from analysis_options in legacy protocol

This adds the same support previously added to LSP to the legacy protocol.

As with LSP, the value in analysis_options overrides the explicit argument (since the expectation is that the user has not specifically chosen this value for this file, but rather as a default for the project/globally).

See https://github.com/dart-lang/sdk/issues/56864


[analyzer] Add support for "formatter" in analysis_options + use page_width in LSP

This adds support for validation + completion for `formatter/page_width` in analysis_options, and uses this value in preference to the client-supplied value in the LSP server.

It does not yet add support for the legacy protocol, and there are a few questions in https://github.com/dart-lang/sdk/issues/56864#issuecomment-2399289974.

See https://github.com/dart-lang/sdk/issues/56864

Change-Id: Ic2be00087f78eb62c409dbc8f558d2f24b521f78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Danny Tuppeny
2024-10-08 17:31:46 +00:00
committed by Commit Queue
parent 262b759e06
commit 75d15bbfa3
9 changed files with 80 additions and 10 deletions
@@ -511,7 +511,8 @@ public interface AnalysisServer {
* @param file The file containing the code to be formatted.
* @param selectionOffset The offset of the current selection in the file.
* @param selectionLength The length of the current selection in the file.
* @param lineLength The line length to be used by the formatter.
* @param lineLength The line length to be used by the formatter. This value is ignored if a
* formatter.page_width has been configured in the relevant analysis_options.yaml file.
*/
public void edit_format(String file, int selectionOffset, int selectionLength, int lineLength, FormatConsumer consumer);