From ab48b7104d268189f28c78c136dbceae4159975d Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 5 Jun 2017 12:35:30 -0700 Subject: [PATCH] Upgrade to the latest source_span. (#151) --- lib/src/io/node.dart | 2 +- lib/src/io/vm.dart | 2 +- lib/src/visitor/perform.dart | 5 +++-- pubspec.yaml | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/io/node.dart b/lib/src/io/node.dart index 6eb6635f..5e206908 100644 --- a/lib/src/io/node.dart +++ b/lib/src/io/node.dart @@ -60,7 +60,7 @@ String readFile(String path) { var contents = _readFile(path, 'utf8') as String; if (!contents.contains("�")) return contents; - var sourceFile = new SourceFile(contents, url: p.toUri(path)); + var sourceFile = new SourceFile.fromString(contents, url: p.toUri(path)); for (var i = 0; i < contents.length; i++) { if (contents.codeUnitAt(i) != 0xFFFD) continue; throw new SassException( diff --git a/lib/src/io/vm.dart b/lib/src/io/vm.dart index c76a8773..f849d7f7 100644 --- a/lib/src/io/vm.dart +++ b/lib/src/io/vm.dart @@ -23,7 +23,7 @@ String readFile(String path) { return UTF8.decode(bytes); } on FormatException { var decoded = UTF8.decode(bytes, allowMalformed: true); - var sourceFile = new SourceFile(decoded, url: p.toUri(path)); + var sourceFile = new SourceFile.fromString(decoded, url: p.toUri(path)); // TODO(nweiz): Use [FormatException.offset] instead when // dart-lang/sdk#28293 is fixed. diff --git a/lib/src/visitor/perform.dart b/lib/src/visitor/perform.dart index 57c39e81..e6b46a21 100644 --- a/lib/src/visitor/perform.dart +++ b/lib/src/visitor/perform.dart @@ -1643,8 +1643,9 @@ class _PerformVisitor var syntheticFile = span.file .getText(0) .replaceRange(span.start.offset, span.end.offset, errorText); - var syntheticSpan = new SourceFile(syntheticFile, url: span.file.url) - .span(span.start.offset + error.span.start.offset, + var syntheticSpan = + new SourceFile.fromString(syntheticFile, url: span.file.url).span( + span.start.offset + error.span.start.offset, span.start.offset + error.span.end.offset); throw _exception(error.message, syntheticSpan); } diff --git a/pubspec.yaml b/pubspec.yaml index ca94c938..b4d1f770 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: charcode: "^1.1.0" collection: "^1.8.0" path: "^1.0.0" - source_span: "^1.3.0" + source_span: "^1.4.0" string_scanner: ">=0.1.5 <2.0.0" stack_trace: ">=0.9.0 <2.0.0" tuple: "^1.0.0"