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

Function getWorkspaceRuntimeOverride

src/cm/lsp/runtimeSettings.ts:24–55  ·  view source on GitHub ↗
(
	settings: RuntimeSettings,
	context: LspRuntimeContext,
)

Source from the content-addressed store, hash-verified

22}
23
24function getWorkspaceRuntimeOverride(
25 settings: RuntimeSettings,
26 context: LspRuntimeContext,
27): string | null {
28 const workspaces = settings.workspaces;
29 if (!workspaces || typeof workspaces !== "object") return null;
30
31 const candidates = [
32 context.rootUri,
33 context.file?.uri,
34 context.uri,
35 context.documentUri,
36 ]
37 .map((uri) => String(uri || ""))
38 .filter(Boolean);
39
40 let bestMatch = "";
41 let bestRuntime: string | null = null;
42 for (const [prefix, runtimeId] of Object.entries(workspaces)) {
43 const normalizedPrefix = String(prefix || "");
44 if (!normalizedPrefix) continue;
45 if (
46 normalizedPrefix.length > bestMatch.length &&
47 candidates.some((uri) => uri.startsWith(normalizedPrefix))
48 ) {
49 bestMatch = normalizedPrefix;
50 bestRuntime = toRuntimeId(runtimeId);
51 }
52 }
53
54 return bestRuntime;
55}
56
57export function getConfiguredRuntimeId(
58 server: LspServerDefinition,

Callers 1

getConfiguredRuntimeIdFunction · 0.85

Calls 2

StringInterface · 0.85
toRuntimeIdFunction · 0.85

Tested by

no test coverage detected