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

Unified Diff: lib/src/span_scanner.dart

Issue 2039163002: Add SpanScanner.within(). (Closed) Base URL: git@github.com:dart-lang/string_scanner@master
Patch Set: Code review changes Created 4 years, 6 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 | « lib/src/relative_span_scanner.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/span_scanner.dart
diff --git a/lib/src/span_scanner.dart b/lib/src/span_scanner.dart
index dd16e47cf06c39f3233f1c11e4412bca96954844..dd7f0e4f2e261b99b5265c161bdfa8e6e94081ff 100644
--- a/lib/src/span_scanner.dart
+++ b/lib/src/span_scanner.dart
@@ -7,6 +7,7 @@ import 'package:source_span/source_span.dart';
import 'eager_span_scanner.dart';
import 'exception.dart';
import 'line_scanner.dart';
+import 'relative_span_scanner.dart';
import 'string_scanner.dart';
import 'utils.dart';
@@ -69,6 +70,14 @@ class SpanScanner extends StringScanner implements LineScanner {
factory SpanScanner.eager(String string, {sourceUrl, int position}) =
EagerSpanScanner;
+ /// Creates a new [SpanScanner] that scans within [span].
+ ///
+ /// This scans through [span.text], but emits new spans from [span.file] in
+ /// their appropriate relative positions. The [string] field contains only
+ /// [span.text], and [position], [line], and [column] are all relative to the
+ /// span.
+ factory SpanScanner.within(FileSpan span) = RelativeSpanScanner;
+
/// Creates a [FileSpan] representing the source range between [startState]
/// and the current position.
FileSpan spanFrom(LineScannerState startState, [LineScannerState endState]) {
« no previous file with comments | « lib/src/relative_span_scanner.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698