mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-30 04:39:03 +01:00
Merge pull request #736 from sass/merge-master
Merge master into feature.use
This commit is contained in:
commit
ccec9342a5
@ -3,6 +3,10 @@
|
||||
* Produce better stack traces when importing a file that contains a syntax
|
||||
error.
|
||||
|
||||
* Make deprecation warnings for `!global` variable declarations that create new
|
||||
variables clearer, especially in the case where the `!global` flag is
|
||||
unnecessary because the variables are at the top level of the stylesheet.
|
||||
|
||||
### Dart API
|
||||
|
||||
* Add a `Value.realNull` getter, which returns Dart's `null` if the value is
|
||||
|
@ -114,6 +114,9 @@ class AsyncEnvironment {
|
||||
UserDefinedCallable<AsyncEnvironment> get content => _content;
|
||||
UserDefinedCallable<AsyncEnvironment> _content;
|
||||
|
||||
/// Whether the environment is lexically at the root of the document.
|
||||
bool get atRoot => _variables.length == 1;
|
||||
|
||||
/// Whether the environment is lexically within a mixin.
|
||||
bool get inMixin => _inMixin;
|
||||
var _inMixin = false;
|
||||
@ -454,7 +457,7 @@ class AsyncEnvironment {
|
||||
return;
|
||||
}
|
||||
|
||||
if (global || _variables.length == 1) {
|
||||
if (global || atRoot) {
|
||||
// Don't set the index if there's already a variable with the given name,
|
||||
// since local accesses should still return the local variable.
|
||||
_variableIndices.putIfAbsent(name, () {
|
||||
|
@ -5,7 +5,7 @@
|
||||
// DO NOT EDIT. This file was generated from async_environment.dart.
|
||||
// See tool/grind/synchronize.dart for details.
|
||||
//
|
||||
// Checksum: 1f5c92aead0d5957fb0e502091f18d406701707a
|
||||
// Checksum: fe68ec0b099d3f2992af03dbdaeff0b3e8392808
|
||||
//
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
@ -120,6 +120,9 @@ class Environment {
|
||||
UserDefinedCallable<Environment> get content => _content;
|
||||
UserDefinedCallable<Environment> _content;
|
||||
|
||||
/// Whether the environment is lexically at the root of the document.
|
||||
bool get atRoot => _variables.length == 1;
|
||||
|
||||
/// Whether the environment is lexically within a mixin.
|
||||
bool get inMixin => _inMixin;
|
||||
var _inMixin = false;
|
||||
@ -460,7 +463,7 @@ class Environment {
|
||||
return;
|
||||
}
|
||||
|
||||
if (global || _variables.length == 1) {
|
||||
if (global || atRoot) {
|
||||
// Don't set the index if there's already a variable with the given name,
|
||||
// since local accesses should still return the local variable.
|
||||
_variableIndices.putIfAbsent(name, () {
|
||||
|
@ -352,7 +352,7 @@ class _EvaluateVisitor
|
||||
if (function is SassString) {
|
||||
warn(
|
||||
"Passing a string to call() is deprecated and will be illegal\n"
|
||||
"in Sass 4.0. Use call(get-function($function)) instead.",
|
||||
"in Dart Sass 2.0.0. Use call(get-function($function)) instead.",
|
||||
deprecation: true);
|
||||
|
||||
var expression = FunctionExpression(
|
||||
@ -1533,9 +1533,15 @@ class _EvaluateVisitor
|
||||
|
||||
if (node.isGlobal && !_environment.globalVariableExists(node.name)) {
|
||||
_logger.warn(
|
||||
"As of Dart Sass 2.0.0, !global assignments won't be able to\n"
|
||||
"declare new variables. Consider adding `\$${node.name}: null` at "
|
||||
"the top level.",
|
||||
_environment.atRoot
|
||||
? "As of Dart Sass 2.0.0, !global assignments won't be able to\n"
|
||||
"declare new variables. Since this assignment is at the root "
|
||||
"of the stylesheet,\n"
|
||||
"the !global flag is unnecessary and can safely be removed."
|
||||
: "As of Dart Sass 2.0.0, !global assignments won't be able to\n"
|
||||
"declare new variables. Consider adding `\$${node.name}: "
|
||||
"null` at the root of the\n"
|
||||
"stylesheet.",
|
||||
span: node.span,
|
||||
trace: _stackTrace(node.span),
|
||||
deprecation: true);
|
||||
|
@ -5,7 +5,7 @@
|
||||
// DO NOT EDIT. This file was generated from async_evaluate.dart.
|
||||
// See tool/grind/synchronize.dart for details.
|
||||
//
|
||||
// Checksum: b4dcbae0a682db653ebbc98719e293f6432eb266
|
||||
// Checksum: b5c6cb6023c2cf2735c13f16d340438972117eb7
|
||||
//
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
@ -360,7 +360,7 @@ class _EvaluateVisitor
|
||||
if (function is SassString) {
|
||||
warn(
|
||||
"Passing a string to call() is deprecated and will be illegal\n"
|
||||
"in Sass 4.0. Use call(get-function($function)) instead.",
|
||||
"in Dart Sass 2.0.0. Use call(get-function($function)) instead.",
|
||||
deprecation: true);
|
||||
|
||||
var expression = FunctionExpression(
|
||||
@ -1527,9 +1527,15 @@ class _EvaluateVisitor
|
||||
|
||||
if (node.isGlobal && !_environment.globalVariableExists(node.name)) {
|
||||
_logger.warn(
|
||||
"As of Dart Sass 2.0.0, !global assignments won't be able to\n"
|
||||
"declare new variables. Consider adding `\$${node.name}: null` at "
|
||||
"the top level.",
|
||||
_environment.atRoot
|
||||
? "As of Dart Sass 2.0.0, !global assignments won't be able to\n"
|
||||
"declare new variables. Since this assignment is at the root "
|
||||
"of the stylesheet,\n"
|
||||
"the !global flag is unnecessary and can safely be removed."
|
||||
: "As of Dart Sass 2.0.0, !global assignments won't be able to\n"
|
||||
"declare new variables. Consider adding `\$${node.name}: "
|
||||
"null` at the root of the\n"
|
||||
"stylesheet.",
|
||||
span: node.span,
|
||||
trace: _stackTrace(node.span),
|
||||
deprecation: true);
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: sass
|
||||
version: 1.22.0-dev
|
||||
version: 1.22.0
|
||||
description: A Sass implementation in Dart.
|
||||
author: Dart Team <misc@dartlang.org>
|
||||
homepage: https://github.com/sass/dart-sass
|
||||
@ -31,7 +31,7 @@ dependencies:
|
||||
|
||||
dev_dependencies:
|
||||
archive: ">=1.0.0 <3.0.0"
|
||||
analyzer: ">=0.30.0 <0.37.0"
|
||||
analyzer: ">=0.36.4 <0.37.0"
|
||||
crypto: ">=0.9.2 <3.0.0"
|
||||
dart_style: "^1.2.0"
|
||||
grinder: "^0.8.0"
|
||||
|
@ -5,10 +5,8 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
// See https://groups.google.com/a/dartlang.org/d/msg/misc/bZ0AGuEo41c/u05-1M7yAgAJ.
|
||||
//
|
||||
// ignore: deprecated_member_use
|
||||
import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer/dart/analysis/utilities.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/ast/token.dart';
|
||||
import 'package:analyzer/dart/ast/visitor.dart';
|
||||
@ -45,7 +43,9 @@ final _sharedClasses = const ['EvaluateResult', 'CompileResult'];
|
||||
synchronize() {
|
||||
sources.forEach((source, target) {
|
||||
var visitor = _Visitor(File(source).readAsStringSync(), source);
|
||||
parseDartFile(source).accept(visitor);
|
||||
parseFile2(path: source, featureSet: FeatureSet.fromEnableFlags([]))
|
||||
.unit
|
||||
.accept(visitor);
|
||||
var formatted = DartFormatter().format(visitor.result);
|
||||
File(target).writeAsStringSync(formatted);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user