Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit all warnings in the evaluator #2396

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code review + make this a -dev release
  • Loading branch information
jathak committed Oct 18, 2024
commit 7a9efb411aecbc44d5040e1df610058bf0ce1087
2 changes: 1 addition & 1 deletion lib/src/ast/sass/expression.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ abstract class Expression implements SassNode {
///
/// Throws a [SassFormatException] if parsing fails.
factory Expression.parse(String contents, {Object? url}) =>
ScssParser(contents, url: url).parseExpression().node;
ScssParser(contents, url: url).parseExpression().$1;
}
2 changes: 1 addition & 1 deletion lib/src/ast/sass/statement/use_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class UseRule extends Statement implements SassDependency {
/// @nodoc
@internal
factory UseRule.parse(String contents, {Object? url}) =>
ScssParser(contents, url: url).parseUseRule().node;
ScssParser(contents, url: url).parseUseRule().$1;

T accept<T>(StatementVisitor<T> visitor) => visitor.visitUseRule(this);

Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/sass/statement/variable_declaration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final class VariableDeclaration extends Statement implements SassDeclaration {
/// @nodoc
@internal
factory VariableDeclaration.parse(String contents, {Object? url}) =>
ScssParser(contents, url: url).parseVariableDeclaration().node;
ScssParser(contents, url: url).parseVariableDeclaration().$1;

T accept<T>(StatementVisitor<T> visitor) =>
visitor.visitVariableDeclaration(this);
Expand Down
3 changes: 3 additions & 0 deletions lib/src/async_import_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ final class AsyncImportCache {

if (result == null) return (null, cacheable);

// Relative canonical URLs (empty scheme) should throw an error starting in
// Dart Sass 2.0.0, but for now, they only emit a deprecation warning in
// the evaluator.
if (result.scheme != '' &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment that this should be an error but currently produces a deprecation warning in the evaluator

await importer.isNonCanonicalScheme(result.scheme)) {
throw "Importer $importer canonicalized $url to $result, which uses a "
Expand Down
6 changes: 3 additions & 3 deletions lib/src/executable/repl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ Future<void> repl(ExecutableOptions options) async {
if (line.trim().isEmpty) continue;
try {
if (line.startsWith("@")) {
var (:node, :warnings) = ScssParser(line).parseUseRule();
var (node, warnings) = ScssParser(line).parseUseRule();
warnings.forEach(warn);
evaluator.use(node);
continue;
}

if (Parser.isVariableDeclarationLike(line)) {
var (:node, :warnings) = ScssParser(line).parseVariableDeclaration();
var (node, warnings) = ScssParser(line).parseVariableDeclaration();
warnings.forEach(warn);
evaluator.setVariable(node);
print(evaluator.evaluate(VariableExpression(node.name, node.span,
namespace: node.namespace)));
} else {
var (:node, :warnings) = ScssParser(line).parseExpression();
var (node, warnings) = ScssParser(line).parseExpression();
warnings.forEach(warn);
print(evaluator.evaluate(node));
}
Expand Down
23 changes: 11 additions & 12 deletions lib/src/parse/stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,30 @@ abstract class StylesheetParser extends Parser {
return arguments;
});

({Expression node, List<ParseTimeWarning> warnings}) parseExpression() =>
(node: _parseSingleProduction(_expression), warnings: warnings);
(Expression, List<ParseTimeWarning>) parseExpression() =>
(_parseSingleProduction(_expression), warnings);

SassNumber parseNumber() {
var expression = _parseSingleProduction(_number);
return SassNumber(expression.value, expression.unit);
}

({VariableDeclaration node, List<ParseTimeWarning> warnings})
parseVariableDeclaration() => (
node: _parseSingleProduction(() => lookingAtIdentifier()
? _variableDeclarationWithNamespace()
: variableDeclarationWithoutNamespace()),
warnings: warnings
);
(VariableDeclaration, List<ParseTimeWarning>) parseVariableDeclaration() => (
_parseSingleProduction(() => lookingAtIdentifier()
? _variableDeclarationWithNamespace()
: variableDeclarationWithoutNamespace()),
warnings
);

({UseRule node, List<ParseTimeWarning> warnings}) parseUseRule() => (
node: _parseSingleProduction(() {
(UseRule, List<ParseTimeWarning>) parseUseRule() => (
_parseSingleProduction(() {
var start = scanner.state;
scanner.expectChar($at, name: "@-rule");
expectIdentifier("use");
whitespace();
return _useRule(start);
}),
warnings: warnings
warnings
);

/// Parses and returns [production] as the entire contents of [scanner].
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.80.3
version: 1.80.3-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down
Loading