forked from sass/dart-sass
/
extend_rule.dart
36 lines (28 loc) · 1.05 KB
/
extend_rule.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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.
import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';
import '../../../visitor/interface/statement.dart';
import '../interpolation.dart';
import '../statement.dart';
/// An `@extend` rule.
///
/// This gives one selector all the styling of another.
///
/// {@category AST}
@sealed
class ExtendRule implements Statement {
/// The interpolation for the selector that will be extended.
final Interpolation selector;
/// Whether this is an optional extension.
///
/// If an extension isn't optional, it will emit an error if it doesn't match
/// any selectors.
final bool isOptional;
final FileSpan span;
ExtendRule(this.selector, this.span, {bool optional = false})
: isOptional = optional;
T accept<T>(StatementVisitor<T> visitor) => visitor.visitExtendRule(this);
String toString() => "@extend $selector${isOptional ? ' !optional' : ''};";
}