mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-23 06:12:00 +01:00
Delete ModifiableCssNode.modifyChildren
Instead of doing this, we now construct a new (unmodifiable) CssStylesheet if additional imports need to be added.
This commit is contained in:
parent
93f4876b28
commit
d3c3a3d515
@ -93,14 +93,6 @@ abstract class ModifiableCssParentNode extends ModifiableCssNode
|
|||||||
/// Returns a copy of [this] with an empty [children] list.
|
/// Returns a copy of [this] with an empty [children] list.
|
||||||
ModifiableCssParentNode copyWithoutChildren();
|
ModifiableCssParentNode copyWithoutChildren();
|
||||||
|
|
||||||
/// Passes a modifiable view of [children] to [modify].
|
|
||||||
///
|
|
||||||
/// This is used to explicitly indicate when modifications are intended so
|
|
||||||
/// that [children] can remain unmodifiable by default.
|
|
||||||
void modifyChildren(void modify(List<ModifiableCssNode> children)) {
|
|
||||||
modify(_children);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Adds [child] as a child of this statement.
|
/// Adds [child] as a child of this statement.
|
||||||
void addChild(ModifiableCssNode child) {
|
void addChild(ModifiableCssNode child) {
|
||||||
child._parent = this;
|
child._parent = this;
|
||||||
|
@ -2,9 +2,23 @@
|
|||||||
// MIT-style license that can be found in the LICENSE file or at
|
// MIT-style license that can be found in the LICENSE file or at
|
||||||
// https://opensource.org/licenses/MIT.
|
// https://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
|
import 'package:source_span/source_span.dart';
|
||||||
|
|
||||||
|
import '../../visitor/interface/css.dart';
|
||||||
import 'node.dart';
|
import 'node.dart';
|
||||||
|
|
||||||
/// A plain CSS stylesheet.
|
/// A plain CSS stylesheet.
|
||||||
///
|
///
|
||||||
/// This is the root plain CSS node. It contains top-level statements.
|
/// This is the root plain CSS node. It contains top-level statements.
|
||||||
abstract class CssStylesheet extends CssParentNode {}
|
class CssStylesheet extends CssParentNode {
|
||||||
|
final List<CssNode> children;
|
||||||
|
final FileSpan span;
|
||||||
|
bool get isGroupEnd => false;
|
||||||
|
bool get isChildless => false;
|
||||||
|
|
||||||
|
/// Creates an unmodifiable stylesheet containing [children].
|
||||||
|
CssStylesheet(Iterable<CssNode> children, this.span)
|
||||||
|
: children = List.unmodifiable(children);
|
||||||
|
|
||||||
|
T accept<T>(CssVisitor<T> visitor) => visitor.visitStylesheet(this);
|
||||||
|
}
|
||||||
|
@ -327,7 +327,20 @@ class _EvaluateVisitor
|
|||||||
|
|
||||||
await visitStylesheet(node);
|
await visitStylesheet(node);
|
||||||
|
|
||||||
return EvaluateResult(_root, _includedFiles);
|
CssStylesheet stylesheet = _root;
|
||||||
|
if (_outOfOrderImports.isNotEmpty) {
|
||||||
|
// Create a copy of [_root.children] with [_outOfOrderImports] inserted at
|
||||||
|
// [_endOfImports].
|
||||||
|
var statements =
|
||||||
|
List<CssNode>(_root.children.length + _outOfOrderImports.length);
|
||||||
|
statements.setRange(0, _endOfImports, _root.children);
|
||||||
|
statements.setAll(_endOfImports, _outOfOrderImports);
|
||||||
|
statements.setRange(_endOfImports + _outOfOrderImports.length,
|
||||||
|
statements.length, _root.children, _endOfImports);
|
||||||
|
stylesheet = CssStylesheet(statements, _root.span);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EvaluateResult(stylesheet, _includedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ## Statements
|
// ## Statements
|
||||||
@ -340,12 +353,6 @@ class _EvaluateVisitor
|
|||||||
await child.accept(this);
|
await child.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_outOfOrderImports.isNotEmpty) {
|
|
||||||
_root.modifyChildren((children) {
|
|
||||||
children.insertAll(_endOfImports, _outOfOrderImports);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_extender.finalize();
|
_extender.finalize();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// DO NOT EDIT. This file was generated from async_evaluate.dart.
|
// DO NOT EDIT. This file was generated from async_evaluate.dart.
|
||||||
// See tool/synchronize.dart for details.
|
// See tool/synchronize.dart for details.
|
||||||
//
|
//
|
||||||
// Checksum: f90160d7f7fd8d5b9aacd1019cfe9e41385d34f5
|
// Checksum: 816959e86ecf3e10aaa0ced8a58a35cf3604b3b2
|
||||||
//
|
//
|
||||||
// ignore_for_file: unused_import
|
// ignore_for_file: unused_import
|
||||||
|
|
||||||
@ -334,7 +334,20 @@ class _EvaluateVisitor
|
|||||||
|
|
||||||
visitStylesheet(node);
|
visitStylesheet(node);
|
||||||
|
|
||||||
return EvaluateResult(_root, _includedFiles);
|
CssStylesheet stylesheet = _root;
|
||||||
|
if (_outOfOrderImports.isNotEmpty) {
|
||||||
|
// Create a copy of [_root.children] with [_outOfOrderImports] inserted at
|
||||||
|
// [_endOfImports].
|
||||||
|
var statements =
|
||||||
|
List<CssNode>(_root.children.length + _outOfOrderImports.length);
|
||||||
|
statements.setRange(0, _endOfImports, _root.children);
|
||||||
|
statements.setAll(_endOfImports, _outOfOrderImports);
|
||||||
|
statements.setRange(_endOfImports + _outOfOrderImports.length,
|
||||||
|
statements.length, _root.children, _endOfImports);
|
||||||
|
stylesheet = CssStylesheet(statements, _root.span);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EvaluateResult(stylesheet, _includedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ## Statements
|
// ## Statements
|
||||||
@ -347,12 +360,6 @@ class _EvaluateVisitor
|
|||||||
child.accept(this);
|
child.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_outOfOrderImports.isNotEmpty) {
|
|
||||||
_root.modifyChildren((children) {
|
|
||||||
children.insertAll(_endOfImports, _outOfOrderImports);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_extender.finalize();
|
_extender.finalize();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user