From d44489c610f2d7699f7b7dd6e941437660c5419c Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Fri, 2 Aug 2024 20:38:37 +0800 Subject: [PATCH] Sort functions --- .../lib/codegen/template/index.ts | 80 +++++++++---------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/packages/language-core/lib/codegen/template/index.ts b/packages/language-core/lib/codegen/template/index.ts index 32473d8774..c78716c3b3 100644 --- a/packages/language-core/lib/codegen/template/index.ts +++ b/packages/language-core/lib/codegen/template/index.ts @@ -78,47 +78,6 @@ export function* generateTemplate(options: TemplateCodegenOptions): Generator { - let count = 0; - - const currentEscapeTargets = [...escapeTargets]; - - const firstEscapeTarget = currentEscapeTargets.shift()!; - - const splitted = className.split(firstEscapeTarget); - - for (let i = 0; i < splitted.length; i++) { - const part = splitted[i]; - const partLength = part.length; - - if (escapeTargets.length > 0) { - yield* escapeString(part, offset + count, [...currentEscapeTargets]); - } else { - yield [ - part, - 'template', - offset + count, - ctx.codeFeatures.navigationAndAdditionalCompletion, - ]; - } - - if (i !== splitted.length - 1) { - yield '\\'; - - yield [ - firstEscapeTarget, - 'template', - offset + count + partLength, - ctx.codeFeatures.navigationAndAdditionalCompletion, - ]; - - count += partLength + 1; - } else { - count += partLength; - } - } - } - function* generateStyleScopedClasses(): Generator { yield `if (typeof __VLS_styleScopedClasses === 'object' && !Array.isArray(__VLS_styleScopedClasses)) {${newLine}`; for (const offset of ctx.emptyClassOffsets) { @@ -174,6 +133,45 @@ export function* generateTemplate(options: TemplateCodegenOptions): Generator { + let count = 0; + + const currentEscapeTargets = [...escapeTargets]; + const firstEscapeTarget = currentEscapeTargets.shift()!; + const splitted = className.split(firstEscapeTarget); + + for (let i = 0; i < splitted.length; i++) { + const part = splitted[i]; + const partLength = part.length; + + if (escapeTargets.length > 0) { + yield* escapeString(part, offset + count, [...currentEscapeTargets]); + } else { + yield [ + part, + 'template', + offset + count, + ctx.codeFeatures.navigationAndAdditionalCompletion, + ]; + } + + if (i !== splitted.length - 1) { + yield '\\'; + + yield [ + firstEscapeTarget, + 'template', + offset + count + partLength, + ctx.codeFeatures.navigationAndAdditionalCompletion, + ]; + + count += partLength + 1; + } else { + count += partLength; + } + } + } } export function* forEachElementNode(node: CompilerDOM.RootNode | CompilerDOM.TemplateChildNode): Generator {