MCPcopy
hub / github.com/webpack/webpack / internalParse

Method internalParse

lib/javascript/JavascriptParser.js:5867–5893  ·  view source on GitHub ↗
(code, options)

Source from the content-addressed store, hash-verified

5865 * @returns {ParseResult} parse result
5866 */
5867 const internalParse = (code, options) => {
5868 if (typeof customParse === "function") {
5869 return customParse(code, options);
5870 }
5871
5872 /** @type {Comment[]} */
5873 const comments = [];
5874
5875 if (options.comments) {
5876 /** @type {AcornOptions} */
5877 (options).onComment = comments;
5878 }
5879
5880 /** @type {Set<number>} */
5881 const semicolons = new Set();
5882
5883 if (options.semicolons) {
5884 /** @type {AcornOptions} */
5885 (options).onInsertedSemicolon = (pos) => semicolons.add(pos);
5886 }
5887
5888 const ast =
5889 /** @type {Program} */
5890 (parser.parse(code, /** @type {AcornOptions} */ (options)));
5891
5892 return { ast, comments, semicolons };
5893 };
5894
5895 /** @type {Program | undefined} */
5896 let ast;

Callers

nothing calls this directly

Calls 2

addMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected