(filepath: string)
| 119 | }; |
| 120 | |
| 121 | export async function getParserForFile(filepath: string) { |
| 122 | try { |
| 123 | await Parser.init(); |
| 124 | const parser = new Parser(); |
| 125 | |
| 126 | const language = await getLanguageForFile(filepath); |
| 127 | if (!language) { |
| 128 | return undefined; |
| 129 | } |
| 130 | |
| 131 | parser.setLanguage(language); |
| 132 | |
| 133 | return parser; |
| 134 | } catch (e) { |
| 135 | console.debug("Unable to load language for file", filepath, e); |
| 136 | return undefined; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | // Loading the wasm files to create a Language object is an expensive operation and with |
| 141 | // sufficient number of files can result in errors, instead keep a map of language name |
no test coverage detected