Default highlightCode:true for the parser highlighting. (#8546)
This commit is contained in:
parent
edbffda091
commit
e0ee0570be
@ -91,14 +91,18 @@ export default function normalizeFile(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function parser(pluginPasses, options, code) {
|
function parser(
|
||||||
|
pluginPasses: PluginPasses,
|
||||||
|
{ parserOpts, highlightCode = true, filename = "unknown" }: Object,
|
||||||
|
code: string,
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const plugins of pluginPasses) {
|
for (const plugins of pluginPasses) {
|
||||||
for (const plugin of plugins) {
|
for (const plugin of plugins) {
|
||||||
const { parserOverride } = plugin;
|
const { parserOverride } = plugin;
|
||||||
if (parserOverride) {
|
if (parserOverride) {
|
||||||
const ast = parserOverride(code, options.parserOpts, parse);
|
const ast = parserOverride(code, parserOpts, parse);
|
||||||
|
|
||||||
if (ast !== undefined) results.push(ast);
|
if (ast !== undefined) results.push(ast);
|
||||||
}
|
}
|
||||||
@ -106,7 +110,7 @@ function parser(pluginPasses, options, code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (results.length === 0) {
|
if (results.length === 0) {
|
||||||
return parse(code, options.parserOpts);
|
return parse(code, parserOpts);
|
||||||
} else if (results.length === 1) {
|
} else if (results.length === 1) {
|
||||||
if (typeof results[0].then === "function") {
|
if (typeof results[0].then === "function") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -136,15 +140,16 @@ function parser(pluginPasses, options, code) {
|
|||||||
column: loc.column + 1,
|
column: loc.column + 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options,
|
{
|
||||||
|
highlightCode,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (missingPlugin) {
|
if (missingPlugin) {
|
||||||
err.message =
|
err.message =
|
||||||
`${options.filename || "unknown"}: ` +
|
`${filename}: ` +
|
||||||
generateMissingPluginMessage(missingPlugin[0], loc, codeFrame);
|
generateMissingPluginMessage(missingPlugin[0], loc, codeFrame);
|
||||||
} else {
|
} else {
|
||||||
err.message =
|
err.message = `${filename}: ${err.message}\n\n` + codeFrame;
|
||||||
`${options.filename || "unknown"}: ${err.message}\n\n` + codeFrame;
|
|
||||||
}
|
}
|
||||||
err.code = "BABEL_PARSE_ERROR";
|
err.code = "BABEL_PARSE_ERROR";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user