/** * @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 */ (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define("@angular/compiler/src/ml_parser/ast", ["require", "exports", "tslib", "@angular/compiler/src/ast_path"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findNode = exports.RecursiveVisitor = exports.visitAll = exports.Comment = exports.Element = exports.Attribute = exports.ExpansionCase = exports.Expansion = exports.Text = exports.NodeWithI18n = void 0; var tslib_1 = require("tslib"); var ast_path_1 = require("@angular/compiler/src/ast_path"); var NodeWithI18n = /** @class */ (function () { function NodeWithI18n(sourceSpan, i18n) { this.sourceSpan = sourceSpan; this.i18n = i18n; } return NodeWithI18n; }()); exports.NodeWithI18n = NodeWithI18n; var Text = /** @class */ (function (_super) { tslib_1.__extends(Text, _super); function Text(value, sourceSpan, tokens, i18n) { var _this = _super.call(this, sourceSpan, i18n) || this; _this.value = value; _this.tokens = tokens; return _this; } Text.prototype.visit = function (visitor, context) { return visitor.visitText(this, context); }; return Text; }(NodeWithI18n)); exports.Text = Text; var Expansion = /** @class */ (function (_super) { tslib_1.__extends(Expansion, _super); function Expansion(switchValue, type, cases, sourceSpan, switchValueSourceSpan, i18n) { var _this = _super.call(this, sourceSpan, i18n) || this; _this.switchValue = switchValue; _this.type = type; _this.cases = cases; _this.switchValueSourceSpan = switchValueSourceSpan; return _this; } Expansion.prototype.visit = function (visitor, context) { return visitor.visitExpansion(this, context); }; return Expansion; }(NodeWithI18n)); exports.Expansion = Expansion; var ExpansionCase = /** @class */ (function () { function ExpansionCase(value, expression, sourceSpan, valueSourceSpan, expSourceSpan) { this.value = value; this.expression = expression; this.sourceSpan = sourceSpan; this.valueSourceSpan = valueSourceSpan; this.expSourceSpan = expSourceSpan; } ExpansionCase.prototype.visit = function (visitor, context) { return visitor.visitExpansionCase(this, context); }; return ExpansionCase; }()); exports.ExpansionCase = ExpansionCase; var Attribute = /** @class */ (function (_super) { tslib_1.__extends(Attribute, _super); function Attribute(name, value, sourceSpan, keySpan, valueSpan, valueTokens, i18n) { var _this = _super.call(this, sourceSpan, i18n) || this; _this.name = name; _this.value = value; _this.keySpan = keySpan; _this.valueSpan = valueSpan; _this.valueTokens = valueTokens; return _this; } Attribute.prototype.visit = function (visitor, context) { return visitor.visitAttribute(this, context); }; return Attribute; }(NodeWithI18n)); exports.Attribute = Attribute; var Element = /** @class */ (function (_super) { tslib_1.__extends(Element, _super); function Element(name, attrs, children, sourceSpan, startSourceSpan, endSourceSpan, i18n) { if (endSourceSpan === void 0) { endSourceSpan = null; } var _this = _super.call(this, sourceSpan, i18n) || this; _this.name = name; _this.attrs = attrs; _this.children = children; _this.startSourceSpan = startSourceSpan; _this.endSourceSpan = endSourceSpan; return _this; } Element.prototype.visit = function (visitor, context) { return visitor.visitElement(this, context); }; return Element; }(NodeWithI18n)); exports.Element = Element; var Comment = /** @class */ (function () { function Comment(value, sourceSpan) { this.value = value; this.sourceSpan = sourceSpan; } Comment.prototype.visit = function (visitor, context) { return visitor.visitComment(this, context); }; return Comment; }()); exports.Comment = Comment; function visitAll(visitor, nodes, context) { if (context === void 0) { context = null; } var result = []; var visit = visitor.visit ? function (ast) { return visitor.visit(ast, context) || ast.visit(visitor, context); } : function (ast) { return ast.visit(visitor, context); }; nodes.forEach(function (ast) { var astResult = visit(ast); if (astResult) { result.push(astResult); } }); return result; } exports.visitAll = visitAll; var RecursiveVisitor = /** @class */ (function () { function RecursiveVisitor() { } RecursiveVisitor.prototype.visitElement = function (ast, context) { this.visitChildren(context, function (visit) { visit(ast.attrs); visit(ast.children); }); }; RecursiveVisitor.prototype.visitAttribute = function (ast, context) { }; RecursiveVisitor.prototype.visitText = function (ast, context) { }; RecursiveVisitor.prototype.visitComment = function (ast, context) { }; RecursiveVisitor.prototype.visitExpansion = function (ast, context) { return this.visitChildren(context, function (visit) { visit(ast.cases); }); }; RecursiveVisitor.prototype.visitExpansionCase = function (ast, context) { }; RecursiveVisitor.prototype.visitChildren = function (context, cb) { var results = []; var t = this; function visit(children) { if (children) results.push(visitAll(t, children, context)); } cb(visit); return Array.prototype.concat.apply([], results); }; return RecursiveVisitor; }()); exports.RecursiveVisitor = RecursiveVisitor; function spanOf(ast) { var start = ast.sourceSpan.start.offset; var end = ast.sourceSpan.end.offset; if (ast instanceof Element) { if (ast.endSourceSpan) { end = ast.endSourceSpan.end.offset; } else if (ast.children && ast.children.length) { end = spanOf(ast.children[ast.children.length - 1]).end; } } return { start: start, end: end }; } function findNode(nodes, position) { var path = []; var visitor = new /** @class */ (function (_super) { tslib_1.__extends(class_1, _super); function class_1() { return _super !== null && _super.apply(this, arguments) || this; } class_1.prototype.visit = function (ast, context) { var span = spanOf(ast); if (span.start <= position && position < span.end) { path.push(ast); } else { // Returning a value here will result in the children being skipped. return true; } }; return class_1; }(RecursiveVisitor)); visitAll(visitor, nodes); return new ast_path_1.AstPath(path, position); } exports.findNode = findNode; }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvc3JjL21sX3BhcnNlci9hc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOzs7Ozs7Ozs7Ozs7OztJQUVILDJEQUFvQztJQVlwQztRQUNFLHNCQUFtQixVQUEyQixFQUFTLElBQWU7WUFBbkQsZUFBVSxHQUFWLFVBQVUsQ0FBaUI7WUFBUyxTQUFJLEdBQUosSUFBSSxDQUFXO1FBQUcsQ0FBQztRQUU1RSxtQkFBQztJQUFELENBQUMsQUFIRCxJQUdDO0lBSHFCLG9DQUFZO0lBS2xDO1FBQTBCLGdDQUFZO1FBQ3BDLGNBQ1cs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