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

Unified Diff: pkg/analysis_server/lib/src/provisional/edit/utilities/change_builder_core.dart

Issue 2856233003: Change the ChangeBuilder API to use SourceRange (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/utilities/change_builder_core.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/provisional/edit/utilities/change_builder_core.dart
diff --git a/pkg/analysis_server/lib/src/provisional/edit/utilities/change_builder_core.dart b/pkg/analysis_server/lib/src/provisional/edit/utilities/change_builder_core.dart
index 47f66bb963d89b8d2806eb6f55363eb2d8febb89..59aad98d0afc50b9c68b2c57e699cb22f031a85b 100644
--- a/pkg/analysis_server/lib/src/provisional/edit/utilities/change_builder_core.dart
+++ b/pkg/analysis_server/lib/src/provisional/edit/utilities/change_builder_core.dart
@@ -6,6 +6,7 @@ import 'dart:async';
import 'package:analysis_server/protocol/protocol_generated.dart';
import 'package:analysis_server/src/utilities/change_builder_core.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:meta/meta.dart';
/**
@@ -81,36 +82,37 @@ abstract class EditBuilder {
*/
abstract class FileEditBuilder {
/**
- * Add a deletion of text starting at the given [offset] and continuing for
- * the given [length].
+ * Add a deletion of text specified by the given [range]. The [range] is
+ * relative to the original source. This is fully equivalent to
+ *
+ * addSimpleReplacement(range, '');
*/
- void addDeletion(int offset, int length);
+ void addDeletion(SourceRange range);
/**
* Add an insertion of text at the given [offset]. The [offset] is relative to
* the original source. The [buildEdit] function is used to write the text to
* be inserted. This is fully equivalent to
*
- * addReplacement(offset, 0, buildEdit);
+ * addReplacement(new SourceRange(offset, 0), buildEdit);
*/
void addInsertion(int offset, void buildEdit(EditBuilder builder));
/**
- * Add the region of text starting at the given [offset] and continuing for
- * the given [length] to the linked edit group with the given [groupName].
- * The [offset] is relative to the original source. This is typically used to
- * include pre-existing regions of text in a group.
+ * Add the region of text specified by the given [range] to the linked edit
+ * group with the given [groupName]. The [range] is relative to the original
+ * source. This is typically used to include pre-existing regions of text in a
+ * group. If the region to be included is part of newly generated text, then
+ * the method [EditBuilder.addLinkedEdit] should be used instead.
*/
- void addLinkedPosition(int offset, int length, String groupName);
+ void addLinkedPosition(SourceRange range, String groupName);
/**
- * Add a replacement of text starting at the given [offset] and continuing for
- * the given [length]. The [offset] is relative to the original source. The
- * [buildEdit] function is used to write the text that will replace the
- * specified region.
+ * Add a replacement of text specified by the given [range]. The [range] is
+ * relative to the original source. The [buildEdit] function is used to write
+ * the text that will replace the specified region.
*/
- void addReplacement(
- int offset, int length, void buildEdit(EditBuilder builder));
+ void addReplacement(SourceRange range, void buildEdit(EditBuilder builder));
/**
* Add an insertion of the given [text] at the given [offset]. The [offset] is
@@ -123,16 +125,15 @@ abstract class FileEditBuilder {
void addSimpleInsertion(int offset, String text);
/**
- * Add a replacement of the text starting at the given [offset] and continuing
- * for the given [length]. The [offset] is relative to the original source.
- * The original content will be replaced by the given [text]. This is fully
- * equivalent to
+ * Add a replacement of the text specified by the given [range]. The [range]
+ * is relative to the original source. The original content will be replaced
+ * by the given [text]. This is fully equivalent to
*
* addReplacement(offset, length, (EditBuilder builder) {
* builder.write(text);
* });
*/
- void addSimpleReplacement(int offset, int length, String text);
+ void addSimpleReplacement(SourceRange range, String text);
}
/**
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/utilities/change_builder_core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698