MCPcopy Index your code
hub / github.com/prettier/prettier / parse

Function parse

src/main/parse.js:4–25  ·  view source on GitHub ↗
(originalText, options)

Source from the content-addressed store, hash-verified

2import { resolveParser } from "./parser-and-printer.js";
3
4async function parse(originalText, options) {
5 const parser = await resolveParser(options);
6 const text = parser.preprocess
7 ? await parser.preprocess(originalText, options)
8 : originalText;
9 options.originalText = text;
10
11 let ast;
12 try {
13 ast = await parser.parse(
14 text,
15 options,
16 // TODO: remove the third argument in v4
17 // The duplicated argument is passed as intended, see #10156
18 options,
19 );
20 } catch (error) {
21 handleParseError(error, originalText);
22 }
23
24 return { text, ast };
25}
26
27function handleParseError(error, text) {
28 const { loc } = error;

Callers

nothing calls this directly

Calls 3

resolveParserFunction · 0.90
handleParseErrorFunction · 0.85
preprocessMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…