Skip to content

Commit

Permalink
Parse Deprecation.forVersion on compiler side
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed May 29, 2024
1 parent 1073c7b commit 53e6fe7
Showing 1 changed file with 26 additions and 12 deletions.
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

0 comments on commit 53e6fe7

Please sign in to comment.