( context: Pick<LspRuntimeContext, "uri" | "rootUri" | "file">, )
| 165 | } |
| 166 | |
| 167 | export function inferWorkspaceKind( |
| 168 | context: Pick<LspRuntimeContext, "uri" | "rootUri" | "file">, |
| 169 | ): WorkspaceKind { |
| 170 | const uri = String(context.rootUri || context.file?.uri || context.uri || ""); |
| 171 | if (!uri) return "unknown"; |
| 172 | |
| 173 | const schemeMatch = /^([a-zA-Z][\w+\-.]*?):/.exec(uri); |
| 174 | const scheme = schemeMatch ? schemeMatch[1].toLowerCase() : null; |
| 175 | |
| 176 | if (!scheme) return uri.startsWith("/") ? "app-private" : "unknown"; |
| 177 | if (scheme === "file") return "app-private"; |
| 178 | if (scheme === "untitled") return "virtual"; |
| 179 | if ( |
| 180 | scheme === "ftp" || |
| 181 | scheme === "sftp" || |
| 182 | scheme === "http" || |
| 183 | scheme === "https" |
| 184 | ) { |
| 185 | return "remote"; |
| 186 | } |
| 187 | if (scheme !== "content") return "unknown"; |
| 188 | |
| 189 | if (/^content:\/\/com\.foxdebug\.acode(?:free)?\.documents\//i.test(uri)) { |
| 190 | return "builtin-alpine"; |
| 191 | } |
| 192 | if (/termux/i.test(uri)) return "termux-saf"; |
| 193 | return "saf"; |
| 194 | } |
| 195 | |
| 196 | export function isBuiltinAlpineAccessible( |
| 197 | context: Pick<LspRuntimeContext, "uri" | "rootUri" | "file">, |
no test coverage detected