Skip to content

Commit

Permalink
Use of() constructors instead of from()
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Jun 14, 2018
1 parent 6ad67a6 commit 7a2d724
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/src/ast/sass/argument_declaration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ArgumentDeclaration implements SassNode {
}

String toString() {
var components = new List.from(arguments.map((arg) => arg.toString()));
var components = new List.of(arguments.map((arg) => arg.toString()));
if (restArgument != null) components.add('$restArgument...');
return components.join(', ');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/executable/watch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class _Watcher {
/// necessary.
Future _recompileDownstream(Iterable<StylesheetNode> nodes) async {
var seen = new Set<StylesheetNode>();
var toRecompile = new Queue<StylesheetNode>.from(nodes);
var toRecompile = new Queue.of(nodes);

while (!toRecompile.isEmpty) {
var node = toRecompile.removeFirst();
Expand Down
10 changes: 5 additions & 5 deletions lib/src/extend/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import '../utils.dart';
///
/// For example, `.foo` is a superselector of `:matches(.foo)`.
final _subselectorPseudos =
new Set<String>.from(['matches', 'any', 'nth-child', 'nth-last-child']);
new Set.of(['matches', 'any', 'nth-child', 'nth-last-child']);

/// Returns the contents of a [SelectorList] that matches only elements that are
/// matched by both [complex1] and [complex2].
Expand Down Expand Up @@ -183,8 +183,8 @@ List<List<ComplexSelectorComponent>> weave(
Iterable<List<ComplexSelectorComponent>> _weaveParents(
List<ComplexSelectorComponent> parents1,
List<ComplexSelectorComponent> parents2) {
var queue1 = new Queue<ComplexSelectorComponent>.from(parents1);
var queue2 = new Queue<ComplexSelectorComponent>.from(parents2);
var queue1 = new Queue.of(parents1);
var queue2 = new Queue.of(parents2);

var initialCombinators = _mergeInitialCombinators(queue1, queue2);
if (initialCombinators == null) return null;
Expand Down Expand Up @@ -316,9 +316,9 @@ List<List<List<ComplexSelectorComponent>>> _mergeFinalCombinators(
// is a supersequence of the other, use that, otherwise give up.
var lcs = longestCommonSubsequence(combinators1, combinators2);
if (listEquals(lcs, combinators1)) {
result.addFirst([new List.from(combinators2.reversed)]);
result.addFirst([new List.of(combinators2.reversed)]);
} else if (listEquals(lcs, combinators2)) {
result.addFirst([new List.from(combinators1.reversed)]);
result.addFirst([new List.of(combinators1.reversed)]);
} else {
return null;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'value.dart';
final _microsoftFilterStart = new RegExp(r'^[a-zA-Z]+\s*=');

/// Feature names supported by Dart sass.
final _features = new Set<String>.from([
final _features = new Set.of([
"global-variable-shadowing",
"extend-selector-pseudoclass",
"units-level-3",
Expand Down Expand Up @@ -806,13 +806,13 @@ final List<BuiltInCallable> coreFunctions = new UnmodifiableListView([
new BuiltInCallable("map-merge", r"$map1, $map2", (arguments) {
var map1 = arguments[0].assertMap("map1");
var map2 = arguments[1].assertMap("map2");
return new SassMap(new Map.from(map1.contents)..addAll(map2.contents));
return new SassMap(new Map.of(map1.contents)..addAll(map2.contents));
}),

new BuiltInCallable("map-remove", r"$map, $keys...", (arguments) {
var map = arguments[0].assertMap("map");
var keys = arguments[1];
var mutableMap = new Map<Value, Value>.from(map.contents);
var mutableMap = new Map.of(map.contents);
for (var key in keys.asList) {
mutableMap.remove(key);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/node/value/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final Function mapConstructor =
'setValue': (_NodeSassMap thisArg, int index, value) {
var key = thisArg.dartValue.contents.keys.elementAt(index);

var mutable = new Map<Value, Value>.from(thisArg.dartValue.contents);
var mutable = new Map.of(thisArg.dartValue.contents);
mutable[key] = unwrapValue(value);
thisArg.dartValue = new SassMap(mutable);
},
Expand Down
4 changes: 2 additions & 2 deletions lib/src/parse/selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import '../utils.dart';
import 'parser.dart';

/// Pseudo-class selectors that take unadorned selectors as arguments.
final _selectorPseudoClasses = new Set<String>.from(
final _selectorPseudoClasses = new Set.of(
["not", "matches", "current", "any", "has", "host", "host-context"]);

/// Pseudo-element selectors that take unadorned selectors as arguments.
final _selectorPseudoElements = new Set<String>.from(["slotted"]);
final _selectorPseudoElements = new Set.of(["slotted"]);

/// A parser for selectors.
class SelectorParser extends Parser {
Expand Down
8 changes: 3 additions & 5 deletions lib/src/stylesheet_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class StylesheetGraph {
/// appears within [baseUrl] imported by [baseImporter].
Map<Uri, StylesheetNode> _upstreamNodes(
Stylesheet stylesheet, Importer baseImporter, Uri baseUrl) {
var active = new Set<Uri>.from([baseUrl]);
var active = new Set.of([baseUrl]);
var upstream = <Uri, StylesheetNode>{};
for (var import in findImports(stylesheet)) {
var url = Uri.parse(import.url);
Expand Down Expand Up @@ -255,10 +255,8 @@ class StylesheetNode {
/// Sets [newUpstream] as the new value of [upstream] and adjusts upstream
/// nodes' [downstream] fields accordingly.
void _replaceUpstream(Map<Uri, StylesheetNode> newUpstream) {
var oldUpstream = new Set<StylesheetNode>.from(upstream.values)
..remove(null);
var newUpstreamSet = new Set<StylesheetNode>.from(newUpstream.values)
..remove(null);
var oldUpstream = new Set.of(upstream.values)..remove(null);
var newUpstreamSet = new Set.of(newUpstream.values)..remove(null);

for (var removed in oldUpstream.difference(newUpstreamSet)) {
var wasRemoved = removed._downstream.remove(this);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/visitor/serialize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import 'interface/value.dart';
/// Normally we avoid encoding this much information about CSS semantics, but
/// since this is just for an optimization it won't cause user pain if it takes
/// us a while to add new units.
final _compressibleUnits = new Set.from([
final _compressibleUnits = new Set.of([
"em", "ex", "ch", "rem", "vw", "wh", "vmin", "vmax", "cm", "mm", "q", "in", //
"pt", "pc", "px", "deg", "rad", "turn"
]);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ executables:
dart-sass: sass

environment:
sdk: '>=1.25.0-dev.29.0 <2.0.0'
sdk: '>=1.25.0-dev.35.0 <2.0.0'

dependencies:
args: ">=1.4.0 <2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion test/source_map_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ void _expectMapMatches(
Map<String, SourceLocation> sourceLocations,
List<Tuple2<String, SourceLocation>> targetLocations) {
expect(sourceLocations.keys,
equals(new Set.from(targetLocations.map((tuple) => tuple.item1))));
equals(new Set.of(targetLocations.map((tuple) => tuple.item1))));

String actualMap() =>
"\nActual map:\n\n" + _mapToString(map, sourceText, targetText) + "\n";
Expand Down

0 comments on commit 7a2d724

Please sign in to comment.