Skip to content

Commit

Permalink
Default highlightCode:true for the parser highlighting. (#8546)
Browse files Browse the repository at this point in the history
  • Loading branch information
loganfsmyth authored Aug 26, 2018
1 parent edbffda commit e0ee057
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/babel-core/src/transformation/normalize-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,26 @@ export default function normalizeFile(
});
}

function parser(pluginPasses, options, code) {
function parser(
pluginPasses: PluginPasses,
{ parserOpts, highlightCode = true, filename = "unknown" }: Object,
code: string,
) {
try {
const results = [];
for (const plugins of pluginPasses) {
for (const plugin of plugins) {
const { parserOverride } = plugin;
if (parserOverride) {
const ast = parserOverride(code, options.parserOpts, parse);
const ast = parserOverride(code, parserOpts, parse);

if (ast !== undefined) results.push(ast);
}
}
}

if (results.length === 0) {
return parse(code, options.parserOpts);
return parse(code, parserOpts);
} else if (results.length === 1) {
if (typeof results[0].then === "function") {
throw new Error(
Expand Down Expand Up @@ -136,15 +140,16 @@ function parser(pluginPasses, options, code) {
column: loc.column + 1,
},
},
options,
{
highlightCode,
},
);
if (missingPlugin) {
err.message =
`${options.filename || "unknown"}: ` +
`${filename}: ` +
generateMissingPluginMessage(missingPlugin[0], loc, codeFrame);
} else {
err.message =
`${options.filename || "unknown"}: ${err.message}\n\n` + codeFrame;
err.message = `${filename}: ${err.message}\n\n` + codeFrame;
}
err.code = "BABEL_PARSE_ERROR";
}
Expand Down

0 comments on commit e0ee057

Please sign in to comment.