Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Entities are never transformed in codemod mode. #1284

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/@glimmer/syntax/lib/parser/tokenizer-event-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,17 @@ const syntax: Syntax = {
Walker,
};

class CodemodEntityParser extends EntityParser {
// match upstream types, but never match an entity
constructor() {
super({});
}

parse(): string | undefined {
return undefined;
}
}

export function preprocess(
input: string | Source | HBS.Program,
options: PreprocessOptions = {}
Expand Down Expand Up @@ -412,7 +423,7 @@ export function preprocess(

let entityParser = undefined;
if (mode === 'codemod') {
entityParser = new EntityParser({});
entityParser = new CodemodEntityParser();
}

let offsets = SourceSpan.forCharPositions(source, 0, source.source.length);
Expand Down
2 changes: 2 additions & 0 deletions packages/@glimmer/syntax/test/generation/print-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ QUnit.module('[glimmer-syntax] Code generation - source -> source', function ()

// "stand alone"
' {{#foo}}\n {{bar}}\n {{/foo}}',

`<span class="stampFont" style="font-family: 'stampfont'">&#xf000;</span>`,
].forEach(buildTest);
});

Expand Down