mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-27 04:34:59 +01:00
visit -> accept
This commit is contained in:
parent
d15247b019
commit
d2a42d61ef
@ -18,7 +18,7 @@ class Comment implements Statement {
|
||||
Comment(this.text, {bool silent, this.span})
|
||||
: isSilent = silent;
|
||||
|
||||
/*=T*/ visit/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitComment(this);
|
||||
|
||||
String toString() => text;
|
||||
|
@ -19,7 +19,7 @@ class Declaration implements Statement {
|
||||
|
||||
Declaration(this.name, this.value);
|
||||
|
||||
/*=T*/ visit/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitDeclaration(this);
|
||||
|
||||
String toString() => "$name: $value;";
|
||||
|
@ -15,5 +15,5 @@ export 'expression/unary_operator.dart';
|
||||
export 'expression/variable.dart';
|
||||
|
||||
abstract class Expression implements SassNode {
|
||||
/*=T*/ visit/*<T>*/(ExpressionVisitor/*<T>*/ visitor);
|
||||
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor);
|
||||
}
|
@ -14,7 +14,7 @@ class BooleanExpression implements Expression {
|
||||
|
||||
BooleanExpression(this.value, {this.span});
|
||||
|
||||
/*=T*/ visit/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitBooleanExpression(this);
|
||||
|
||||
String toString() => value.toString();
|
||||
|
@ -15,7 +15,7 @@ class IdentifierExpression implements Expression {
|
||||
|
||||
IdentifierExpression(this.text);
|
||||
|
||||
/*=T*/ visit/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitIdentifierExpression(this);
|
||||
|
||||
String toString() => text.toString();
|
||||
|
@ -40,7 +40,7 @@ class InterpolationExpression implements Expression {
|
||||
}
|
||||
}
|
||||
|
||||
/*=T*/ visit/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitInterpolationExpression(this);
|
||||
|
||||
String toString() =>
|
||||
|
@ -24,7 +24,7 @@ class ListExpression implements Expression {
|
||||
: contents = contents,
|
||||
span = span ?? spanForList(contents);
|
||||
|
||||
/*=T*/ visit/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitListExpression(this);
|
||||
|
||||
// TODO: parenthesize nested lists if necessary
|
||||
|
@ -14,7 +14,7 @@ class NumberExpression implements Expression {
|
||||
|
||||
NumberExpression(this.value, {this.span});
|
||||
|
||||
/*=T*/ visit/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitNumberExpression(this);
|
||||
|
||||
String toString() => value.toString();
|
||||
|
@ -23,7 +23,7 @@ class StringExpression implements Expression {
|
||||
/// Unlike [text], his doesn't resolve escapes and does include quotes.
|
||||
InterpolationExpression get asInterpolation => throw new UnimplementedError();
|
||||
|
||||
/*=T*/ visit/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitStringExpression(this);
|
||||
|
||||
StringExpression(this.text);
|
||||
|
@ -17,7 +17,7 @@ class UnaryOperatorExpression implements Expression {
|
||||
|
||||
UnaryOperatorExpression(this.operator, this.operand, {this.span});
|
||||
|
||||
/*=T*/ visit/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitUnaryOperatorExpression(this);
|
||||
|
||||
String toString() {
|
||||
|
@ -14,7 +14,7 @@ class VariableExpression implements Expression {
|
||||
|
||||
VariableExpression(this.name, {this.span});
|
||||
|
||||
/*=T*/ visit/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(ExpressionVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitVariableExpression(this);
|
||||
|
||||
String toString() => "\$$name";
|
||||
|
@ -12,5 +12,5 @@ export 'stylesheet.dart';
|
||||
export 'variable_declaration.dart';
|
||||
|
||||
abstract class Statement implements SassNode {
|
||||
/*=T*/ visit/*<T>*/(StatementVisitor/*<T>*/ visitor);
|
||||
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor);
|
||||
}
|
@ -20,7 +20,7 @@ class StyleRule implements Statement {
|
||||
StyleRule(this.selector, Iterable<Statement> children, {this.span})
|
||||
: children = new List.unmodifiable(children);
|
||||
|
||||
/*=T*/ visit/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitStyleRule(this);
|
||||
|
||||
String toString() => "$selector {${children.join(" ")}}";
|
||||
|
@ -15,7 +15,7 @@ class Stylesheet implements Statement {
|
||||
Stylesheet(Iterable<Statement> children, {this.span})
|
||||
: children = new List.unmodifiable(children);
|
||||
|
||||
/*=T*/ visit/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitStylesheet(this);
|
||||
|
||||
String toString() => children.join(" ");
|
||||
|
@ -24,7 +24,7 @@ class VariableDeclaration implements Statement {
|
||||
: isGuarded = guarded,
|
||||
isGlobal = global;
|
||||
|
||||
/*=T*/ visit/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
/*=T*/ accept/*<T>*/(StatementVisitor/*<T>*/ visitor) =>
|
||||
visitor.visitVariableDeclaration(this);
|
||||
|
||||
String toString() => "\$$name: $expression;";
|
||||
|
@ -11,8 +11,8 @@ import 'visitor/statement.dart';
|
||||
class AstVisitor<T> extends ExpressionVisitor<T>
|
||||
implements StatementVisitor<T> {
|
||||
T visit(SassNode node) {
|
||||
if (node is Statement) return node.visit(this);
|
||||
if (node is Expression) return node.visit(this);
|
||||
if (node is Statement) return node.accept(this);
|
||||
if (node is Expression) return node.accept(this);
|
||||
throw new ArgumentError("Unknown node type $node.");
|
||||
}
|
||||
|
||||
@ -20,27 +20,27 @@ class AstVisitor<T> extends ExpressionVisitor<T>
|
||||
|
||||
T visitDeclaration(DeclarationNode node) {
|
||||
visitInterpolationExpression(node.name);
|
||||
node.value.visit(this);
|
||||
node.value.accept(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
T visitStyleRule(StyleRuleNode node) {
|
||||
visitInterpolationExpression(node.selector);
|
||||
for (var child in node.children) {
|
||||
child.visit(this);
|
||||
child.accept(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
T visitStylesheet(StylesheetNode node) {
|
||||
for (var child in node.children) {
|
||||
child.visit(this);
|
||||
child.accept(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
T visitVariableDeclaration(VariableDeclarationNode node) {
|
||||
node.expression.visit(this);
|
||||
node.expression.accept(this);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,14 @@
|
||||
import '../ast/sass/expression.dart';
|
||||
|
||||
class ExpressionVisitor<T> {
|
||||
T visit(Expression expression) => expression.visit(this);
|
||||
T visit(Expression expression) => expression.accept(this);
|
||||
|
||||
T visitVariableExpression(VariableExpression node) => null;
|
||||
T visitBooleanExpression(BooleanExpression node) => null;
|
||||
T visitNumberExpression(NumberExpression node) => null;
|
||||
|
||||
T visitUnaryOperatorExpression(UnaryOperatorExpression node) {
|
||||
node.operand.visit(this);
|
||||
node.operand.accept(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ class ExpressionVisitor<T> {
|
||||
|
||||
T visitListExpression(ListExpression node) {
|
||||
for (var expression in node.contents) {
|
||||
expression.visit(this);
|
||||
expression.accept(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -35,7 +35,7 @@ class ExpressionVisitor<T> {
|
||||
|
||||
T visitInterpolationExpression(InterpolationExpression node) {
|
||||
for (var value in node.contents) {
|
||||
if (value is Expression) value.visit(this);
|
||||
if (value is Expression) value.accept(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ class PerformExpressionVisitor extends ExpressionVisitor<Value> {
|
||||
|
||||
PerformExpressionVisitor(this._environment);
|
||||
|
||||
Value visit(Expression expression) => expression.visit(this);
|
||||
Value visit(Expression expression) => expression.accept(this);
|
||||
|
||||
Value visitVariableExpression(VariableExpression node) {
|
||||
var result = _environment.getVariable(node.name);
|
||||
@ -23,7 +23,7 @@ class PerformExpressionVisitor extends ExpressionVisitor<Value> {
|
||||
}
|
||||
|
||||
Value visitUnaryOperatorExpression(UnaryOperatorExpression node) {
|
||||
var operand = node.operand.visit(this);
|
||||
var operand = node.operand.accept(this);
|
||||
switch (node.operator) {
|
||||
case UnaryOperator.plus: return operand.unaryPlus();
|
||||
case UnaryOperator.minus: return operand.unaryMinus();
|
||||
@ -45,12 +45,12 @@ class PerformExpressionVisitor extends ExpressionVisitor<Value> {
|
||||
SassString visitInterpolationExpression(InterpolationExpression node) {
|
||||
return new SassString(node.contents.map((value) {
|
||||
if (value is String) return value;
|
||||
return (value as Expression).visit(this);
|
||||
return (value as Expression).accept(this);
|
||||
}).join());
|
||||
}
|
||||
|
||||
SassList visitListExpression(ListExpression node) => new SassList(
|
||||
node.contents.map((expression) => expression.visit(this)),
|
||||
node.contents.map((expression) => expression.accept(this)),
|
||||
node.separator);
|
||||
|
||||
SassString visitStringExpression(StringExpression node) =>
|
||||
|
@ -5,7 +5,7 @@
|
||||
import '../ast/sass/statement.dart';
|
||||
|
||||
class StatementVisitor<T> {
|
||||
T visit(Statement node) => node.visit(this);
|
||||
T visit(Statement node) => node.accept(this);
|
||||
|
||||
T visitComment(Comment node) => null;
|
||||
T visitDeclaration(Declaration node) => null;
|
||||
@ -13,14 +13,14 @@ class StatementVisitor<T> {
|
||||
|
||||
T visitStyleRule(StyleRule node) {
|
||||
for (var child in node.children) {
|
||||
child.visit(this);
|
||||
child.accept(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
T visitStylesheet(Stylesheet node) {
|
||||
for (var child in node.children) {
|
||||
child.visit(this);
|
||||
child.accept(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class PerformVisitor extends StatementVisitor {
|
||||
: _environment = environment,
|
||||
_expressionVisitor = new PerformExpressionVisitor(environment);
|
||||
|
||||
void visit(Statement node) => node.visit(this);
|
||||
void visit(Statement node) => node.accept(this);
|
||||
|
||||
CssStylesheet visitStylesheet(Stylesheet node) {
|
||||
super.visitStylesheet(node);
|
||||
@ -75,7 +75,7 @@ class PerformVisitor extends StatementVisitor {
|
||||
|
||||
void visitVariableDeclaration(VariableDeclaration node) {
|
||||
_environment.setVariable(
|
||||
node.name, node.expression.visit(_expressionVisitor),
|
||||
node.name, node.expression.accept(_expressionVisitor),
|
||||
global: node.isGlobal);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class PerformVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
CssValue<Value> _performExpression(Expression expression) =>
|
||||
new CssValue(expression.visit(_expressionVisitor));
|
||||
new CssValue(expression.accept(_expressionVisitor));
|
||||
|
||||
void _addChild(CssNode node) {
|
||||
_children.last.add(new LinkedListValue(node));
|
||||
|
Loading…
Reference in New Issue
Block a user