Index: lib/src/span_with_context.dart |
diff --git a/lib/src/span_with_context.dart b/lib/src/span_with_context.dart |
index edbb8b65ffe278f3084a4b8aa016c5b15df53a41..0012e3f3d706080c479d5d08a1d462441f713083 100644 |
--- a/lib/src/span_with_context.dart |
+++ b/lib/src/span_with_context.dart |
@@ -6,6 +6,7 @@ library source_span.span_with_context; |
import 'location.dart'; |
import 'span.dart'; |
+import 'utils.dart'; |
/// A class that describes a segment of source text with additional context. |
class SourceSpanWithContext extends SourceSpanBase { |
@@ -23,14 +24,12 @@ class SourceSpanWithContext extends SourceSpanBase { |
SourceSpanWithContext( |
SourceLocation start, SourceLocation end, String text, this.context) |
: super(start, end, text) { |
- var index = context.indexOf(text); |
- if (index == -1) { |
+ if (!context.contains(text)) { |
throw new ArgumentError( |
'The context line "$context" must contain "$text".'); |
} |
- var beginningOfLine = context.lastIndexOf('\n', index) + 1; |
- if (start.column != index - beginningOfLine) { |
+ if (findLineStart(context, text, start.column) == null) { |
throw new ArgumentError('The span text "$text" must start at ' |
'column ${start.column + 1} in a line within "$context".'); |
} |