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

Parse Deprecation.forVersion on compiler side #2248

Merged
merged 2 commits into from
May 30, 2024
Merged
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
38 changes: 26 additions & 12 deletions lib/src/embedded/compilation_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import 'dart:io';
import 'dart:isolate';
import 'dart:typed_data';

import 'package:collection/collection.dart';
import 'package:native_synchronization/mailbox.dart';
import 'package:path/path.dart' as p;
import 'package:protobuf/protobuf.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:sass/sass.dart' as sass;
import 'package:sass/src/importer/node_package.dart' as npi;

Expand Down Expand Up @@ -125,20 +125,34 @@ final class CompilationDispatcher {
: EmbeddedLogger(this,
color: request.alertColor, ascii: request.alertAscii);

sass.Deprecation? deprecationOrWarn(String id) {
var deprecation = sass.Deprecation.fromId(id);
if (deprecation == null) {
logger.warn('Invalid deprecation "$id".');
}
return deprecation;
Iterable<sass.Deprecation>? parseDeprecationsOrWarn(
Iterable<String> deprecations,
{bool supportVersions = false}) {
return () sync* {
for (var item in deprecations) {
var deprecation = sass.Deprecation.fromId(item);
if (deprecation == null) {
if (supportVersions) {
try {
yield* sass.Deprecation.forVersion(Version.parse(item));
} on FormatException {
logger.warn('Invalid deprecation id or version "$item".');
}
} else {
logger.warn('Invalid deprecation id "$item".');
}
} else {
yield deprecation;
}
}
}();
}

var fatalDeprecations =
request.fatalDeprecation.map(deprecationOrWarn).whereNotNull();
var fatalDeprecations = parseDeprecationsOrWarn(request.fatalDeprecation,
supportVersions: true);
var silenceDeprecations =
request.silenceDeprecation.map(deprecationOrWarn).whereNotNull();
var futureDeprecations =
request.futureDeprecation.map(deprecationOrWarn).whereNotNull();
parseDeprecationsOrWarn(request.silenceDeprecation);
var futureDeprecations = parseDeprecationsOrWarn(request.futureDeprecation);

try {
var importers = request.importers.map((importer) =>
Expand Down
Loading