mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-30 04:39:03 +01:00
Disable implicit downcasts.
This commit is contained in:
parent
35b3baa1ef
commit
13156d5107
@ -1,2 +1,3 @@
|
||||
analyzer:
|
||||
strong-mode: true
|
||||
strong-mode:
|
||||
implicit-casts: false
|
||||
|
@ -22,12 +22,16 @@ class Interpolation implements SassNode {
|
||||
/// Otherwise, returns `null`.
|
||||
String get asPlain {
|
||||
if (contents.isEmpty) return '';
|
||||
if (contents.length == 1 && contents.first is String) return contents.first;
|
||||
return null;
|
||||
if (contents.length > 1) return null;
|
||||
var first = contents.first;
|
||||
return first is String ? first : null;
|
||||
}
|
||||
|
||||
/// Returns the plain text before the interpolation, or the empty string.
|
||||
String get initialPlain => contents.first is String ? contents.first : '';
|
||||
String get initialPlain {
|
||||
var first = contents.first;
|
||||
return first is String ? first : '';
|
||||
}
|
||||
|
||||
Interpolation(Iterable /*(String|Expression)*/ contents, this.span)
|
||||
: contents = new List.unmodifiable(contents) {
|
||||
|
@ -14,7 +14,7 @@ class IDSelector extends SimpleSelector {
|
||||
/// The ID name this selects for.
|
||||
final String name;
|
||||
|
||||
int get minSpecificity => math.pow(super.minSpecificity, 2);
|
||||
int get minSpecificity => math.pow(super.minSpecificity, 2) as int;
|
||||
|
||||
IDSelector(this.name);
|
||||
|
||||
|
@ -120,7 +120,7 @@ class PseudoSelector extends SimpleSelector {
|
||||
}
|
||||
} else {
|
||||
// This is higher than any selector's specificity can actually be.
|
||||
_minSpecificity = math.pow(super.minSpecificity, 3);
|
||||
_minSpecificity = math.pow(super.minSpecificity, 3) as int;
|
||||
_maxSpecificity = 0;
|
||||
for (var complex in selector.components) {
|
||||
_minSpecificity = math.min(_minSpecificity, complex.minSpecificity);
|
||||
|
@ -6,155 +6,154 @@ import 'utils.dart';
|
||||
import 'value.dart';
|
||||
|
||||
/// A map from (lowercase) color names to their color values.
|
||||
final colorsByName = normalizedMap()
|
||||
..addAll({
|
||||
'aliceblue': new SassColor.rgb(0xF0, 0xF8, 0xFF),
|
||||
'antiquewhite': new SassColor.rgb(0xFA, 0xEB, 0xD7),
|
||||
'aquamarine': new SassColor.rgb(0x7F, 0xFF, 0xD4),
|
||||
'azure': new SassColor.rgb(0xF0, 0xFF, 0xFF),
|
||||
'beige': new SassColor.rgb(0xF5, 0xF5, 0xDC),
|
||||
'bisque': new SassColor.rgb(0xFF, 0xE4, 0xC4),
|
||||
'black': new SassColor.rgb(0x00, 0x00, 0x00),
|
||||
'blanchedalmond': new SassColor.rgb(0xFF, 0xEB, 0xCD),
|
||||
'blue': new SassColor.rgb(0x00, 0x00, 0xFF),
|
||||
'blueviolet': new SassColor.rgb(0x8A, 0x2B, 0xE2),
|
||||
'brown': new SassColor.rgb(0xA5, 0x2A, 0x2A),
|
||||
'burlywood': new SassColor.rgb(0xDE, 0xB8, 0x87),
|
||||
'cadetblue': new SassColor.rgb(0x5F, 0x9E, 0xA0),
|
||||
'chartreuse': new SassColor.rgb(0x7F, 0xFF, 0x00),
|
||||
'chocolate': new SassColor.rgb(0xD2, 0x69, 0x1E),
|
||||
'coral': new SassColor.rgb(0xFF, 0x7F, 0x50),
|
||||
'cornflowerblue': new SassColor.rgb(0x64, 0x95, 0xED),
|
||||
'cornsilk': new SassColor.rgb(0xFF, 0xF8, 0xDC),
|
||||
'crimson': new SassColor.rgb(0xDC, 0x14, 0x3C),
|
||||
'cyan': new SassColor.rgb(0x00, 0xFF, 0xFF),
|
||||
'aqua': new SassColor.rgb(0x00, 0xFF, 0xFF),
|
||||
'darkblue': new SassColor.rgb(0x00, 0x00, 0x8B),
|
||||
'darkcyan': new SassColor.rgb(0x00, 0x8B, 0x8B),
|
||||
'darkgoldenrod': new SassColor.rgb(0xB8, 0x86, 0x0B),
|
||||
'darkgray': new SassColor.rgb(0xA9, 0xA9, 0xA9),
|
||||
'darkgrey': new SassColor.rgb(0xA9, 0xA9, 0xA9),
|
||||
'darkgreen': new SassColor.rgb(0x00, 0x64, 0x00),
|
||||
'darkkhaki': new SassColor.rgb(0xBD, 0xB7, 0x6B),
|
||||
'darkmagenta': new SassColor.rgb(0x8B, 0x00, 0x8B),
|
||||
'darkolivegreen': new SassColor.rgb(0x55, 0x6B, 0x2F),
|
||||
'darkorange': new SassColor.rgb(0xFF, 0x8C, 0x00),
|
||||
'darkorchid': new SassColor.rgb(0x99, 0x32, 0xCC),
|
||||
'darkred': new SassColor.rgb(0x8B, 0x00, 0x00),
|
||||
'darksalmon': new SassColor.rgb(0xE9, 0x96, 0x7A),
|
||||
'darkseagreen': new SassColor.rgb(0x8F, 0xBC, 0x8F),
|
||||
'darkslateblue': new SassColor.rgb(0x48, 0x3D, 0x8B),
|
||||
'darkslategray': new SassColor.rgb(0x2F, 0x4F, 0x4F),
|
||||
'darkslategrey': new SassColor.rgb(0x2F, 0x4F, 0x4F),
|
||||
'darkturquoise': new SassColor.rgb(0x00, 0xCE, 0xD1),
|
||||
'darkviolet': new SassColor.rgb(0x94, 0x00, 0xD3),
|
||||
'deeppink': new SassColor.rgb(0xFF, 0x14, 0x93),
|
||||
'deepskyblue': new SassColor.rgb(0x00, 0xBF, 0xFF),
|
||||
'dimgray': new SassColor.rgb(0x69, 0x69, 0x69),
|
||||
'dimgrey': new SassColor.rgb(0x69, 0x69, 0x69),
|
||||
'dodgerblue': new SassColor.rgb(0x1E, 0x90, 0xFF),
|
||||
'firebrick': new SassColor.rgb(0xB2, 0x22, 0x22),
|
||||
'floralwhite': new SassColor.rgb(0xFF, 0xFA, 0xF0),
|
||||
'forestgreen': new SassColor.rgb(0x22, 0x8B, 0x22),
|
||||
'gainsboro': new SassColor.rgb(0xDC, 0xDC, 0xDC),
|
||||
'ghostwhite': new SassColor.rgb(0xF8, 0xF8, 0xFF),
|
||||
'gold': new SassColor.rgb(0xFF, 0xD7, 0x00),
|
||||
'goldenrod': new SassColor.rgb(0xDA, 0xA5, 0x20),
|
||||
'gray': new SassColor.rgb(0x80, 0x80, 0x80),
|
||||
'grey': new SassColor.rgb(0x80, 0x80, 0x80),
|
||||
'green': new SassColor.rgb(0x00, 0x80, 0x00),
|
||||
'greenyellow': new SassColor.rgb(0xAD, 0xFF, 0x2F),
|
||||
'honeydew': new SassColor.rgb(0xF0, 0xFF, 0xF0),
|
||||
'hotpink': new SassColor.rgb(0xFF, 0x69, 0xB4),
|
||||
'indianred': new SassColor.rgb(0xCD, 0x5C, 0x5C),
|
||||
'indigo': new SassColor.rgb(0x4B, 0x00, 0x82),
|
||||
'ivory': new SassColor.rgb(0xFF, 0xFF, 0xF0),
|
||||
'khaki': new SassColor.rgb(0xF0, 0xE6, 0x8C),
|
||||
'lavender': new SassColor.rgb(0xE6, 0xE6, 0xFA),
|
||||
'lavenderblush': new SassColor.rgb(0xFF, 0xF0, 0xF5),
|
||||
'lawngreen': new SassColor.rgb(0x7C, 0xFC, 0x00),
|
||||
'lemonchiffon': new SassColor.rgb(0xFF, 0xFA, 0xCD),
|
||||
'lightblue': new SassColor.rgb(0xAD, 0xD8, 0xE6),
|
||||
'lightcoral': new SassColor.rgb(0xF0, 0x80, 0x80),
|
||||
'lightcyan': new SassColor.rgb(0xE0, 0xFF, 0xFF),
|
||||
'lightgoldenrodyellow': new SassColor.rgb(0xFA, 0xFA, 0xD2),
|
||||
'lightgreen': new SassColor.rgb(0x90, 0xEE, 0x90),
|
||||
'lightgray': new SassColor.rgb(0xD3, 0xD3, 0xD3),
|
||||
'lightgrey': new SassColor.rgb(0xD3, 0xD3, 0xD3),
|
||||
'lightpink': new SassColor.rgb(0xFF, 0xB6, 0xC1),
|
||||
'lightsalmon': new SassColor.rgb(0xFF, 0xA0, 0x7A),
|
||||
'lightseagreen': new SassColor.rgb(0x20, 0xB2, 0xAA),
|
||||
'lightskyblue': new SassColor.rgb(0x87, 0xCE, 0xFA),
|
||||
'lightslategray': new SassColor.rgb(0x77, 0x88, 0x99),
|
||||
'lightslategrey': new SassColor.rgb(0x77, 0x88, 0x99),
|
||||
'lightsteelblue': new SassColor.rgb(0xB0, 0xC4, 0xDE),
|
||||
'lightyellow': new SassColor.rgb(0xFF, 0xFF, 0xE0),
|
||||
'lime': new SassColor.rgb(0x00, 0xFF, 0x00),
|
||||
'limegreen': new SassColor.rgb(0x32, 0xCD, 0x32),
|
||||
'linen': new SassColor.rgb(0xFA, 0xF0, 0xE6),
|
||||
'magenta': new SassColor.rgb(0xFF, 0x00, 0xFF),
|
||||
'fuchsia': new SassColor.rgb(0xFF, 0x00, 0xFF),
|
||||
'maroon': new SassColor.rgb(0x80, 0x00, 0x00),
|
||||
'mediumaquamarine': new SassColor.rgb(0x66, 0xCD, 0xAA),
|
||||
'mediumblue': new SassColor.rgb(0x00, 0x00, 0xCD),
|
||||
'mediumorchid': new SassColor.rgb(0xBA, 0x55, 0xD3),
|
||||
'mediumpurple': new SassColor.rgb(0x93, 0x70, 0xDB),
|
||||
'mediumseagreen': new SassColor.rgb(0x3C, 0xB3, 0x71),
|
||||
'mediumslateblue': new SassColor.rgb(0x7B, 0x68, 0xEE),
|
||||
'mediumspringgreen': new SassColor.rgb(0x00, 0xFA, 0x9A),
|
||||
'mediumturquoise': new SassColor.rgb(0x48, 0xD1, 0xCC),
|
||||
'mediumvioletred': new SassColor.rgb(0xC7, 0x15, 0x85),
|
||||
'midnightblue': new SassColor.rgb(0x19, 0x19, 0x70),
|
||||
'mintcream': new SassColor.rgb(0xF5, 0xFF, 0xFA),
|
||||
'mistyrose': new SassColor.rgb(0xFF, 0xE4, 0xE1),
|
||||
'moccasin': new SassColor.rgb(0xFF, 0xE4, 0xB5),
|
||||
'navajowhite': new SassColor.rgb(0xFF, 0xDE, 0xAD),
|
||||
'navy': new SassColor.rgb(0x00, 0x00, 0x80),
|
||||
'oldlace': new SassColor.rgb(0xFD, 0xF5, 0xE6),
|
||||
'olive': new SassColor.rgb(0x80, 0x80, 0x00),
|
||||
'olivedrab': new SassColor.rgb(0x6B, 0x8E, 0x23),
|
||||
'orange': new SassColor.rgb(0xFF, 0xA5, 0x00),
|
||||
'orangered': new SassColor.rgb(0xFF, 0x45, 0x00),
|
||||
'orchid': new SassColor.rgb(0xDA, 0x70, 0xD6),
|
||||
'palegoldenrod': new SassColor.rgb(0xEE, 0xE8, 0xAA),
|
||||
'palegreen': new SassColor.rgb(0x98, 0xFB, 0x98),
|
||||
'paleturquoise': new SassColor.rgb(0xAF, 0xEE, 0xEE),
|
||||
'palevioletred': new SassColor.rgb(0xDB, 0x70, 0x93),
|
||||
'papayawhip': new SassColor.rgb(0xFF, 0xEF, 0xD5),
|
||||
'peachpuff': new SassColor.rgb(0xFF, 0xDA, 0xB9),
|
||||
'peru': new SassColor.rgb(0xCD, 0x85, 0x3F),
|
||||
'pink': new SassColor.rgb(0xFF, 0xC0, 0xCB),
|
||||
'plum': new SassColor.rgb(0xDD, 0xA0, 0xDD),
|
||||
'powderblue': new SassColor.rgb(0xB0, 0xE0, 0xE6),
|
||||
'purple': new SassColor.rgb(0x80, 0x00, 0x80),
|
||||
'red': new SassColor.rgb(0xFF, 0x00, 0x00),
|
||||
'rebeccapurple': new SassColor.rgb(0x66, 0x33, 0x99),
|
||||
'rosybrown': new SassColor.rgb(0xBC, 0x8F, 0x8F),
|
||||
'royalblue': new SassColor.rgb(0x41, 0x69, 0xE1),
|
||||
'saddlebrown': new SassColor.rgb(0x8B, 0x45, 0x13),
|
||||
'salmon': new SassColor.rgb(0xFA, 0x80, 0x72),
|
||||
'sandybrown': new SassColor.rgb(0xF4, 0xA4, 0x60),
|
||||
'seagreen': new SassColor.rgb(0x2E, 0x8B, 0x57),
|
||||
'seashell': new SassColor.rgb(0xFF, 0xF5, 0xEE),
|
||||
'sienna': new SassColor.rgb(0xA0, 0x52, 0x2D),
|
||||
'silver': new SassColor.rgb(0xC0, 0xC0, 0xC0),
|
||||
'skyblue': new SassColor.rgb(0x87, 0xCE, 0xEB),
|
||||
'slateblue': new SassColor.rgb(0x6A, 0x5A, 0xCD),
|
||||
'slategray': new SassColor.rgb(0x70, 0x80, 0x90),
|
||||
'slategrey': new SassColor.rgb(0x70, 0x80, 0x90),
|
||||
'snow': new SassColor.rgb(0xFF, 0xFA, 0xFA),
|
||||
'springgreen': new SassColor.rgb(0x00, 0xFF, 0x7F),
|
||||
'steelblue': new SassColor.rgb(0x46, 0x82, 0xB4),
|
||||
'tan': new SassColor.rgb(0xD2, 0xB4, 0x8C),
|
||||
'teal': new SassColor.rgb(0x00, 0x80, 0x80),
|
||||
'thistle': new SassColor.rgb(0xD8, 0xBF, 0xD8),
|
||||
'tomato': new SassColor.rgb(0xFF, 0x63, 0x47),
|
||||
'transparent': new SassColor.rgb(0, 0, 0, 0),
|
||||
'turquoise': new SassColor.rgb(0x40, 0xE0, 0xD0),
|
||||
'violet': new SassColor.rgb(0xEE, 0x82, 0xEE),
|
||||
'wheat': new SassColor.rgb(0xF5, 0xDE, 0xB3),
|
||||
'white': new SassColor.rgb(0xFF, 0xFF, 0xFF),
|
||||
'whitesmoke': new SassColor.rgb(0xF5, 0xF5, 0xF5),
|
||||
'yellow': new SassColor.rgb(0xFF, 0xFF, 0x00),
|
||||
'yellowgreen': new SassColor.rgb(0x9A, 0xCD, 0x32),
|
||||
});
|
||||
final colorsByName = normalizedMap({
|
||||
'aliceblue': new SassColor.rgb(0xF0, 0xF8, 0xFF),
|
||||
'antiquewhite': new SassColor.rgb(0xFA, 0xEB, 0xD7),
|
||||
'aquamarine': new SassColor.rgb(0x7F, 0xFF, 0xD4),
|
||||
'azure': new SassColor.rgb(0xF0, 0xFF, 0xFF),
|
||||
'beige': new SassColor.rgb(0xF5, 0xF5, 0xDC),
|
||||
'bisque': new SassColor.rgb(0xFF, 0xE4, 0xC4),
|
||||
'black': new SassColor.rgb(0x00, 0x00, 0x00),
|
||||
'blanchedalmond': new SassColor.rgb(0xFF, 0xEB, 0xCD),
|
||||
'blue': new SassColor.rgb(0x00, 0x00, 0xFF),
|
||||
'blueviolet': new SassColor.rgb(0x8A, 0x2B, 0xE2),
|
||||
'brown': new SassColor.rgb(0xA5, 0x2A, 0x2A),
|
||||
'burlywood': new SassColor.rgb(0xDE, 0xB8, 0x87),
|
||||
'cadetblue': new SassColor.rgb(0x5F, 0x9E, 0xA0),
|
||||
'chartreuse': new SassColor.rgb(0x7F, 0xFF, 0x00),
|
||||
'chocolate': new SassColor.rgb(0xD2, 0x69, 0x1E),
|
||||
'coral': new SassColor.rgb(0xFF, 0x7F, 0x50),
|
||||
'cornflowerblue': new SassColor.rgb(0x64, 0x95, 0xED),
|
||||
'cornsilk': new SassColor.rgb(0xFF, 0xF8, 0xDC),
|
||||
'crimson': new SassColor.rgb(0xDC, 0x14, 0x3C),
|
||||
'cyan': new SassColor.rgb(0x00, 0xFF, 0xFF),
|
||||
'aqua': new SassColor.rgb(0x00, 0xFF, 0xFF),
|
||||
'darkblue': new SassColor.rgb(0x00, 0x00, 0x8B),
|
||||
'darkcyan': new SassColor.rgb(0x00, 0x8B, 0x8B),
|
||||
'darkgoldenrod': new SassColor.rgb(0xB8, 0x86, 0x0B),
|
||||
'darkgray': new SassColor.rgb(0xA9, 0xA9, 0xA9),
|
||||
'darkgrey': new SassColor.rgb(0xA9, 0xA9, 0xA9),
|
||||
'darkgreen': new SassColor.rgb(0x00, 0x64, 0x00),
|
||||
'darkkhaki': new SassColor.rgb(0xBD, 0xB7, 0x6B),
|
||||
'darkmagenta': new SassColor.rgb(0x8B, 0x00, 0x8B),
|
||||
'darkolivegreen': new SassColor.rgb(0x55, 0x6B, 0x2F),
|
||||
'darkorange': new SassColor.rgb(0xFF, 0x8C, 0x00),
|
||||
'darkorchid': new SassColor.rgb(0x99, 0x32, 0xCC),
|
||||
'darkred': new SassColor.rgb(0x8B, 0x00, 0x00),
|
||||
'darksalmon': new SassColor.rgb(0xE9, 0x96, 0x7A),
|
||||
'darkseagreen': new SassColor.rgb(0x8F, 0xBC, 0x8F),
|
||||
'darkslateblue': new SassColor.rgb(0x48, 0x3D, 0x8B),
|
||||
'darkslategray': new SassColor.rgb(0x2F, 0x4F, 0x4F),
|
||||
'darkslategrey': new SassColor.rgb(0x2F, 0x4F, 0x4F),
|
||||
'darkturquoise': new SassColor.rgb(0x00, 0xCE, 0xD1),
|
||||
'darkviolet': new SassColor.rgb(0x94, 0x00, 0xD3),
|
||||
'deeppink': new SassColor.rgb(0xFF, 0x14, 0x93),
|
||||
'deepskyblue': new SassColor.rgb(0x00, 0xBF, 0xFF),
|
||||
'dimgray': new SassColor.rgb(0x69, 0x69, 0x69),
|
||||
'dimgrey': new SassColor.rgb(0x69, 0x69, 0x69),
|
||||
'dodgerblue': new SassColor.rgb(0x1E, 0x90, 0xFF),
|
||||
'firebrick': new SassColor.rgb(0xB2, 0x22, 0x22),
|
||||
'floralwhite': new SassColor.rgb(0xFF, 0xFA, 0xF0),
|
||||
'forestgreen': new SassColor.rgb(0x22, 0x8B, 0x22),
|
||||
'gainsboro': new SassColor.rgb(0xDC, 0xDC, 0xDC),
|
||||
'ghostwhite': new SassColor.rgb(0xF8, 0xF8, 0xFF),
|
||||
'gold': new SassColor.rgb(0xFF, 0xD7, 0x00),
|
||||
'goldenrod': new SassColor.rgb(0xDA, 0xA5, 0x20),
|
||||
'gray': new SassColor.rgb(0x80, 0x80, 0x80),
|
||||
'grey': new SassColor.rgb(0x80, 0x80, 0x80),
|
||||
'green': new SassColor.rgb(0x00, 0x80, 0x00),
|
||||
'greenyellow': new SassColor.rgb(0xAD, 0xFF, 0x2F),
|
||||
'honeydew': new SassColor.rgb(0xF0, 0xFF, 0xF0),
|
||||
'hotpink': new SassColor.rgb(0xFF, 0x69, 0xB4),
|
||||
'indianred': new SassColor.rgb(0xCD, 0x5C, 0x5C),
|
||||
'indigo': new SassColor.rgb(0x4B, 0x00, 0x82),
|
||||
'ivory': new SassColor.rgb(0xFF, 0xFF, 0xF0),
|
||||
'khaki': new SassColor.rgb(0xF0, 0xE6, 0x8C),
|
||||
'lavender': new SassColor.rgb(0xE6, 0xE6, 0xFA),
|
||||
'lavenderblush': new SassColor.rgb(0xFF, 0xF0, 0xF5),
|
||||
'lawngreen': new SassColor.rgb(0x7C, 0xFC, 0x00),
|
||||
'lemonchiffon': new SassColor.rgb(0xFF, 0xFA, 0xCD),
|
||||
'lightblue': new SassColor.rgb(0xAD, 0xD8, 0xE6),
|
||||
'lightcoral': new SassColor.rgb(0xF0, 0x80, 0x80),
|
||||
'lightcyan': new SassColor.rgb(0xE0, 0xFF, 0xFF),
|
||||
'lightgoldenrodyellow': new SassColor.rgb(0xFA, 0xFA, 0xD2),
|
||||
'lightgreen': new SassColor.rgb(0x90, 0xEE, 0x90),
|
||||
'lightgray': new SassColor.rgb(0xD3, 0xD3, 0xD3),
|
||||
'lightgrey': new SassColor.rgb(0xD3, 0xD3, 0xD3),
|
||||
'lightpink': new SassColor.rgb(0xFF, 0xB6, 0xC1),
|
||||
'lightsalmon': new SassColor.rgb(0xFF, 0xA0, 0x7A),
|
||||
'lightseagreen': new SassColor.rgb(0x20, 0xB2, 0xAA),
|
||||
'lightskyblue': new SassColor.rgb(0x87, 0xCE, 0xFA),
|
||||
'lightslategray': new SassColor.rgb(0x77, 0x88, 0x99),
|
||||
'lightslategrey': new SassColor.rgb(0x77, 0x88, 0x99),
|
||||
'lightsteelblue': new SassColor.rgb(0xB0, 0xC4, 0xDE),
|
||||
'lightyellow': new SassColor.rgb(0xFF, 0xFF, 0xE0),
|
||||
'lime': new SassColor.rgb(0x00, 0xFF, 0x00),
|
||||
'limegreen': new SassColor.rgb(0x32, 0xCD, 0x32),
|
||||
'linen': new SassColor.rgb(0xFA, 0xF0, 0xE6),
|
||||
'magenta': new SassColor.rgb(0xFF, 0x00, 0xFF),
|
||||
'fuchsia': new SassColor.rgb(0xFF, 0x00, 0xFF),
|
||||
'maroon': new SassColor.rgb(0x80, 0x00, 0x00),
|
||||
'mediumaquamarine': new SassColor.rgb(0x66, 0xCD, 0xAA),
|
||||
'mediumblue': new SassColor.rgb(0x00, 0x00, 0xCD),
|
||||
'mediumorchid': new SassColor.rgb(0xBA, 0x55, 0xD3),
|
||||
'mediumpurple': new SassColor.rgb(0x93, 0x70, 0xDB),
|
||||
'mediumseagreen': new SassColor.rgb(0x3C, 0xB3, 0x71),
|
||||
'mediumslateblue': new SassColor.rgb(0x7B, 0x68, 0xEE),
|
||||
'mediumspringgreen': new SassColor.rgb(0x00, 0xFA, 0x9A),
|
||||
'mediumturquoise': new SassColor.rgb(0x48, 0xD1, 0xCC),
|
||||
'mediumvioletred': new SassColor.rgb(0xC7, 0x15, 0x85),
|
||||
'midnightblue': new SassColor.rgb(0x19, 0x19, 0x70),
|
||||
'mintcream': new SassColor.rgb(0xF5, 0xFF, 0xFA),
|
||||
'mistyrose': new SassColor.rgb(0xFF, 0xE4, 0xE1),
|
||||
'moccasin': new SassColor.rgb(0xFF, 0xE4, 0xB5),
|
||||
'navajowhite': new SassColor.rgb(0xFF, 0xDE, 0xAD),
|
||||
'navy': new SassColor.rgb(0x00, 0x00, 0x80),
|
||||
'oldlace': new SassColor.rgb(0xFD, 0xF5, 0xE6),
|
||||
'olive': new SassColor.rgb(0x80, 0x80, 0x00),
|
||||
'olivedrab': new SassColor.rgb(0x6B, 0x8E, 0x23),
|
||||
'orange': new SassColor.rgb(0xFF, 0xA5, 0x00),
|
||||
'orangered': new SassColor.rgb(0xFF, 0x45, 0x00),
|
||||
'orchid': new SassColor.rgb(0xDA, 0x70, 0xD6),
|
||||
'palegoldenrod': new SassColor.rgb(0xEE, 0xE8, 0xAA),
|
||||
'palegreen': new SassColor.rgb(0x98, 0xFB, 0x98),
|
||||
'paleturquoise': new SassColor.rgb(0xAF, 0xEE, 0xEE),
|
||||
'palevioletred': new SassColor.rgb(0xDB, 0x70, 0x93),
|
||||
'papayawhip': new SassColor.rgb(0xFF, 0xEF, 0xD5),
|
||||
'peachpuff': new SassColor.rgb(0xFF, 0xDA, 0xB9),
|
||||
'peru': new SassColor.rgb(0xCD, 0x85, 0x3F),
|
||||
'pink': new SassColor.rgb(0xFF, 0xC0, 0xCB),
|
||||
'plum': new SassColor.rgb(0xDD, 0xA0, 0xDD),
|
||||
'powderblue': new SassColor.rgb(0xB0, 0xE0, 0xE6),
|
||||
'purple': new SassColor.rgb(0x80, 0x00, 0x80),
|
||||
'red': new SassColor.rgb(0xFF, 0x00, 0x00),
|
||||
'rebeccapurple': new SassColor.rgb(0x66, 0x33, 0x99),
|
||||
'rosybrown': new SassColor.rgb(0xBC, 0x8F, 0x8F),
|
||||
'royalblue': new SassColor.rgb(0x41, 0x69, 0xE1),
|
||||
'saddlebrown': new SassColor.rgb(0x8B, 0x45, 0x13),
|
||||
'salmon': new SassColor.rgb(0xFA, 0x80, 0x72),
|
||||
'sandybrown': new SassColor.rgb(0xF4, 0xA4, 0x60),
|
||||
'seagreen': new SassColor.rgb(0x2E, 0x8B, 0x57),
|
||||
'seashell': new SassColor.rgb(0xFF, 0xF5, 0xEE),
|
||||
'sienna': new SassColor.rgb(0xA0, 0x52, 0x2D),
|
||||
'silver': new SassColor.rgb(0xC0, 0xC0, 0xC0),
|
||||
'skyblue': new SassColor.rgb(0x87, 0xCE, 0xEB),
|
||||
'slateblue': new SassColor.rgb(0x6A, 0x5A, 0xCD),
|
||||
'slategray': new SassColor.rgb(0x70, 0x80, 0x90),
|
||||
'slategrey': new SassColor.rgb(0x70, 0x80, 0x90),
|
||||
'snow': new SassColor.rgb(0xFF, 0xFA, 0xFA),
|
||||
'springgreen': new SassColor.rgb(0x00, 0xFF, 0x7F),
|
||||
'steelblue': new SassColor.rgb(0x46, 0x82, 0xB4),
|
||||
'tan': new SassColor.rgb(0xD2, 0xB4, 0x8C),
|
||||
'teal': new SassColor.rgb(0x00, 0x80, 0x80),
|
||||
'thistle': new SassColor.rgb(0xD8, 0xBF, 0xD8),
|
||||
'tomato': new SassColor.rgb(0xFF, 0x63, 0x47),
|
||||
'transparent': new SassColor.rgb(0, 0, 0, 0),
|
||||
'turquoise': new SassColor.rgb(0x40, 0xE0, 0xD0),
|
||||
'violet': new SassColor.rgb(0xEE, 0x82, 0xEE),
|
||||
'wheat': new SassColor.rgb(0xF5, 0xDE, 0xB3),
|
||||
'white': new SassColor.rgb(0xFF, 0xFF, 0xFF),
|
||||
'whitesmoke': new SassColor.rgb(0xF5, 0xF5, 0xF5),
|
||||
'yellow': new SassColor.rgb(0xFF, 0xFF, 0x00),
|
||||
'yellowgreen': new SassColor.rgb(0x9A, 0xCD, 0x32),
|
||||
});
|
||||
|
@ -113,7 +113,7 @@ class Extender {
|
||||
|
||||
var rules = _selectors[target];
|
||||
if (rules == null) return;
|
||||
var extensions = {target: new Set()..add(source)};
|
||||
var extensions = {target: new Set<ExtendSource>()..add(source)};
|
||||
for (var rule in rules.toList()) {
|
||||
rule.selector.value = _extendList(rule.selector.value, extensions);
|
||||
_registerSelector(rule.selector.value, rule);
|
||||
@ -210,7 +210,7 @@ class Extender {
|
||||
return new ComplexSelector(outputComplex,
|
||||
lineBreak: complex.lineBreak ||
|
||||
path.any((inputComplex) => inputComplex.lineBreak));
|
||||
});
|
||||
}).toList();
|
||||
}).toList());
|
||||
return result;
|
||||
}
|
||||
@ -386,7 +386,9 @@ class Extender {
|
||||
// TODO(nweiz): I think there may be a way to get perfect trimming without
|
||||
// going quadratic by building some sort of trie-like data structure that
|
||||
// can be used to look up superselectors.
|
||||
if (lists.length > 100) return lists.expand((selectors) => selectors);
|
||||
if (lists.length > 100) {
|
||||
return lists.expand((selectors) => selectors).toList();
|
||||
}
|
||||
|
||||
// This is n² on the sequences, but only comparing between separate
|
||||
// sequences should limit the quadratic behavior.
|
||||
|
@ -211,18 +211,20 @@ Iterable<List<ComplexSelectorComponent>> _weaveParents(
|
||||
});
|
||||
|
||||
var choices = [
|
||||
<List<ComplexSelectorComponent>>[initialCombinator]
|
||||
<Iterable<ComplexSelectorComponent>>[initialCombinator]
|
||||
];
|
||||
for (var group in lcs) {
|
||||
choices.add(_chunks/*<List<ComplexSelectorComponent>>*/(groups1, groups2,
|
||||
(sequence) => complexIsParentSuperselector(sequence.first, group))
|
||||
.map((chunk) => chunk.expand((group) => group)));
|
||||
.map((chunk) => chunk.expand((group) => group))
|
||||
.toList());
|
||||
choices.add([group]);
|
||||
groups1.removeFirst();
|
||||
groups2.removeFirst();
|
||||
}
|
||||
choices.add(_chunks(groups1, groups2, (sequence) => sequence.isEmpty)
|
||||
.map((chunk) => chunk.expand((group) => group)));
|
||||
.map((chunk) => chunk.expand((group) => group))
|
||||
.toList());
|
||||
choices.addAll(finalCombinator);
|
||||
|
||||
return paths(choices.where((choice) => choice.isNotEmpty))
|
||||
@ -404,7 +406,7 @@ List<List<List<ComplexSelectorComponent>>> _mergeFinalCombinators(
|
||||
if (combinator1 == Combinator.child &&
|
||||
components2.isNotEmpty &&
|
||||
(components2.last as CompoundSelector)
|
||||
.isSuperselector(components1.last)) {
|
||||
.isSuperselector(components1.last as CompoundSelector)) {
|
||||
components2.removeLast();
|
||||
}
|
||||
result.addFirst([
|
||||
@ -416,7 +418,7 @@ List<List<List<ComplexSelectorComponent>>> _mergeFinalCombinators(
|
||||
if (combinator2 == Combinator.child &&
|
||||
components1.isNotEmpty &&
|
||||
(components1.last as CompoundSelector)
|
||||
.isSuperselector(components2.last)) {
|
||||
.isSuperselector(components2.last as CompoundSelector)) {
|
||||
components1.removeLast();
|
||||
}
|
||||
result.addFirst([
|
||||
@ -577,15 +579,16 @@ bool complexIsSuperselector(List<ComplexSelectorComponent> complex1,
|
||||
// subselectors.
|
||||
if (complex1[i1] is Combinator) return false;
|
||||
if (complex2[i2] is Combinator) return false;
|
||||
var compound1 = complex1[i1] as CompoundSelector;
|
||||
var compound2 = complex2[i2] as CompoundSelector;
|
||||
|
||||
if (remaining1 == 1) {
|
||||
var selector = complex1[i1] as CompoundSelector;
|
||||
return compoundIsSuperselector(selector, complex2[i2],
|
||||
return compoundIsSuperselector(compound1, compound2,
|
||||
parents: complex2.skip(i2 + 1));
|
||||
}
|
||||
|
||||
// Find the first index where `complex2.sublist(i2, afterSuperselector)` is
|
||||
// a subselector of `complex1[i1]`. We stop before the superselector would
|
||||
// a subselector of [compound1]. We stop before the superselector would
|
||||
// encompass all of [complex2] because we know [complex1] has more than one
|
||||
// element, and consuming all of [complex2] wouldn't leave anything for the
|
||||
// rest of [complex1] to match.
|
||||
@ -593,7 +596,7 @@ bool complexIsSuperselector(List<ComplexSelectorComponent> complex1,
|
||||
for (; afterSuperselector < complex2.length; afterSuperselector++) {
|
||||
if (complex2[afterSuperselector - 1] is Combinator) continue;
|
||||
|
||||
if (compoundIsSuperselector(complex1[i1], complex2[i2],
|
||||
if (compoundIsSuperselector(compound1, compound2,
|
||||
parents: complex2.take(afterSuperselector - 1).skip(i2 + 1))) {
|
||||
break;
|
||||
}
|
||||
@ -768,8 +771,8 @@ bool _selectorPseudoIsSuperselector(
|
||||
/// and that have the given [name].
|
||||
Iterable<PseudoSelector> _selectorPseudosNamed(
|
||||
CompoundSelector compound, String name) =>
|
||||
compound.components.where((simple) =>
|
||||
DelegatingIterable.typed(compound.components.where((simple) =>
|
||||
simple is PseudoSelector &&
|
||||
simple.isClass &&
|
||||
simple.selector != null &&
|
||||
simple.name == name);
|
||||
simple.name == name));
|
||||
|
@ -33,7 +33,7 @@ final _features = new Set.from([
|
||||
final _random = new math.Random();
|
||||
|
||||
// We use base-36 so we can use the (26-character) alphabet and all digits.
|
||||
var _uniqueID = _random.nextInt(math.pow(36, 6));
|
||||
var _uniqueID = _random.nextInt(math.pow(36, 6) as int);
|
||||
|
||||
/// Adds all core-library function definitions to [environment].
|
||||
void defineCoreFunctions(Environment environment) {
|
||||
@ -286,13 +286,13 @@ void defineCoreFunctions(Environment environment) {
|
||||
"be passed by name.");
|
||||
}
|
||||
|
||||
var keywords = normalizedMap/*<Value>*/()..addAll(argumentList.keywords);
|
||||
var keywords = normalizedMap(argumentList.keywords);
|
||||
getInRange(String name, num min, num max) =>
|
||||
keywords.remove(name)?.assertNumber(name)?.valueInRange(min, max, name);
|
||||
|
||||
var red = getInRange("red", -255, 255);
|
||||
var green = getInRange("green", -255, 255);
|
||||
var blue = getInRange("blue", -255, 255);
|
||||
var red = getInRange("red", -255, 255)?.round();
|
||||
var green = getInRange("green", -255, 255)?.round();
|
||||
var blue = getInRange("blue", -255, 255)?.round();
|
||||
var hue = keywords.remove("hue")?.assertNumber("hue")?.value;
|
||||
var saturation = getInRange("saturation", -100, 100);
|
||||
var lightness = getInRange("lightness", -100, 100);
|
||||
@ -337,7 +337,7 @@ void defineCoreFunctions(Environment environment) {
|
||||
"be passed by name.");
|
||||
}
|
||||
|
||||
var keywords = normalizedMap/*<Value>*/()..addAll(argumentList.keywords);
|
||||
var keywords = normalizedMap(argumentList.keywords);
|
||||
getScale(String name) {
|
||||
var value = keywords.remove(name);
|
||||
if (value == null) return null;
|
||||
@ -397,13 +397,13 @@ void defineCoreFunctions(Environment environment) {
|
||||
"be passed by name.");
|
||||
}
|
||||
|
||||
var keywords = normalizedMap/*<Value>*/()..addAll(argumentList.keywords);
|
||||
var keywords = normalizedMap(argumentList.keywords);
|
||||
getInRange(String name, num min, num max) =>
|
||||
keywords.remove(name)?.assertNumber(name)?.valueInRange(min, max, name);
|
||||
|
||||
var red = getInRange("red", 0, 255);
|
||||
var green = getInRange("green", 0, 255);
|
||||
var blue = getInRange("blue", 0, 255);
|
||||
var red = getInRange("red", 0, 255)?.round();
|
||||
var green = getInRange("green", 0, 255)?.round();
|
||||
var blue = getInRange("blue", 0, 255)?.round();
|
||||
var hue = keywords.remove("hue")?.assertNumber("hue")?.value;
|
||||
var saturation = getInRange("saturation", 0, 100);
|
||||
var lightness = getInRange("lightness", 0, 100);
|
||||
@ -722,8 +722,8 @@ void defineCoreFunctions(Environment environment) {
|
||||
environment.defineFunction("keywords", r"$args", (arguments) {
|
||||
var argumentList = arguments[0];
|
||||
if (argumentList is SassArgumentList) {
|
||||
return new SassMap(
|
||||
mapMap(argumentList.keywords, key: (key, _) => new SassString(key)));
|
||||
return new SassMap(mapMap(argumentList.keywords,
|
||||
key: (String key, Value _) => new SassString(key)));
|
||||
} else {
|
||||
throw new SassScriptException(
|
||||
"\$args: $argumentList is not an argument list.");
|
||||
@ -763,8 +763,8 @@ void defineCoreFunctions(Environment environment) {
|
||||
throw new SassScriptException("Can't append $complex to $parent.");
|
||||
}
|
||||
|
||||
return new ComplexSelector(
|
||||
[newCompound]..addAll(complex.components.skip(1)));
|
||||
return new ComplexSelector(<ComplexSelectorComponent>[newCompound]
|
||||
..addAll(complex.components.skip(1)));
|
||||
} else {
|
||||
throw new SassScriptException("Can't append $complex to $parent.");
|
||||
}
|
||||
@ -888,7 +888,7 @@ void defineCoreFunctions(Environment environment) {
|
||||
environment.defineFunction("unique-id", "", (arguments) {
|
||||
// Make it difficult to guess the next ID by randomizing the increase.
|
||||
_uniqueID += _random.nextInt(36) + 1;
|
||||
if (_uniqueID > math.pow(36, 6)) _uniqueID %= math.pow(36, 6);
|
||||
if (_uniqueID > math.pow(36, 6)) _uniqueID %= math.pow(36, 6) as int;
|
||||
// The leading "u" ensures that the result is a valid identifier.
|
||||
return new SassString("u${_uniqueID.toRadixString(36).padLeft(6, '0')}");
|
||||
});
|
||||
@ -1009,8 +1009,9 @@ CompoundSelector _prependParent(CompoundSelector compound) {
|
||||
if (first is UniversalSelector) return null;
|
||||
if (first is TypeSelector) {
|
||||
if (first.name.namespace != null) return null;
|
||||
return new CompoundSelector([new ParentSelector(suffix: first.name.name)]
|
||||
..addAll(compound.components.skip(1)));
|
||||
return new CompoundSelector(<SimpleSelector>[
|
||||
new ParentSelector(suffix: first.name.name)
|
||||
]..addAll(compound.components.skip(1)));
|
||||
} else {
|
||||
return new CompoundSelector(
|
||||
<SimpleSelector>[new ParentSelector()]..addAll(compound.components));
|
||||
|
@ -44,7 +44,7 @@ class InterpolationBuffer implements StringSink {
|
||||
void addInterpolation(Interpolation interpolation) {
|
||||
if (interpolation.contents.isEmpty) return;
|
||||
|
||||
var toAdd = interpolation.contents;
|
||||
Iterable toAdd = interpolation.contents;
|
||||
var first = interpolation.contents.first;
|
||||
if (first is String) {
|
||||
_text.write(first);
|
||||
|
@ -159,12 +159,24 @@ bool equalsIgnoreCase(String string1, String string2) {
|
||||
}
|
||||
|
||||
/// Returns an empty map that uses [equalsIgnoreSeparator] for key equality.
|
||||
Map/*<String, V>*/ normalizedMap/*<V>*/() => new LinkedHashMap(
|
||||
equals: equalsIgnoreSeparator, hashCode: hashCodeIgnoreSeparator);
|
||||
///
|
||||
/// If [source] is passed, copies it into the map.
|
||||
Map/*<String, V>*/ normalizedMap/*<V>*/([Map<String, dynamic/*=V*/ > source]) {
|
||||
var map = new LinkedHashMap/*<String, V>*/(
|
||||
equals: equalsIgnoreSeparator, hashCode: hashCodeIgnoreSeparator);
|
||||
if (source != null) map.addAll(source);
|
||||
return map;
|
||||
}
|
||||
|
||||
/// Returns an empty set that uses [equalsIgnoreSeparator] for equality.
|
||||
Set<String> normalizedSet() => new LinkedHashSet(
|
||||
equals: equalsIgnoreSeparator, hashCode: hashCodeIgnoreSeparator);
|
||||
///
|
||||
/// If [source] is passed, copies it into the set.
|
||||
Set<String> normalizedSet([Iterable<String> source]) {
|
||||
var set = new LinkedHashSet(
|
||||
equals: equalsIgnoreSeparator, hashCode: hashCodeIgnoreSeparator);
|
||||
if (source != null) set.addAll(source);
|
||||
return set;
|
||||
}
|
||||
|
||||
/// Like [mapMap], but returns a map that uses [equalsIgnoreSeparator] for key
|
||||
/// equality.
|
||||
|
@ -29,6 +29,6 @@ class SassArgumentList extends SassList {
|
||||
|
||||
SassArgumentList(Iterable<Value> contents, Map<String, Value> keywords,
|
||||
ListSeparator separator)
|
||||
: _keywords = new UnmodifiableMapView(normalizedMap()..addAll(keywords)),
|
||||
: _keywords = new UnmodifiableMapView(normalizedMap(keywords)),
|
||||
super(contents, separator);
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ class SassNumber extends Value {
|
||||
var value = this.value;
|
||||
var oldNumerators = numeratorUnits.toList();
|
||||
for (var newNumerator in newNumerators) {
|
||||
removeFirstWhere(oldNumerators, (oldNumerator) {
|
||||
removeFirstWhere/*<String>*/(oldNumerators, (oldNumerator) {
|
||||
var factor = _conversionFactor(newNumerator, oldNumerator);
|
||||
if (factor == null) return false;
|
||||
value *= factor;
|
||||
@ -355,7 +355,7 @@ class SassNumber extends Value {
|
||||
|
||||
var oldDenominators = denominatorUnits.toList();
|
||||
for (var newDenominator in newDenominators) {
|
||||
removeFirstWhere(oldDenominators, (oldDenominator) {
|
||||
removeFirstWhere/*<String>*/(oldDenominators, (oldDenominator) {
|
||||
var factor = _conversionFactor(newDenominator, oldDenominator);
|
||||
if (factor == null) return false;
|
||||
value /= factor;
|
||||
@ -535,7 +535,7 @@ class SassNumber extends Value {
|
||||
continue;
|
||||
}
|
||||
|
||||
removeFirstWhere(mutableDenominators2, (denominator) {
|
||||
removeFirstWhere/*<String>*/(mutableDenominators2, (denominator) {
|
||||
var factor = _conversionFactor(numerator, denominator);
|
||||
if (factor == null) return false;
|
||||
value *= factor;
|
||||
@ -552,7 +552,7 @@ class SassNumber extends Value {
|
||||
continue;
|
||||
}
|
||||
|
||||
removeFirstWhere(mutableDenominators1, (denominator) {
|
||||
removeFirstWhere/*<String>*/(mutableDenominators1, (denominator) {
|
||||
var factor = _conversionFactor(numerator, denominator);
|
||||
if (factor == null) return false;
|
||||
value *= factor;
|
||||
|
@ -37,10 +37,11 @@ typedef _ScopeCallback(callback());
|
||||
CssStylesheet evaluate(Stylesheet stylesheet,
|
||||
{Iterable<String> loadPaths, Environment environment}) =>
|
||||
new _PerformVisitor(loadPaths: loadPaths, environment: environment)
|
||||
.visitStylesheet(stylesheet);
|
||||
.run(stylesheet);
|
||||
|
||||
/// A visitor that executes Sass code to produce a CSS tree.
|
||||
class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
class _PerformVisitor
|
||||
implements StatementVisitor<Value>, ExpressionVisitor<Value> {
|
||||
/// The paths to search for Sass files being imported.
|
||||
final List<String> _loadPaths;
|
||||
|
||||
@ -105,19 +106,24 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
});
|
||||
}
|
||||
|
||||
CssStylesheet run(Stylesheet node) {
|
||||
visitStylesheet(node);
|
||||
return _root;
|
||||
}
|
||||
|
||||
// ## Statements
|
||||
|
||||
CssStylesheet visitStylesheet(Stylesheet node) {
|
||||
Value visitStylesheet(Stylesheet node) {
|
||||
_root = new CssStylesheet(node.span);
|
||||
_parent = _root;
|
||||
for (var child in node.children) {
|
||||
child.accept(this);
|
||||
}
|
||||
_extender.finalize();
|
||||
return _root;
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitAtRootRule(AtRootRule node) {
|
||||
Value visitAtRootRule(AtRootRule node) {
|
||||
var query = node.query == null
|
||||
? AtRootQuery.defaultQuery
|
||||
: new AtRootQuery.parse(_performInterpolation(node.query));
|
||||
@ -136,7 +142,7 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
for (var child in node.children) {
|
||||
child.accept(this);
|
||||
}
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
var innerCopy =
|
||||
@ -154,6 +160,8 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
child.accept(this);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Destructively trims a trailing sublist that matches the current list of
|
||||
@ -190,7 +198,7 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
/// This returns a callback that adjusts various instance variables for its
|
||||
/// duration, based on which rules are excluded by [query]. It always assigns
|
||||
/// [_parent] to [newParent].
|
||||
_ScopeCallback _scopeForAtRoot(CssNode newParent, AtRootQuery query) {
|
||||
_ScopeCallback _scopeForAtRoot(CssParentNode newParent, AtRootQuery query) {
|
||||
var scope = (callback()) {
|
||||
// We can't use [_withParent] here because it'll add the node to the tree
|
||||
// in the wrong place.
|
||||
@ -212,14 +220,15 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
return scope;
|
||||
}
|
||||
|
||||
void visitComment(Comment node) {
|
||||
if (node.isSilent) return;
|
||||
Value visitComment(Comment node) {
|
||||
if (node.isSilent) return null;
|
||||
_parent.addChild(new CssComment(node.text, node.span));
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitContentRule(ContentRule node) {
|
||||
Value visitContentRule(ContentRule node) {
|
||||
var block = _environment.contentBlock;
|
||||
if (block == null) return;
|
||||
if (block == null) return null;
|
||||
|
||||
_withStackFrame("@content", node.span, () {
|
||||
_withEnvironment(_environment.contentEnvironment, () {
|
||||
@ -228,14 +237,17 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitDebugRule(DebugRule node) {
|
||||
Value visitDebugRule(DebugRule node) {
|
||||
stderr.writeln("Line ${node.span.start.line + 1} DEBUG: "
|
||||
"${node.expression.accept(this)}");
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitDeclaration(Declaration node) {
|
||||
Value visitDeclaration(Declaration node) {
|
||||
if (_selector == null) {
|
||||
throw _exception(
|
||||
"Declarations may only be used within style rules.", node.span);
|
||||
@ -262,6 +274,8 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
}
|
||||
_declarationName = oldDeclarationName;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Returns whether [value] is an empty [SassList].
|
||||
@ -270,12 +284,14 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
Value visitEachRule(EachRule node) {
|
||||
var list = node.list.accept(this);
|
||||
var setVariables = node.variables.length == 1
|
||||
? (value) => _environment.setLocalVariable(node.variables.first, value)
|
||||
: (value) => _setMultipleVariables(node.variables, value);
|
||||
? (Value value) =>
|
||||
_environment.setLocalVariable(node.variables.first, value)
|
||||
: (Value value) => _setMultipleVariables(node.variables, value);
|
||||
return _environment.scope(() {
|
||||
return _handleReturn(list.asList, (element) {
|
||||
return _handleReturn/*<Value>*/(list.asList, (element) {
|
||||
setVariables(element);
|
||||
return _handleReturn(node.children, (child) => child.accept(this));
|
||||
return _handleReturn/*<Statement>*/(
|
||||
node.children, (child) => child.accept(this));
|
||||
});
|
||||
}, semiGlobal: true);
|
||||
}
|
||||
@ -293,11 +309,11 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
}
|
||||
}
|
||||
|
||||
void visitErrorRule(ErrorRule node) {
|
||||
Value visitErrorRule(ErrorRule node) {
|
||||
throw _exception(node.expression.accept(this).toString(), node.span);
|
||||
}
|
||||
|
||||
void visitExtendRule(ExtendRule node) {
|
||||
Value visitExtendRule(ExtendRule node) {
|
||||
if (_selector == null || _declarationName != null) {
|
||||
throw _exception(
|
||||
"@extend may only be used within style rules.", node.span);
|
||||
@ -310,9 +326,10 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
() => new SimpleSelector.parse(targetText.value.trim(),
|
||||
allowParent: false));
|
||||
_extender.addExtension(_selector, target, node);
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitAtRule(AtRule node) {
|
||||
Value visitAtRule(AtRule node) {
|
||||
if (_declarationName != null) {
|
||||
throw _exception(
|
||||
"At-rules may not be used within nested declarations.", node.span);
|
||||
@ -325,7 +342,7 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
if (node.children == null) {
|
||||
_parent.addChild(
|
||||
new CssAtRule(node.name, node.span, childless: true, value: value));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
_withParent(new CssAtRule(node.name, node.span, value: value), () {
|
||||
@ -345,6 +362,8 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
});
|
||||
}
|
||||
}, through: (node) => node is CssStyleRule);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Value visitForRule(ForRule node) {
|
||||
@ -361,17 +380,18 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
return _environment.scope(() {
|
||||
for (var i = from; i != to; i += direction) {
|
||||
_environment.setLocalVariable(node.variable, new SassNumber(i));
|
||||
var result =
|
||||
_handleReturn(node.children, (child) => child.accept(this));
|
||||
var result = _handleReturn/*<Statement>*/(
|
||||
node.children, (child) => child.accept(this));
|
||||
if (result != null) return result;
|
||||
}
|
||||
return null;
|
||||
}, semiGlobal: true);
|
||||
}
|
||||
|
||||
void visitFunctionRule(FunctionRule node) {
|
||||
Value visitFunctionRule(FunctionRule node) {
|
||||
_environment
|
||||
.setFunction(new UserDefinedCallable(node, _environment.closure()));
|
||||
return null;
|
||||
}
|
||||
|
||||
Value visitIfRule(IfRule node) {
|
||||
@ -383,11 +403,12 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
if (clause == null) return null;
|
||||
|
||||
return _environment.scope(
|
||||
() => _handleReturn(clause, (child) => child.accept(this)),
|
||||
() =>
|
||||
_handleReturn/*<Statement>*/(clause, (child) => child.accept(this)),
|
||||
semiGlobal: true);
|
||||
}
|
||||
|
||||
void visitImportRule(ImportRule node) {
|
||||
Value visitImportRule(ImportRule node) {
|
||||
var stylesheet = _loadImport(node);
|
||||
_withStackFrame("@import", node.span, () {
|
||||
_withEnvironment(_environment.global(), () {
|
||||
@ -396,6 +417,7 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
}
|
||||
});
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Loads the [Stylesheet] imported by [node], or throws a
|
||||
@ -446,7 +468,7 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitIncludeRule(IncludeRule node) {
|
||||
Value visitIncludeRule(IncludeRule node) {
|
||||
var mixin = _environment.getMixin(node.name) as UserDefinedCallable;
|
||||
if (mixin == null) {
|
||||
throw _exception("Undefined mixin.", node.span);
|
||||
@ -471,14 +493,17 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
_environment.withContent(node.children, environment, callback);
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitMixinRule(MixinRule node) {
|
||||
Value visitMixinRule(MixinRule node) {
|
||||
_environment
|
||||
.setMixin(new UserDefinedCallable(node, _environment.closure()));
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitMediaRule(MediaRule node) {
|
||||
Value visitMediaRule(MediaRule node) {
|
||||
if (_declarationName != null) {
|
||||
throw _exception(
|
||||
"Media rules may not be used within nested declarations.", node.span);
|
||||
@ -488,7 +513,7 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
var queries = _mediaQueries == null
|
||||
? new List<CssMediaQuery>.unmodifiable(queryIterable)
|
||||
: _mergeMediaQueries(_mediaQueries, queryIterable);
|
||||
if (queries.isEmpty) return;
|
||||
if (queries.isEmpty) return null;
|
||||
|
||||
_withParent(new CssMediaRule(queries, node.span), () {
|
||||
_withMediaQueries(queries, () {
|
||||
@ -510,6 +535,8 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
}
|
||||
});
|
||||
}, through: (node) => node is CssStyleRule || node is CssMediaRule);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Returns a list of queries that selects for platforms that match both
|
||||
@ -535,13 +562,14 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
return new CssMediaQuery(type, modifier: modifier, features: features);
|
||||
}
|
||||
|
||||
void visitPlainImportRule(PlainImportRule node) {
|
||||
Value visitPlainImportRule(PlainImportRule node) {
|
||||
_parent.addChild(new CssImport(_interpolationToValue(node.url), node.span));
|
||||
return null;
|
||||
}
|
||||
|
||||
Value visitReturnRule(ReturnRule node) => node.expression.accept(this);
|
||||
|
||||
void visitStyleRule(StyleRule node) {
|
||||
Value visitStyleRule(StyleRule node) {
|
||||
if (_declarationName != null) {
|
||||
throw _exception(
|
||||
"Style rules may not be used within nested declarations.", node.span);
|
||||
@ -564,9 +592,11 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
}
|
||||
});
|
||||
}, through: (node) => node is CssStyleRule);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitSupportsRule(SupportsRule node) {
|
||||
Value visitSupportsRule(SupportsRule node) {
|
||||
if (_declarationName != null) {
|
||||
throw _exception(
|
||||
"Supports rules may not be used within nested declarations.",
|
||||
@ -593,6 +623,8 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
});
|
||||
}
|
||||
}, through: (node) => node is CssStyleRule);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Evaluates [condition] and converts it to a plain CSS string.
|
||||
@ -629,13 +661,14 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
}
|
||||
}
|
||||
|
||||
void visitVariableDeclaration(VariableDeclaration node) {
|
||||
Value visitVariableDeclaration(VariableDeclaration node) {
|
||||
_environment.setVariable(
|
||||
node.name, node.expression.accept(this).withoutOriginal(),
|
||||
global: node.isGlobal);
|
||||
return null;
|
||||
}
|
||||
|
||||
void visitWarnRule(WarnRule node) {
|
||||
Value visitWarnRule(WarnRule node) {
|
||||
_addExceptionSpan(node.span, () {
|
||||
var value = node.expression.accept(this);
|
||||
var string = value is SassString ? value.text : value.toCssString();
|
||||
@ -645,13 +678,15 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
for (var line in _stackTrace(node.span).toString().split("\n")) {
|
||||
stderr.writeln(" $line");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Value visitWhileRule(WhileRule node) {
|
||||
return _environment.scope(() {
|
||||
while (node.condition.accept(this).isTruthy) {
|
||||
var result =
|
||||
_handleReturn(node.children, (child) => child.accept(this));
|
||||
var result = _handleReturn/*<Statement>*/(
|
||||
node.children, (child) => child.accept(this));
|
||||
if (result != null) return result;
|
||||
}
|
||||
return null;
|
||||
@ -993,8 +1028,7 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
}
|
||||
|
||||
var positional = invocation.arguments.positional.toList();
|
||||
var named = normalizedMap/*<Expression>*/()
|
||||
..addAll(invocation.arguments.named);
|
||||
var named = normalizedMap(invocation.arguments.named);
|
||||
var rest = invocation.arguments.rest.accept(this);
|
||||
if (rest is SassMap) {
|
||||
_addRestMap(
|
||||
@ -1080,8 +1114,7 @@ class _PerformVisitor implements StatementVisitor, ExpressionVisitor<Value> {
|
||||
}
|
||||
|
||||
if (arguments.arguments.length - positional < named.length) {
|
||||
var unknownNames = normalizedSet()
|
||||
..addAll(named.keys)
|
||||
var unknownNames = normalizedSet(named.keys)
|
||||
..removeAll(arguments.arguments.map((argument) => argument.name));
|
||||
throw _exception(
|
||||
"No ${pluralize('argument', unknownNames.length)} named "
|
||||
|
@ -299,7 +299,7 @@ class _SerializeCssVisitor
|
||||
value.separator == ListSeparator.comma;
|
||||
if (singleton) _buffer.writeCharCode($lparen);
|
||||
|
||||
_writeBetween(
|
||||
_writeBetween/*<Value>*/(
|
||||
_inspect
|
||||
? value.contents
|
||||
: value.contents.where((element) => !element.isBlank),
|
||||
@ -311,7 +311,9 @@ class _SerializeCssVisitor
|
||||
element.accept(this);
|
||||
if (needsParens) _buffer.writeCharCode($rparen);
|
||||
}
|
||||
: (element) => element.accept(this));
|
||||
: (element) {
|
||||
element.accept(this);
|
||||
});
|
||||
|
||||
if (singleton) {
|
||||
_buffer.writeCharCode($comma);
|
||||
@ -339,7 +341,7 @@ class _SerializeCssVisitor
|
||||
throw new SassScriptException("$map isn't a valid CSS value.");
|
||||
}
|
||||
_buffer.writeCharCode($lparen);
|
||||
_writeBetween(map.contents.keys, ", ", (key) {
|
||||
_writeBetween/*<Value>*/(map.contents.keys, ", ", (key) {
|
||||
_writeMapElement(key);
|
||||
_buffer.write(": ");
|
||||
_writeMapElement(map.contents[key]);
|
||||
|
Loading…
Reference in New Issue
Block a user