/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ export class NodeWithI18n { constructor(sourceSpan, i18n) { this.sourceSpan = sourceSpan; this.i18n = i18n; } } export class Text extends NodeWithI18n { constructor(value, sourceSpan, tokens, i18n) { super(sourceSpan, i18n); this.value = value; this.tokens = tokens; } visit(visitor, context) { return visitor.visitText(this, context); } } export class Expansion extends NodeWithI18n { constructor(switchValue, type, cases, sourceSpan, switchValueSourceSpan, i18n) { super(sourceSpan, i18n); this.switchValue = switchValue; this.type = type; this.cases = cases; this.switchValueSourceSpan = switchValueSourceSpan; } visit(visitor, context) { return visitor.visitExpansion(this, context); } } export class ExpansionCase { constructor(value, expression, sourceSpan, valueSourceSpan, expSourceSpan) { this.value = value; this.expression = expression; this.sourceSpan = sourceSpan; this.valueSourceSpan = valueSourceSpan; this.expSourceSpan = expSourceSpan; } visit(visitor, context) { return visitor.visitExpansionCase(this, context); } } export class Attribute extends NodeWithI18n { constructor(name, value, sourceSpan, keySpan, valueSpan, valueTokens, i18n) { super(sourceSpan, i18n); this.name = name; this.value = value; this.keySpan = keySpan; this.valueSpan = valueSpan; this.valueTokens = valueTokens; } visit(visitor, context) { return visitor.visitAttribute(this, context); } } export class Element extends NodeWithI18n { constructor(name, attrs, children, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) { super(sourceSpan, i18n); this.name = name; this.attrs = attrs; this.children = children; this.startSourceSpan = startSourceSpan; this.endSourceSpan = endSourceSpan; } visit(visitor, context) { return visitor.visitElement(this, context); } } export class Comment { constructor(value, sourceSpan) { this.value = value; this.sourceSpan = sourceSpan; } visit(visitor, context) { return visitor.visitComment(this, context); } } export class BlockGroup { constructor(blocks, sourceSpan, startSourceSpan, endSourceSpan = null) { this.blocks = blocks; this.sourceSpan = sourceSpan; this.startSourceSpan = startSourceSpan; this.endSourceSpan = endSourceSpan; } visit(visitor, context) { return visitor.visitBlockGroup(this, context); } } export class Block { constructor(name, parameters, children, sourceSpan, startSourceSpan, endSourceSpan = null) { this.name = name; this.parameters = parameters; this.children = children; this.sourceSpan = sourceSpan; this.startSourceSpan = startSourceSpan; this.endSourceSpan = endSourceSpan; } visit(visitor, context) { return visitor.visitBlock(this, context); } } export class BlockParameter { constructor(expression, sourceSpan) { this.expression = expression; this.sourceSpan = sourceSpan; } visit(visitor, context) { return visitor.visitBlockParameter(this, context); } } export function visitAll(visitor, nodes, context = null) { const result = []; const visit = visitor.visit ? (ast) => visitor.visit(ast, context) || ast.visit(visitor, context) : (ast) => ast.visit(visitor, context); nodes.forEach(ast => { const astResult = visit(ast); if (astResult) { result.push(astResult); } }); return result; } export class RecursiveVisitor { constructor() { } visitElement(ast, context) { this.visitChildren(context, visit => { visit(ast.attrs); visit(ast.children); }); } visitAttribute(ast, context) { } visitText(ast, context) { } visitComment(ast, context) { } visitExpansion(ast, context) { return this.visitChildren(context, visit => { visit(ast.cases); }); } visitExpansionCase(ast, context) { } visitBlockGroup(ast, context) { this.visitChildren(context, visit => { visit(ast.blocks); }); } visitBlock(block, context) { this.visitChildren(context, visit => { visit(block.parameters); visit(block.children); }); } visitBlockParameter(ast, context) { } visitChildren(context, cb) { let results = []; let t = this; function visit(children) { if (children) results.push(visitAll(t, children, context)); } cb(visit); return Array.prototype.concat.apply([], results); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvc3JjL21sX3BhcnNlci9hc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBZUgsTUFBTSxPQUFnQixZQUFZO0lBQ2hDLFlBQW1CLFVBQTJCLEVBQVMsSUFBZTtRQUFuRCxlQUFVLEdBQVYsVUFBVSxDQUFpQjtRQUFTLFNBQUksR0FBSixJQUFJLENBQV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