Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: pkg/analysis_server/test/integration/integration_test_methods.dart

Issue 809213003: Add format API (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add handler hook and missed classes Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/integration/integration_test_methods.dart
diff --git a/pkg/analysis_server/test/integration/integration_test_methods.dart b/pkg/analysis_server/test/integration/integration_test_methods.dart
index 6f3bb56589335dcc92ddd37253340133cf20a678..1d91b21f65fa5f337a4cac0e91ba4f88060823e8 100644
--- a/pkg/analysis_server/test/integration/integration_test_methods.dart
+++ b/pkg/analysis_server/test/integration/integration_test_methods.dart
@@ -1012,6 +1012,51 @@ abstract class IntegrationTestMixin {
StreamController<SearchResultsParams> _onSearchResults;
/**
+ * Format the contents of a single file. The currently selected region of
+ * text is passed in so that the selection can be preserved across the
+ * formatting operation. The updated selection will be as close to matching
+ * the original as possible, but whitespace at the beginning or end of the
+ * selected region will be ignored.
+ *
+ * Parameters
+ *
+ * file ( FilePath )
+ *
+ * The file containing the code to be formatted.
+ *
+ * selectionOffset ( int )
+ *
+ * The offset of the current selection in the file.
+ *
+ * selectionLength ( int )
+ *
+ * The length of the current selection in the file.
+ *
+ * Returns
+ *
+ * edits ( List<SourceEdit> )
+ *
+ * The edit(s) to be applied in order to format the code. The list will be
+ * empty if the code was already formatted (there are no changes).
+ *
+ * selectionOffset ( int )
+ *
+ * The offset of the selection after formatting the code.
+ *
+ * selectionLength ( int )
+ *
+ * The length of the selection after formatting the code.
+ */
+ Future<EditFormatResult> sendEditFormat(String file, int selectionOffset, int selectionLength) {
+ var params = new EditFormatParams(file, selectionOffset, selectionLength).toJson();
+ return server.send("edit.format", params)
+ .then((result) {
+ ResponseDecoder decoder = new ResponseDecoder(null);
+ return new EditFormatResult.fromJson(decoder, 'result', result);
+ });
+ }
+
+ /**
* Return the set of assists that are available at the given location. An
* assist is distinguished from a refactoring primarily by the fact that it
* affects a single file and does not require user input in order to be
« no previous file with comments | « pkg/analysis_server/lib/src/generated_protocol.dart ('k') | pkg/analysis_server/test/integration/protocol_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698