* Gets the language parser for a given URI using the modelist
(uri)
| 131 | * Gets the language parser for a given URI using the modelist |
| 132 | */ |
| 133 | async function getLanguageParser(uri) { |
| 134 | const mode = getModeForPath(uri); |
| 135 | if (!mode?.languageExtension) return null; |
| 136 | |
| 137 | try { |
| 138 | const langExt = await mode.languageExtension(); |
| 139 | if (!langExt) return null; |
| 140 | |
| 141 | const langArray = Array.isArray(langExt) ? langExt : [langExt]; |
| 142 | for (const ext of langArray) { |
| 143 | if (ext && typeof ext === "object" && "language" in ext) { |
| 144 | return ext.language.parser; |
| 145 | } |
| 146 | } |
| 147 | } catch (e) { |
| 148 | console.warn("Failed to get language parser for", uri, e); |
| 149 | } |
| 150 | return null; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Gets language parser by language name (e.g., "javascript", "python") |
no test coverage detected