Change handlebars preprocess to postprocess (#8644)
This commit is contained in:
1 parent
35ac6f0752
commit
8ea2d91f1d
3 files changed
+12
-12
No files matched your search
@@ -1,11 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
const createError = require("../common/parser-create-error");
|
||||
const postprocess = require("./postprocess");
|
||||
|
||||
function parse(text) {
|
||||
function parse(text, parsers, options) {
|
||||
const { preprocess: glimmer, traverse } = require("@glimmer/syntax");
|
||||
let ast;
|
||||
try {
|
||||
const glimmer = require("@glimmer/syntax").preprocess;
|
||||
return glimmer(text, { mode: "codemod" });
|
||||
ast = glimmer(text, { mode: "codemod" });
|
||||
/* istanbul ignore next */
|
||||
} catch (error) {
|
||||
const matches = error.message.match(/on line (\d+)/);
|
||||
@@ -17,6 +19,8 @@ function parse(text) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return postprocess(ast, options, traverse);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const transform = require("@glimmer/syntax").traverse;
|
||||
|
||||
const PREPROCESS_PIPELINE = [addBackslash];
|
||||
const PIPELINE = [addBackslash];
|
||||
|
||||
/* VISITORS */
|
||||
|
||||
@@ -22,13 +20,13 @@ function addBackslash(/* options*/) {
|
||||
};
|
||||
}
|
||||
|
||||
function preprocess(ast, options) {
|
||||
for (const fn of PREPROCESS_PIPELINE) {
|
||||
function postprocess(ast, options, traverse) {
|
||||
for (const fn of PIPELINE) {
|
||||
const visitor = fn(options);
|
||||
transform(ast, visitor);
|
||||
traverse(ast, visitor);
|
||||
}
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
module.exports = preprocess;
|
||||
module.exports = postprocess;
|
||||
@@ -12,7 +12,6 @@ const {
|
||||
} = require("../document").builders;
|
||||
|
||||
const clean = require("./clean");
|
||||
const preprocess = require("./preprocess");
|
||||
const {
|
||||
getNextNode,
|
||||
getPreviousNode,
|
||||
@@ -676,5 +675,4 @@ function doesNotHavePositionalParams(node) {
|
||||
module.exports = {
|
||||
print,
|
||||
massageAstNode: clean,
|
||||
preprocess,
|
||||
};
|
||||
Reference in new issue
Block a user