From b507d076be3d50a2a4c071266daabb45a7cc68f5 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 4 Apr 2019 14:04:31 +0200 Subject: [PATCH] refactor(core): move schematic component template visitor to utils (#29713) PR Close #29713 --- .../template-var-assignment/analyze_template.ts | 2 +- .../template-var-assignment/google3/BUILD.bazel | 1 + .../google3/noTemplateVariableAssignmentRule.ts | 2 +- .../migrations/template-var-assignment/index.ts | 2 +- .../angular => utils}/ng_component_template.ts | 8 ++++---- 5 files changed, 8 insertions(+), 7 deletions(-) rename packages/core/schematics/{migrations/template-var-assignment/angular => utils}/ng_component_template.ts (94%) diff --git a/packages/core/schematics/migrations/template-var-assignment/analyze_template.ts b/packages/core/schematics/migrations/template-var-assignment/analyze_template.ts index 36c2cc9b25..77eb53dfbb 100644 --- a/packages/core/schematics/migrations/template-var-assignment/analyze_template.ts +++ b/packages/core/schematics/migrations/template-var-assignment/analyze_template.ts @@ -9,7 +9,7 @@ import {PropertyWrite, parseTemplate} from '@angular/compiler'; import {Variable, visitAll} from '@angular/compiler/src/render3/r3_ast'; -import {ResolvedTemplate} from './angular/ng_component_template'; +import {ResolvedTemplate} from '../../utils/ng_component_template'; import {PropertyAssignment, PropertyWriteHtmlVisitor} from './angular/property_write_html_visitor'; export interface TemplateVariableAssignment { diff --git a/packages/core/schematics/migrations/template-var-assignment/google3/BUILD.bazel b/packages/core/schematics/migrations/template-var-assignment/google3/BUILD.bazel index ff26637f69..83b75a91e6 100644 --- a/packages/core/schematics/migrations/template-var-assignment/google3/BUILD.bazel +++ b/packages/core/schematics/migrations/template-var-assignment/google3/BUILD.bazel @@ -7,6 +7,7 @@ ts_library( visibility = ["//packages/core/schematics/test:__pkg__"], deps = [ "//packages/core/schematics/migrations/template-var-assignment", + "//packages/core/schematics/utils", "//packages/core/schematics/utils/tslint", "@npm//tslint", ], diff --git a/packages/core/schematics/migrations/template-var-assignment/google3/noTemplateVariableAssignmentRule.ts b/packages/core/schematics/migrations/template-var-assignment/google3/noTemplateVariableAssignmentRule.ts index a89e0ea30c..54aa2c53f0 100644 --- a/packages/core/schematics/migrations/template-var-assignment/google3/noTemplateVariableAssignmentRule.ts +++ b/packages/core/schematics/migrations/template-var-assignment/google3/noTemplateVariableAssignmentRule.ts @@ -11,7 +11,7 @@ import * as ts from 'typescript'; import {createHtmlSourceFile} from '../../../utils/tslint/tslint_html_source_file'; import {analyzeResolvedTemplate} from '../analyze_template'; -import {NgComponentTemplateVisitor} from '../angular/ng_component_template'; +import {NgComponentTemplateVisitor} from '../../../utils/ng_component_template'; const FAILURE_MESSAGE = 'Found assignment to template variable. This does not work with Ivy and ' + 'needs to be updated.'; diff --git a/packages/core/schematics/migrations/template-var-assignment/index.ts b/packages/core/schematics/migrations/template-var-assignment/index.ts index d8c520a30a..3bb9f2d81c 100644 --- a/packages/core/schematics/migrations/template-var-assignment/index.ts +++ b/packages/core/schematics/migrations/template-var-assignment/index.ts @@ -15,7 +15,7 @@ import {getProjectTsConfigPaths} from '../../utils/project_tsconfig_paths'; import {parseTsconfigFile} from '../../utils/typescript/parse_tsconfig'; import {analyzeResolvedTemplate} from './analyze_template'; -import {NgComponentTemplateVisitor} from './angular/ng_component_template'; +import {NgComponentTemplateVisitor} from '../../utils/ng_component_template'; type Logger = logging.LoggerApi; diff --git a/packages/core/schematics/migrations/template-var-assignment/angular/ng_component_template.ts b/packages/core/schematics/utils/ng_component_template.ts similarity index 94% rename from packages/core/schematics/migrations/template-var-assignment/angular/ng_component_template.ts rename to packages/core/schematics/utils/ng_component_template.ts index 0296ed238f..7c070f76ff 100644 --- a/packages/core/schematics/migrations/template-var-assignment/angular/ng_component_template.ts +++ b/packages/core/schematics/utils/ng_component_template.ts @@ -10,10 +10,10 @@ import {existsSync, readFileSync} from 'fs'; import {dirname, resolve} from 'path'; import * as ts from 'typescript'; -import {computeLineStartsMap, getLineAndCharacterFromPosition} from '../../../utils/line_mappings'; -import {getAngularDecorators} from '../../../utils/ng_decorators'; -import {unwrapExpression} from '../../../utils/typescript/functions'; -import {getPropertyNameText} from '../../../utils/typescript/property_name'; +import {computeLineStartsMap, getLineAndCharacterFromPosition} from './line_mappings'; +import {getAngularDecorators} from './ng_decorators'; +import {unwrapExpression} from './typescript/functions'; +import {getPropertyNameText} from './typescript/property_name'; export interface ResolvedTemplate { /** File content of the given template. */