Normalize instance lifecycle wiring (#25501)
This commit is contained in:
@@ -5,6 +5,7 @@ import { tmpdir } from "../fixture/fixture"
|
||||
import { LSPClient } from "@/lsp/client"
|
||||
import * as LSPServer from "@/lsp/server"
|
||||
import { Instance } from "../../src/project/instance"
|
||||
import { WithInstance } from "../../src/project/with-instance"
|
||||
import * as Log from "@opencode-ai/core/util/log"
|
||||
|
||||
function spawnFakeServer() {
|
||||
@@ -25,7 +26,7 @@ describe("LSPClient interop", () => {
|
||||
test("handles workspace/workspaceFolders request", async () => {
|
||||
const handle = spawnFakeServer() as any
|
||||
|
||||
const client = await Instance.provide({
|
||||
const client = await WithInstance.provide({
|
||||
directory: process.cwd(),
|
||||
fn: () =>
|
||||
LSPClient.create({
|
||||
@@ -48,7 +49,7 @@ describe("LSPClient interop", () => {
|
||||
test("handles client/registerCapability request", async () => {
|
||||
const handle = spawnFakeServer() as any
|
||||
|
||||
const client = await Instance.provide({
|
||||
const client = await WithInstance.provide({
|
||||
directory: process.cwd(),
|
||||
fn: () =>
|
||||
LSPClient.create({
|
||||
@@ -71,7 +72,7 @@ describe("LSPClient interop", () => {
|
||||
test("handles client/unregisterCapability request", async () => {
|
||||
const handle = spawnFakeServer() as any
|
||||
|
||||
const client = await Instance.provide({
|
||||
const client = await WithInstance.provide({
|
||||
directory: process.cwd(),
|
||||
fn: () =>
|
||||
LSPClient.create({
|
||||
@@ -94,7 +95,7 @@ describe("LSPClient interop", () => {
|
||||
test("initialize does not overclaim unsupported diagnostics capabilities", async () => {
|
||||
const handle = spawnFakeServer() as any
|
||||
|
||||
const client = await Instance.provide({
|
||||
const client = await WithInstance.provide({
|
||||
directory: process.cwd(),
|
||||
fn: () =>
|
||||
LSPClient.create({
|
||||
@@ -121,7 +122,7 @@ describe("LSPClient interop", () => {
|
||||
gamma: true,
|
||||
}
|
||||
|
||||
const client = await Instance.provide({
|
||||
const client = await WithInstance.provide({
|
||||
directory: process.cwd(),
|
||||
fn: () =>
|
||||
LSPClient.create({
|
||||
@@ -150,7 +151,7 @@ describe("LSPClient interop", () => {
|
||||
const file = path.join(tmp.path, "client.ts")
|
||||
await Bun.write(file, "first\n")
|
||||
|
||||
await Instance.provide({
|
||||
await WithInstance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const client = await LSPClient.create({
|
||||
@@ -193,7 +194,7 @@ describe("LSPClient interop", () => {
|
||||
const file = path.join(tmp.path, "client.ts")
|
||||
await Bun.write(file, "const x = 1\n")
|
||||
|
||||
await Instance.provide({
|
||||
await WithInstance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const client = await LSPClient.create({
|
||||
@@ -239,7 +240,7 @@ describe("LSPClient interop", () => {
|
||||
const file = path.join(tmp.path, "client.ts")
|
||||
await Bun.write(file, "const x = 1\n")
|
||||
|
||||
await Instance.provide({
|
||||
await WithInstance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const client = await LSPClient.create({
|
||||
@@ -286,7 +287,7 @@ describe("LSPClient interop", () => {
|
||||
const file = path.join(tmp.path, "client.cs")
|
||||
await Bun.write(file, "class C {}\n")
|
||||
|
||||
await Instance.provide({
|
||||
await WithInstance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const client = await LSPClient.create({
|
||||
@@ -334,7 +335,7 @@ describe("LSPClient interop", () => {
|
||||
const file = path.join(tmp.path, "client.cs")
|
||||
await Bun.write(file, "class C {}\n")
|
||||
|
||||
await Instance.provide({
|
||||
await WithInstance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const client = await LSPClient.create({
|
||||
@@ -387,7 +388,7 @@ describe("LSPClient interop", () => {
|
||||
await Bun.write(file, "class C {}\n")
|
||||
await Bun.write(related, "class D {}\n")
|
||||
|
||||
await Instance.provide({
|
||||
await WithInstance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const client = await LSPClient.create({
|
||||
@@ -451,7 +452,7 @@ describe("LSPClient interop", () => {
|
||||
const file = path.join(tmp.path, "client.cs")
|
||||
await Bun.write(file, "class C {}\n")
|
||||
|
||||
await Instance.provide({
|
||||
await WithInstance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const client = await LSPClient.create({
|
||||
|
||||
Reference in New Issue
Block a user