MCPcopy Index your code
hub / github.com/anomalyco/opencode / schedule

Function schedule

packages/opencode/src/lsp/lsp.ts:217–252  ·  view source on GitHub ↗
(server: LSPServer.Info, root: string, key: string)

Source from the content-addressed store, hash-verified

215 let updated = 0
216
217 async function schedule(server: LSPServer.Info, root: string, key: string) {
218 const handle = await server
219 .spawn(root, ctx, flags)
220 .then((value) => {
221 if (!value) s.broken.add(key)
222 return value
223 })
224 .catch(() => {
225 s.broken.add(key)
226 return undefined
227 })
228
229 if (!handle) return undefined
230 const client = await LSPClient.create({
231 serverID: server.id,
232 server: handle,
233 root,
234 directory: ctx.directory,
235 instance: ctx,
236 }).catch(async () => {
237 s.broken.add(key)
238 await Process.stop(handle.process)
239 return undefined
240 })
241
242 if (!client) return undefined
243
244 const existing = s.clients.find((x) => x.root === root && x.serverID === server.id)
245 if (existing) {
246 await Process.stop(handle.process)
247 return existing
248 }
249
250 s.clients.push(client)
251 return client
252 }
253
254 for (const server of Object.values(s.servers)) {
255 if (server.extensions.length && !server.extensions.includes(extension)) continue

Callers 1

lsp.tsFile · 0.70

Calls 6

spawnMethod · 0.80
pushMethod · 0.80
addMethod · 0.65
createMethod · 0.65
findMethod · 0.65
stopMethod · 0.45

Tested by

no test coverage detected