2016-05-24 03:01:15 +02:00
|
|
|
// Copyright 2016 Google Inc. Use of this source code is governed by an
|
|
|
|
// MIT-style license that can be found in the LICENSE file or at
|
|
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
|
2016-05-24 23:01:41 +02:00
|
|
|
import 'dart:collection';
|
|
|
|
|
2016-06-06 08:51:50 +02:00
|
|
|
import 'package:charcode/charcode.dart';
|
2016-05-24 03:01:15 +02:00
|
|
|
import 'package:source_span/source_span.dart';
|
|
|
|
|
|
|
|
import 'ast/node.dart';
|
2016-06-03 22:36:20 +02:00
|
|
|
import 'value/number.dart';
|
|
|
|
|
2016-06-04 01:31:29 +02:00
|
|
|
const _epsilon = 1 / (10 * SassNumber.precision);
|
2016-05-24 03:01:15 +02:00
|
|
|
|
|
|
|
SourceSpan spanForList(List<AstNode> nodes) {
|
|
|
|
if (nodes.isEmpty) return null;
|
|
|
|
|
|
|
|
var first = nodes.first.span;
|
|
|
|
var last = nodes.last.span;
|
|
|
|
return first is FileSpan && last is FileSpan ? first.expand(last) : null;
|
|
|
|
}
|
2016-05-24 23:01:41 +02:00
|
|
|
|
2016-06-06 08:51:50 +02:00
|
|
|
String unvendor(String name) {
|
|
|
|
assert(!name.isEmpty);
|
|
|
|
if (name.codeUnitAt(0) == $dash) return name;
|
|
|
|
|
|
|
|
for (var i = 1; i < name.length; i++) {
|
|
|
|
if (name.codeUnitAt(0) == $dash) return name.substring(i + 1);
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2016-05-24 23:01:41 +02:00
|
|
|
class LinkedListValue<T> extends LinkedListEntry<LinkedListValue<T>> {
|
|
|
|
final T value;
|
|
|
|
|
|
|
|
LinkedListValue(this.value);
|
|
|
|
}
|
2016-06-03 22:36:20 +02:00
|
|
|
|
|
|
|
bool almostEquals(num number1, num number2) =>
|
|
|
|
(number1 - number2).abs() < _epsilon;
|