1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/core/schematics/migrations/template-var-assignment/analyze_template", ["require", "exports", "@angular/compiler/src/render3/r3_ast", "@angular/core/schematics/utils/parse_html", "@angular/core/schematics/migrations/template-var-assignment/angular/html_variable_assignment_visitor"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.analyzeResolvedTemplate = void 0;
|
---|
20 | const r3_ast_1 = require("@angular/compiler/src/render3/r3_ast");
|
---|
21 | const parse_html_1 = require("@angular/core/schematics/utils/parse_html");
|
---|
22 | const html_variable_assignment_visitor_1 = require("@angular/core/schematics/migrations/template-var-assignment/angular/html_variable_assignment_visitor");
|
---|
23 | /**
|
---|
24 | * Analyzes a given resolved template by looking for property assignments to local
|
---|
25 | * template variables within bound events.
|
---|
26 | */
|
---|
27 | function analyzeResolvedTemplate(template) {
|
---|
28 | const templateNodes = parse_html_1.parseHtmlGracefully(template.content, template.filePath);
|
---|
29 | if (!templateNodes) {
|
---|
30 | return null;
|
---|
31 | }
|
---|
32 | const visitor = new html_variable_assignment_visitor_1.HtmlVariableAssignmentVisitor();
|
---|
33 | // Analyze the Angular Render3 HTML AST and collect all template variable assignments.
|
---|
34 | r3_ast_1.visitAll(visitor, templateNodes);
|
---|
35 | return visitor.variableAssignments.map(({ node, start, end }) => ({ node, start: start + node.span.start, end }));
|
---|
36 | }
|
---|
37 | exports.analyzeResolvedTemplate = analyzeResolvedTem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