MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / normalizeProvider

Function normalizeProvider

src/cm/lsp/runtimeProviders.ts:24–55  ·  view source on GitHub ↗
(
	provider: LspRuntimeProvider,
)

Source from the content-addressed store, hash-verified

22}
23
24function normalizeProvider(
25 provider: LspRuntimeProvider,
26): LspRuntimeProvider {
27 const id = toKey(provider?.id);
28 if (!id) throw new Error("LSP runtime provider requires a non-empty id");
29 if (!provider.label || typeof provider.label !== "string") {
30 throw new Error(`LSP runtime provider ${id} requires a label`);
31 }
32 if (typeof provider.canHandle !== "function") {
33 throw new Error(`LSP runtime provider ${id} requires canHandle()`);
34 }
35 if (typeof provider.start !== "function") {
36 throw new Error(`LSP runtime provider ${id} requires start()`);
37 }
38 for (const method of [
39 "resolveUris",
40 "checkInstallation",
41 "install",
42 "uninstall",
43 "getInstallCommand",
44 "getUninstallCommand",
45 "stop",
46 ] as const) {
47 if (
48 provider[method] !== undefined &&
49 typeof provider[method] !== "function"
50 ) {
51 throw new Error(`LSP runtime provider ${id} has invalid ${method}()`);
52 }
53 }
54 return { ...provider, id };
55}
56
57function getPriority(provider: LspRuntimeProvider): number {
58 const priority = Number(provider.priority);

Callers 1

registerRuntimeProviderFunction · 0.85

Calls 1

toKeyFunction · 0.70

Tested by

no test coverage detected