safeParseAst() — astro Function Reference
Architecture documentation for the safeParseAst() function in parseAstro.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 92c77695_f5e4_ba84_e352_bad33ff64189["safeParseAst()"] 0fc8da77_17d5_93f4_f8a7_0d74e4ce41d9["parseAstro.ts"] 92c77695_f5e4_ba84_e352_bad33ff64189 -->|defined in| 0fc8da77_17d5_93f4_f8a7_0d74e4ce41d9 b2606d14_70c4_bc93_1789_07a66f3d3311["getAstroMetadata()"] b2606d14_70c4_bc93_1789_07a66f3d3311 -->|calls| 92c77695_f5e4_ba84_e352_bad33ff64189 style 92c77695_f5e4_ba84_e352_bad33ff64189 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/language-server/src/core/parseAstro.ts lines 23–52
function safeParseAst(fileName: string, input: string, parseOptions: ParseOptions): ParseResult {
try {
const parseResult = parse(input, parseOptions);
return parseResult;
} catch (e) {
console.error(
`There was an error parsing ${fileName}'s AST. An empty AST will be returned instead to avoid breaking the server. Please create an issue: https://github.com/withastro/astro/issues\nError: ${e}.`,
);
return {
ast: {
type: 'root',
children: [],
},
diagnostics: [
{
code: 1000,
location: {
file: fileName,
line: 1,
column: 1,
length: input.length,
},
severity: 1,
text: `The Astro compiler encountered an unknown error while parsing this file's AST. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/astro/issues`,
},
],
};
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does safeParseAst() do?
safeParseAst() is a function in the astro codebase, defined in packages/language-tools/language-server/src/core/parseAstro.ts.
Where is safeParseAst() defined?
safeParseAst() is defined in packages/language-tools/language-server/src/core/parseAstro.ts at line 23.
What calls safeParseAst()?
safeParseAst() is called by 1 function(s): getAstroMetadata.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free