Skip to content

Commit 0676529

Browse files
committed
Merge branch 'main' of https://github.com/sass/dart-sass into feature.package-importer
2 parents e5f795a + 4daf0b4 commit 0676529

30 files changed

+158
-131
lines changed

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 1.69.6
2+
3+
* Produce better output for numbers with complex units in `meta.inspect()` and
4+
debugging messages.
5+
6+
* When generating CSS error messages to display in-browser, escape all code
7+
points that aren't in the US-ASCII region. Previously only code points U+0100
8+
LATIN CAPITAL LETTER A WITH MACRON were escaped.
9+
10+
### JS API
11+
12+
* Fix a bug where certain exceptions could produce `SourceSpan`s that didn't
13+
follow the documented `SourceSpan` API.
14+
115
## 1.69.5
216

317
### JS API

lib/src/ast/sass/statement/function_rule.dart

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import 'package:source_span/source_span.dart';
66

77
import '../../../util/span.dart';
88
import '../../../visitor/interface/statement.dart';
9-
import '../argument_declaration.dart';
109
import '../declaration.dart';
11-
import '../statement.dart';
1210
import 'callable_declaration.dart';
13-
import 'silent_comment.dart';
1411

1512
/// A function declaration.
1613
///
@@ -21,10 +18,8 @@ final class FunctionRule extends CallableDeclaration
2118
implements SassDeclaration {
2219
FileSpan get nameSpan => span.withoutInitialAtRule().initialIdentifier();
2320

24-
FunctionRule(String name, ArgumentDeclaration arguments,
25-
Iterable<Statement> children, FileSpan span,
26-
{SilentComment? comment})
27-
: super(name, arguments, children, span, comment: comment);
21+
FunctionRule(super.name, super.arguments, super.children, super.span,
22+
{super.comment});
2823

2924
T accept<T>(StatementVisitor<T> visitor) => visitor.visitFunctionRule(this);
3025

lib/src/ast/sass/statement/if_rule.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ final class IfClause extends IfRuleClause {
9494
///
9595
/// {@category AST}
9696
final class ElseClause extends IfRuleClause {
97-
ElseClause(Iterable<Statement> children) : super(children);
97+
ElseClause(super.children);
9898

9999
String toString() => "@else {${children.join(' ')}}";
100100
}

lib/src/ast/sass/statement/mixin_rule.dart

+2-7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ import 'package:source_span/source_span.dart';
77
import '../../../util/span.dart';
88
import '../../../visitor/interface/statement.dart';
99
import '../../../visitor/statement_search.dart';
10-
import '../argument_declaration.dart';
1110
import '../declaration.dart';
12-
import '../statement.dart';
1311
import 'callable_declaration.dart';
1412
import 'content_rule.dart';
15-
import 'silent_comment.dart';
1613

1714
/// A mixin declaration.
1815
///
@@ -31,10 +28,8 @@ final class MixinRule extends CallableDeclaration implements SassDeclaration {
3128
return startSpan.initialIdentifier();
3229
}
3330

34-
MixinRule(String name, ArgumentDeclaration arguments,
35-
Iterable<Statement> children, FileSpan span,
36-
{SilentComment? comment})
37-
: super(name, arguments, children, span, comment: comment);
31+
MixinRule(super.name, super.arguments, super.children, super.span,
32+
{super.comment});
3833

3934
T accept<T>(StatementVisitor<T> visitor) => visitor.visitMixinRule(this);
4035

lib/src/ast/selector/complex.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ final class ComplexSelector extends Selector {
7070
}
7171

7272
ComplexSelector(Iterable<CssValue<Combinator>> leadingCombinators,
73-
Iterable<ComplexSelectorComponent> components, FileSpan span,
73+
Iterable<ComplexSelectorComponent> components, super.span,
7474
{this.lineBreak = false})
7575
: leadingCombinators = List.unmodifiable(leadingCombinators),
76-
components = List.unmodifiable(components),
77-
super(span) {
76+
components = List.unmodifiable(components) {
7877
if (this.leadingCombinators.isEmpty && this.components.isEmpty) {
7978
throw ArgumentError(
8079
"leadingCombinators and components may not both be empty.");

lib/src/ast/selector/compound.dart

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// https://opensource.org/licenses/MIT.
44

55
import 'package:meta/meta.dart';
6-
import 'package:source_span/source_span.dart';
76

87
import '../../extend/functions.dart';
98
import '../../logger.dart';
@@ -43,9 +42,8 @@ final class CompoundSelector extends Selector {
4342
SimpleSelector? get singleSimple =>
4443
components.length == 1 ? components.first : null;
4544

46-
CompoundSelector(Iterable<SimpleSelector> components, FileSpan span)
47-
: components = List.unmodifiable(components),
48-
super(span) {
45+
CompoundSelector(Iterable<SimpleSelector> components, super.span)
46+
: components = List.unmodifiable(components) {
4947
if (this.components.isEmpty) {
5048
throw ArgumentError("components may not be empty.");
5149
}

lib/src/ast/selector/list.dart

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// https://opensource.org/licenses/MIT.
44

55
import 'package:meta/meta.dart';
6-
import 'package:source_span/source_span.dart';
76

87
import '../../exception.dart';
98
import '../../extend/functions.dart';
@@ -49,9 +48,8 @@ final class SelectorList extends Selector {
4948
}), ListSeparator.comma);
5049
}
5150

52-
SelectorList(Iterable<ComplexSelector> components, FileSpan span)
53-
: components = List.unmodifiable(components),
54-
super(span) {
51+
SelectorList(Iterable<ComplexSelector> components, super.span)
52+
: components = List.unmodifiable(components) {
5553
if (this.components.isEmpty) {
5654
throw ArgumentError("components may not be empty.");
5755
}

lib/src/ast/selector/parent.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// https://opensource.org/licenses/MIT.
44

55
import 'package:meta/meta.dart';
6-
import 'package:source_span/source_span.dart';
76

87
import '../../visitor/interface/selector.dart';
98
import '../selector.dart';
@@ -22,7 +21,7 @@ final class ParentSelector extends SimpleSelector {
2221
/// indicating that the parent selector will not be modified.
2322
final String? suffix;
2423

25-
ParentSelector(FileSpan span, {this.suffix}) : super(span);
24+
ParentSelector(super.span, {this.suffix});
2625

2726
T accept<T>(SelectorVisitor<T> visitor) => visitor.visitParentSelector(this);
2827

lib/src/ast/selector/simple.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// https://opensource.org/licenses/MIT.
44

55
import 'package:meta/meta.dart';
6-
import 'package:source_span/source_span.dart';
76

87
import '../../exception.dart';
98
import '../../logger.dart';
@@ -35,7 +34,7 @@ abstract base class SimpleSelector extends Selector {
3534
/// sequence will contain 1000 simple selectors.
3635
int get specificity => 1000;
3736

38-
SimpleSelector(FileSpan span) : super(span);
37+
SimpleSelector(super.span);
3938

4039
/// Parses a simple selector from [contents].
4140
///

lib/src/ast/selector/universal.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// https://opensource.org/licenses/MIT.
44

55
import 'package:meta/meta.dart';
6-
import 'package:source_span/source_span.dart';
76

87
import '../../extend/functions.dart';
98
import '../../visitor/interface/selector.dart';
@@ -23,7 +22,7 @@ final class UniversalSelector extends SimpleSelector {
2322

2423
int get specificity => 0;
2524

26-
UniversalSelector(FileSpan span, {this.namespace}) : super(span);
25+
UniversalSelector(super.span, {this.namespace});
2726

2827
T accept<T>(SelectorVisitor<T> visitor) =>
2928
visitor.visitUniversalSelector(this);

lib/src/configuration.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ final class ExplicitConfiguration extends Configuration {
119119

120120
/// Creates a base [ExplicitConfiguration] with a [values] map and a
121121
/// [nodeWithSpan].
122-
ExplicitConfiguration(Map<String, ConfiguredValue> values, this.nodeWithSpan)
123-
: super.implicit(values);
122+
ExplicitConfiguration(super.values, this.nodeWithSpan) : super.implicit();
124123

125124
/// Creates an [ExplicitConfiguration] with a [values] map, a [nodeWithSpan]
126125
/// and if this is a copy a reference to the [_originalConfiguration].

lib/src/embedded/importer/file.dart

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// https://opensource.org/licenses/MIT.
44

55
import '../../importer.dart';
6-
import '../compilation_dispatcher.dart';
76
import '../embedded_sass.pb.dart' hide SourceSpan;
87
import 'base.dart';
98

@@ -13,8 +12,7 @@ final class FileImporter extends ImporterBase {
1312
/// The host-provided ID of the importer to invoke.
1413
final int _importerId;
1514

16-
FileImporter(CompilationDispatcher dispatcher, this._importerId)
17-
: super(dispatcher);
15+
FileImporter(super.dispatcher, this._importerId);
1816

1917
Uri? canonicalize(Uri url) {
2018
if (url.scheme == 'file') return FilesystemImporter.cwd.canonicalize(url);

lib/src/embedded/importer/host.dart

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import '../../exception.dart';
66
import '../../importer.dart';
77
import '../../importer/utils.dart';
88
import '../../util/span.dart';
9-
import '../compilation_dispatcher.dart';
109
import '../embedded_sass.pb.dart' hide SourceSpan;
1110
import '../utils.dart';
1211
import 'base.dart';
@@ -20,10 +19,9 @@ final class HostImporter extends ImporterBase {
2019
/// [canonicalize].
2120
final Set<String> _nonCanonicalSchemes;
2221

23-
HostImporter(CompilationDispatcher dispatcher, this._importerId,
24-
Iterable<String> nonCanonicalSchemes)
25-
: _nonCanonicalSchemes = Set.unmodifiable(nonCanonicalSchemes),
26-
super(dispatcher) {
22+
HostImporter(
23+
super.dispatcher, this._importerId, Iterable<String> nonCanonicalSchemes)
24+
: _nonCanonicalSchemes = Set.unmodifiable(nonCanonicalSchemes) {
2725
for (var scheme in _nonCanonicalSchemes) {
2826
if (isValidUrlScheme(scheme)) continue;
2927
throw SassException(

lib/src/exception.dart

+10-15
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ class SassException extends SourceSpanException {
2828
/// compilation, before it failed.
2929
final Set<Uri> loadedUrls;
3030

31-
SassException(String message, FileSpan span, [Iterable<Uri>? loadedUrls])
31+
SassException(super.message, FileSpan super.span, [Iterable<Uri>? loadedUrls])
3232
: loadedUrls =
33-
loadedUrls == null ? const {} : Set.unmodifiable(loadedUrls),
34-
super(message, span);
33+
loadedUrls == null ? const {} : Set.unmodifiable(loadedUrls);
3534

3635
/// Converts this to a [MultiSpanSassException] with the additional [span] and
3736
/// [label].
@@ -83,12 +82,12 @@ class SassException extends SourceSpanException {
8382
.replaceAll("\r\n", "\n");
8483
term_glyph.ascii = wasAscii;
8584

86-
// For the string comment, render all non-ASCII characters as escape
85+
// For the string comment, render all non-US-ASCII characters as escape
8786
// sequences so that they'll show up even if the HTTP headers are set
8887
// incorrectly.
8988
var stringMessage = StringBuffer();
9089
for (var rune in SassString(toString(color: false)).toString().runes) {
91-
if (rune > 0xFF) {
90+
if (rune > 0x7F) {
9291
stringMessage
9392
..writeCharCode($backslash)
9493
..write(rune.toRadixString(16))
@@ -224,9 +223,7 @@ class SassFormatException extends SassException
224223
SassFormatException withLoadedUrls(Iterable<Uri> loadedUrls) =>
225224
SassFormatException(message, span, loadedUrls);
226225

227-
SassFormatException(String message, FileSpan span,
228-
[Iterable<Uri>? loadedUrls])
229-
: super(message, span, loadedUrls);
226+
SassFormatException(super.message, super.span, [super.loadedUrls]);
230227
}
231228

232229
/// A [SassFormatException] that's also a [MultiSpanFormatException].
@@ -248,10 +245,9 @@ class MultiSpanSassFormatException extends MultiSpanSassException
248245
MultiSpanSassFormatException(
249246
message, span, primaryLabel, secondarySpans, loadedUrls);
250247

251-
MultiSpanSassFormatException(String message, FileSpan span,
252-
String primaryLabel, Map<FileSpan, String> secondarySpans,
253-
[Iterable<Uri>? loadedUrls])
254-
: super(message, span, primaryLabel, secondarySpans, loadedUrls);
248+
MultiSpanSassFormatException(
249+
super.message, super.span, super.primaryLabel, super.secondarySpans,
250+
[super.loadedUrls]);
255251
}
256252

257253
/// An exception thrown by SassScript.
@@ -287,9 +283,8 @@ class MultiSpanSassScriptException extends SassScriptException {
287283
final Map<FileSpan, String> secondarySpans;
288284

289285
MultiSpanSassScriptException(
290-
String message, this.primaryLabel, Map<FileSpan, String> secondarySpans)
291-
: secondarySpans = Map.unmodifiable(secondarySpans),
292-
super(message);
286+
super.message, this.primaryLabel, Map<FileSpan, String> secondarySpans)
287+
: secondarySpans = Map.unmodifiable(secondarySpans);
293288

294289
/// Converts this to a [SassException] with the given primary [span].
295290
MultiSpanSassException withSpan(FileSpan span) =>

lib/src/extend/functions.dart

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/// aren't instance methods on other objects because their APIs aren't a good
1010
/// fit—usually because they deal with raw component lists rather than selector
1111
/// classes, to reduce allocations.
12+
library;
1213

1314
import 'dart:collection';
1415

lib/src/js/source_span.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:source_span/source_span.dart';
66

7+
import '../util/lazy_file_span.dart';
78
import '../util/multi_span.dart';
89
import '../util/nullable.dart';
910
import 'reflection.dart';
@@ -14,8 +15,9 @@ import 'utils.dart';
1415
void updateSourceSpanPrototype() {
1516
var span = SourceFile.fromString('').span(0);
1617
var multiSpan = MultiSpan(span, '', {});
18+
var lazySpan = LazyFileSpan(() => span);
1719

18-
for (var item in [span, multiSpan]) {
20+
for (var item in [span, multiSpan, lazySpan]) {
1921
getJSClass(item).defineGetters({
2022
'start': (FileSpan span) => span.start,
2123
'end': (FileSpan span) => span.end,

lib/src/parse/at_root_query.dart

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
import 'package:charcode/charcode.dart';
66

77
import '../ast/sass.dart';
8-
import '../interpolation_map.dart';
9-
import '../logger.dart';
108
import 'parser.dart';
119

1210
/// A parser for `@at-root` queries.
1311
class AtRootQueryParser extends Parser {
14-
AtRootQueryParser(String contents,
15-
{Object? url, Logger? logger, InterpolationMap? interpolationMap})
16-
: super(contents,
17-
url: url, logger: logger, interpolationMap: interpolationMap);
12+
AtRootQueryParser(super.contents,
13+
{super.url, super.logger, super.interpolationMap});
1814

1915
AtRootQuery parse() {
2016
return wrapSpanFormatException(() {

lib/src/parse/css.dart

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:string_scanner/string_scanner.dart';
77

88
import '../ast/sass.dart';
99
import '../functions.dart';
10-
import '../logger.dart';
1110
import 'scss.dart';
1211

1312
/// The set of all function names disallowed in plain CSS.
@@ -31,8 +30,7 @@ final _disallowedFunctionNames =
3130
class CssParser extends ScssParser {
3231
bool get plainCss => true;
3332

34-
CssParser(String contents, {Object? url, Logger? logger})
35-
: super(contents, url: url, logger: logger);
33+
CssParser(super.contents, {super.url, super.logger});
3634

3735
void silentComment() {
3836
var start = scanner.state;

lib/src/parse/keyframe_selector.dart

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44

55
import 'package:charcode/charcode.dart';
66

7-
import '../interpolation_map.dart';
8-
import '../logger.dart';
97
import '../util/character.dart';
108
import 'parser.dart';
119

1210
/// A parser for `@keyframes` block selectors.
1311
class KeyframeSelectorParser extends Parser {
14-
KeyframeSelectorParser(String contents,
15-
{Object? url, Logger? logger, InterpolationMap? interpolationMap})
16-
: super(contents,
17-
url: url, logger: logger, interpolationMap: interpolationMap);
12+
KeyframeSelectorParser(super.contents,
13+
{super.url, super.logger, super.interpolationMap});
1814

1915
List<String> parse() {
2016
return wrapSpanFormatException(() {

0 commit comments

Comments
 (0)