Skip to content

Commit

Permalink
Include deprecation IDs in deprecation messages (#2475)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Jan 4, 2025
1 parent f5c385d commit 777708c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.83.1-dev

* Include deprecation IDs in deprecation warnings to make it easier to determine
what to pass to `--silence-deprecation` or `--fatal-deprecation`.

## 1.83.0

* Allow trailing commas in *all* argument and parameter lists.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ abstract class Logger {
/// [warn].
@internal
abstract class LoggerWithDeprecationType implements Logger {
const LoggerWithDeprecationType();

/// This forwards all calls to [internalWarn].
///
/// For non-user deprecation warnings, the [warnForDeprecation] extension
Expand Down
15 changes: 10 additions & 5 deletions lib/src/logger/stderr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,33 @@ import 'package:path/path.dart' as p;
import 'package:source_span/source_span.dart';
import 'package:stack_trace/stack_trace.dart';

import '../deprecation.dart';
import '../io.dart';
import '../logger.dart';
import '../utils.dart';

/// A logger that prints warnings to standard error or browser console.
final class StderrLogger implements Logger {
final class StderrLogger extends LoggerWithDeprecationType {
/// Whether to use terminal colors in messages.
final bool color;

const StderrLogger({this.color = false});

void warn(String message,
{FileSpan? span, Trace? trace, bool deprecation = false}) {
void internalWarn(String message,
{FileSpan? span, Trace? trace, Deprecation? deprecation}) {
var result = StringBuffer();
if (color) {
// Bold yellow.
result.write('\u001b[33m\u001b[1m');
if (deprecation) result.write('Deprecation ');
if (deprecation != null) result.write('Deprecation ');
result.write('Warning\u001b[0m');
if (deprecation != null) {
result.write(' [\u001b[34m$deprecation\u001b[0m]');
}
} else {
if (deprecation) result.write('DEPRECATION ');
if (deprecation != null) result.write('DEPRECATION ');
result.write('WARNING');
if (deprecation != null) result.write(' [$deprecation]');
}

if (span == null) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.9-dev

* No user-visible changes.

## 0.4.8

Add support for parsing the `@include` rule.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sass-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sass-parser",
"version": "0.4.8",
"version": "0.4.9-dev",
"description": "A PostCSS-compatible wrapper of the official Sass parser",
"repository": "sass/sass",
"author": "Google Inc.",
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 15.0.1-dev

* No user-visible changes.

## 15.0.0

* Rename `ArgumentInvocation` to `ArgumentList`, `ArgumentDeclaration` to
Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 15.0.0
version: 15.0.1-dev
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: ">=3.3.0 <4.0.0"

dependencies:
sass: 1.83.0
sass: 1.83.1

dev_dependencies:
dartdoc: ^8.0.14
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.83.0
version: 1.83.1-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit 777708c

Please sign in to comment.