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

Unified Diff: pkg/analyzer_plugin/lib/utilities/range_factory.dart

Issue 2869083002: Convert server to use RangeFactory (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
Index: pkg/analyzer_plugin/lib/utilities/range_factory.dart
diff --git a/pkg/analyzer_plugin/lib/utilities/range_factory.dart b/pkg/analyzer_plugin/lib/utilities/range_factory.dart
index a875abf3f09f2d0c34b734ead7ddaf9024b68e70..feb3b7c416141ca80e2d31bd0e6263fe4bfbf06b 100644
--- a/pkg/analyzer_plugin/lib/utilities/range_factory.dart
+++ b/pkg/analyzer_plugin/lib/utilities/range_factory.dart
@@ -81,6 +81,34 @@ class RangeFactory {
}
/**
+ * Return a source range whose length is the same as the given [range], but
+ * whose offset is the offset of the given [range] with [offset] added to it.
+ */
+ SourceRange offsetBy(SourceRange range, int offset) {
+ return new SourceRange(range.offset + offset, range.length);
+ }
+
+ /**
+ * Return a source range that starts at the given [offset] and ends at the
+ * given [endIndex].
+ */
+ SourceRange offsetEndIndex(int offset, int endIndex) {
scheglov 2017/05/09 16:04:14 Drop "Index" for consistency with other methods, l
Brian Wilkerson 2017/05/09 16:51:56 So far, "end" means that 'end' will be invoked on
+ int length = endIndex - offset;
+ return new SourceRange(offset, length);
+ }
+
+// /**
+// * Return a source range that starts at the start of [leftEntity] and ends at
+// * the given [endIndex].
+// */
+// SourceRange startEndIndex(
+// SyntacticEntity leftEntity, int endIndex) {
+// int offset = leftEntity.offset;
+// int length = endIndex - offset;
+// return new SourceRange(offset, length);
+// }
+
+ /**
* Return a source range that starts at the start of [leftEntity] and ends at
* the end of [rightEntity].
*/

Powered by Google App Engine
This is Rietveld 408576698