@@ -7,8 +7,8 @@ import 'dart:collection';
7
7
import 'package:meta/meta.dart' ;
8
8
import 'package:source_span/source_span.dart' ;
9
9
10
+ import '../../../deprecation.dart' ;
10
11
import '../../../exception.dart' ;
11
- import '../../../logger.dart' ;
12
12
import '../../../parse/css.dart' ;
13
13
import '../../../parse/sass.dart' ;
14
14
import '../../../parse/scss.dart' ;
@@ -46,16 +46,25 @@ final class Stylesheet extends ParentStatement<List<Statement>> {
46
46
List <ForwardRule > get forwards => UnmodifiableListView (_forwards);
47
47
final _forwards = < ForwardRule > [];
48
48
49
+ /// List of warnings discovered while parsing this stylesheet, to be emitted
50
+ /// during evaluation once we have a proper logger to use.
51
+ ///
52
+ /// @nodoc
53
+ @internal
54
+ final List <ParseTimeWarning > parseTimeWarnings;
55
+
49
56
Stylesheet (Iterable <Statement > children, FileSpan span)
50
- : this .internal (children, span);
57
+ : this .internal (children, span, [] );
51
58
52
59
/// A separate internal constructor that allows [plainCss] to be set.
53
60
///
54
61
/// @nodoc
55
62
@internal
56
63
Stylesheet .internal (Iterable <Statement > children, this .span,
64
+ List <ParseTimeWarning > parseTimeWarnings,
57
65
{this .plainCss = false })
58
- : super (List .unmodifiable (children)) {
66
+ : parseTimeWarnings = UnmodifiableListView (parseTimeWarnings),
67
+ super (List .unmodifiable (children)) {
59
68
loop:
60
69
for (var child in this .children) {
61
70
switch (child) {
@@ -81,16 +90,15 @@ final class Stylesheet extends ParentStatement<List<Statement>> {
81
90
/// If passed, [url] is the name of the file from which [contents] comes.
82
91
///
83
92
/// Throws a [SassFormatException] if parsing fails.
84
- factory Stylesheet .parse (String contents, Syntax syntax,
85
- {Object ? url, Logger ? logger}) {
93
+ factory Stylesheet .parse (String contents, Syntax syntax, {Object ? url}) {
86
94
try {
87
95
switch (syntax) {
88
96
case Syntax .sass:
89
- return Stylesheet .parseSass (contents, url: url, logger : logger );
97
+ return Stylesheet .parseSass (contents, url: url);
90
98
case Syntax .scss:
91
- return Stylesheet .parseScss (contents, url: url, logger : logger );
99
+ return Stylesheet .parseScss (contents, url: url);
92
100
case Syntax .css:
93
- return Stylesheet .parseCss (contents, url: url, logger : logger );
101
+ return Stylesheet .parseCss (contents, url: url);
94
102
}
95
103
} on SassException catch (error, stackTrace) {
96
104
var url = error.span.sourceUrl;
@@ -106,28 +114,33 @@ final class Stylesheet extends ParentStatement<List<Statement>> {
106
114
/// If passed, [url] is the name of the file from which [contents] comes.
107
115
///
108
116
/// Throws a [SassFormatException] if parsing fails.
109
- factory Stylesheet .parseSass (String contents,
110
- {Object ? url, Logger ? logger}) =>
111
- SassParser (contents, url: url, logger: logger).parse ();
117
+ factory Stylesheet .parseSass (String contents, {Object ? url}) =>
118
+ SassParser (contents, url: url).parse ();
112
119
113
120
/// Parses an SCSS stylesheet from [contents] .
114
121
///
115
122
/// If passed, [url] is the name of the file from which [contents] comes.
116
123
///
117
124
/// Throws a [SassFormatException] if parsing fails.
118
- factory Stylesheet .parseScss (String contents,
119
- {Object ? url, Logger ? logger}) =>
120
- ScssParser (contents, url: url, logger: logger).parse ();
125
+ factory Stylesheet .parseScss (String contents, {Object ? url}) =>
126
+ ScssParser (contents, url: url).parse ();
121
127
122
128
/// Parses a plain CSS stylesheet from [contents] .
123
129
///
124
130
/// If passed, [url] is the name of the file from which [contents] comes.
125
131
///
126
132
/// Throws a [SassFormatException] if parsing fails.
127
- factory Stylesheet .parseCss (String contents, {Object ? url, Logger ? logger }) =>
128
- CssParser (contents, url: url, logger : logger ).parse ();
133
+ factory Stylesheet .parseCss (String contents, {Object ? url}) =>
134
+ CssParser (contents, url: url).parse ();
129
135
130
136
T accept <T >(StatementVisitor <T > visitor) => visitor.visitStylesheet (this );
131
137
132
138
String toString () => children.join (" " );
133
139
}
140
+
141
+ /// Record type for a warning discovered while parsing a stylesheet.
142
+ typedef ParseTimeWarning = ({
143
+ Deprecation ? deprecation,
144
+ FileSpan span,
145
+ String message
146
+ });
0 commit comments