From 447fa2fccdb507fe83a34058f2d7faa8421da5bb Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Tue, 1 Oct 2019 12:34:04 +0100 Subject: [PATCH] refactor(compiler): move test helper to test file (#32937) The `processI18nMeta()` function is only called from a single test, so let's move it there to keep the main source simpler. PR Close #32937 --- .../compiler/src/render3/view/i18n/meta.ts | 10 ---------- packages/compiler/test/render3/view/util.ts | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/compiler/src/render3/view/i18n/meta.ts b/packages/compiler/src/render3/view/i18n/meta.ts index 1b14d4b8b8..f0f88e4d03 100644 --- a/packages/compiler/src/render3/view/i18n/meta.ts +++ b/packages/compiler/src/render3/view/i18n/meta.ts @@ -128,16 +128,6 @@ export class I18nMetaVisitor implements html.Visitor { visitExpansionCase(expansionCase: html.ExpansionCase, context: any): any { return expansionCase; } } -export function processI18nMeta( - htmlAstWithErrors: ParseTreeResult, - interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG): ParseTreeResult { - return new ParseTreeResult( - html.visitAll( - new I18nMetaVisitor(interpolationConfig, /* keepI18nAttrs */ false), - htmlAstWithErrors.rootNodes), - htmlAstWithErrors.errors); -} - export function metaFromI18nMessage(message: i18n.Message, id: string | null = null): I18nMeta { return { id: typeof id === 'string' ? id : message.id || '', diff --git a/packages/compiler/test/render3/view/util.ts b/packages/compiler/test/render3/view/util.ts index a347df7ace..df1268fed9 100644 --- a/packages/compiler/test/render3/view/util.ts +++ b/packages/compiler/test/render3/view/util.ts @@ -10,12 +10,12 @@ import * as e from '../../../src/expression_parser/ast'; import {Lexer} from '../../../src/expression_parser/lexer'; import {Parser} from '../../../src/expression_parser/parser'; import * as html from '../../../src/ml_parser/ast'; -import {HtmlParser} from '../../../src/ml_parser/html_parser'; +import {HtmlParser, ParseTreeResult} from '../../../src/ml_parser/html_parser'; import {WhitespaceVisitor} from '../../../src/ml_parser/html_whitespaces'; -import {DEFAULT_INTERPOLATION_CONFIG} from '../../../src/ml_parser/interpolation_config'; +import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../../../src/ml_parser/interpolation_config'; import * as a from '../../../src/render3/r3_ast'; import {Render3ParseResult, htmlAstToRender3Ast} from '../../../src/render3/r3_template_transform'; -import {processI18nMeta} from '../../../src/render3/view/i18n/meta'; +import {I18nMetaVisitor} from '../../../src/render3/view/i18n/meta'; import {BindingParser} from '../../../src/template_parser/binding_parser'; import {MockSchemaRegistry} from '../../../testing'; @@ -102,4 +102,14 @@ export function parseR3( const bindingParser = new BindingParser(expressionParser, DEFAULT_INTERPOLATION_CONFIG, schemaRegistry, null, []); return htmlAstToRender3Ast(htmlNodes, bindingParser); -} \ No newline at end of file +} + +export function processI18nMeta( + htmlAstWithErrors: ParseTreeResult, + interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG): ParseTreeResult { + return new ParseTreeResult( + html.visitAll( + new I18nMetaVisitor(interpolationConfig, /* keepI18nAttrs */ false), + htmlAstWithErrors.rootNodes), + htmlAstWithErrors.errors); +}