diff --git a/client/src/commands/lspCommands.ts b/client/src/commands/lspCommands.ts index 5f08e92e..cfcf3ccb 100644 --- a/client/src/commands/lspCommands.ts +++ b/client/src/commands/lspCommands.ts @@ -3,14 +3,6 @@ import { LanguageClient } from 'vscode-languageclient/node' import { EventEmitter } from 'events' import * as jobs from '../protocol/requests' -/** - * Request that the server should disconnect. Returns promise that will resolve when the server has been reconnected. - * Used for testing purposes. - */ -export function simulateDisconnect(client: LanguageClient) { - return () => client.sendNotification(jobs.Request.apiDisconnect) -} - export function makeHandleRunJob(client: LanguageClient, request: jobs.Request) { return function handler() { client.sendNotification(request) diff --git a/client/src/extension.ts b/client/src/extension.ts index 3e7fd5d3..747573cf 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -17,7 +17,7 @@ import { setupProjectWatchers, setupSingleFileTracking, disposeWatchers } from ' import { startSession } from './lsp/session' import { getUserConfiguration, getCheckCount } from './lsp/notifications' -import { simulateDisconnect, showAst, allJobsFinished } from './commands/lspCommands' +import { showAst, allJobsFinished } from './commands/lspCommands' import { runMain, cmdInit, @@ -114,7 +114,6 @@ export async function activate(context: vscode.ExtensionContext, launchOptions: // Register commands for command palette registerCommand('flix.internalRestart', makeHandleRestartClient(context, { shouldUpdateFlix: false })) registerCommand('flix.internalDownloadLatest', makeHandleRestartClient(context, { shouldUpdateFlix: true })) - registerCommand('flix.simulateDisconnect', simulateDisconnect(client)) registerCommand('flix.runMain', runMain(context, launchOptions)) registerCommand('flix.cmdInit', cmdInit(context, launchOptions)) diff --git a/client/src/protocol/requests.ts b/client/src/protocol/requests.ts index 5f10b869..d1ebe540 100644 --- a/client/src/protocol/requests.ts +++ b/client/src/protocol/requests.ts @@ -32,7 +32,6 @@ export enum Request { apiRemJar = 'api/remJar', apiVersion = 'api/version', apiShutdown = 'api/shutdown', - apiDisconnect = 'api/disconnect', lspCheck = 'lsp/check', lspCodelens = 'lsp/codelens', diff --git a/server/src/engine/jobs.ts b/server/src/engine/jobs.ts index cd424316..2a9314a2 100644 --- a/server/src/engine/jobs.ts +++ b/server/src/engine/jobs.ts @@ -32,7 +32,6 @@ export enum Request { apiRemJar = 'api/remJar', apiVersion = 'api/version', apiShutdown = 'api/shutdown', - apiDisconnect = 'api/disconnect', lspCheck = 'lsp/check', lspCodelens = 'lsp/codelens', diff --git a/server/src/handlers/lifecycle.ts b/server/src/handlers/lifecycle.ts index d1eacb8d..6687a4d2 100644 --- a/server/src/handlers/lifecycle.ts +++ b/server/src/handlers/lifecycle.ts @@ -113,15 +113,6 @@ export function handleExit() { engine.stop() } -/** - * Simulates the compiler disconnecting. - * Used for testing. - */ -export function handleDisconnect() { - const expectResponse = false - socket.sendMessage({ id: 'disconnect', request: jobs.Request.apiDisconnect }, expectResponse) -} - /** * Request a response to be sent when all jobs are finished. */ diff --git a/server/src/server.ts b/server/src/server.ts index 134633a1..d35455bd 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -19,8 +19,6 @@ connection.onInitialize(handlers.handleInitialize) // The user has changed something in the configuration connection.onNotification(jobs.Request.internalReplaceConfiguration, handlers.handleReplaceConfiguration) -connection.onNotification(jobs.Request.apiDisconnect, handlers.handleDisconnect) - // Event happens once after either startup or a restart - starts the engine connection.onNotification(jobs.Request.internalReady, handlers.handleReady) diff --git a/test/src/disconnect.test.ts b/test/src/disconnect.test.ts deleted file mode 100644 index c3009840..00000000 --- a/test/src/disconnect.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2024 Holger Dal Mogensen - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as assert from 'assert' -import * as vscode from 'vscode' -import { init, getTestDocUri, sleep } from './util' - -suite('Server disconnect', () => { - suiteSetup(async () => { - await init('disconnect') - }) - - test('Should reconnect automatically when server is disconnected', async () => { - for (let i = 0; i < 3; i++) { - await vscode.commands.executeCommand('flix.simulateDisconnect') - - // Wait for the server to disconnect, otherwise the next command will hang - await sleep(1000) - - // Ensure that the server is reconnected - const docUri = getTestDocUri('src/Main.flix') - const position = new vscode.Position(9, 12) - const r = await vscode.commands.executeCommand('vscode.executeHoverProvider', docUri, position) - const contents = r[0].contents[0] as vscode.MarkdownString - assert.strictEqual(contents.value.includes('Type'), true) - } - }) -}) diff --git a/test/src/implementation.test.ts b/test/src/implementation.test.ts index 6220107a..73d20cb2 100644 --- a/test/src/implementation.test.ts +++ b/test/src/implementation.test.ts @@ -16,7 +16,7 @@ import * as assert from 'assert' import * as vscode from 'vscode' -import { getTestDocUri, init, normalizeLocation } from './util' +import { getTestDocUri, init } from './util' suite('ImplementationProvider', () => { const dividableDocUri = getTestDocUri('src/Dividable.flix') @@ -34,22 +34,4 @@ suite('ImplementationProvider', () => { ) assert.deepStrictEqual(r, []) }) - - async function testImplementations(uri: vscode.Uri, position: vscode.Position, expectedLocations: vscode.Location[]) { - const r = await vscode.commands.executeCommand<(vscode.Location | vscode.LocationLink)[]>( - 'vscode.executeImplementationProvider', - uri, - position, - ) - - const actualLocations = r.map(normalizeLocation) - - assert.deepStrictEqual(new Set(actualLocations), new Set(expectedLocations)) - } - - test.skip('Should find Dividable trait implementation', async () => { - await testImplementations(dividableDocUri, new vscode.Position(1, 6), [ - new vscode.Location(dividableDocUri, new vscode.Range(5, 9, 5, 18)), - ]) - }) }) diff --git a/test/src/rename.test.ts b/test/src/rename.test.ts index 80156b3e..8b68b463 100644 --- a/test/src/rename.test.ts +++ b/test/src/rename.test.ts @@ -37,18 +37,6 @@ suite('RenameProvider', () => { assert.strictEqual(ranges.length, 2) }) - test.skip('Should rename function', async () => { - const position = await findMarkerPosition(mainDocUri, 'area1') - const ranges = await testRename(mainDocUri, position) - assert.strictEqual(ranges.length, 2) - }) - - test.skip('Should rename function-use', async () => { - const position = await findMarkerPosition(mainDocUri, 'area2') - const ranges = await testRename(mainDocUri, position) - assert.strictEqual(ranges.length, 2) - }) - async function testRename(uri: vscode.Uri, position: vscode.Position): Promise { await open(uri) const newName = 'NewName' diff --git a/test/testWorkspaces/disconnect/flix.toml b/test/testWorkspaces/disconnect/flix.toml deleted file mode 100644 index 16cfc76b..00000000 --- a/test/testWorkspaces/disconnect/flix.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "vscode-flix-test" -description = "test" -version = "0.1.0" -flix = "0.44.0" -authors = ["John Doe "] diff --git a/test/testWorkspaces/disconnect/src/Area.flix b/test/testWorkspaces/disconnect/src/Area.flix deleted file mode 100644 index 36232a80..00000000 --- a/test/testWorkspaces/disconnect/src/Area.flix +++ /dev/null @@ -1,13 +0,0 @@ -// Blank line -/// Computes the area of the given shape using -/// pattern matching and basic arithmetic. -def area(s: Shape): Int32 = { - match s { - case Shape.Circle(r) => 3 * r * r - case Shape.Square(w) => w * w - case Shape.Rectangle(h, w) => h * w - } -} - - -def testSquareArea(): Bool = Assert.eq(area(Shape.Square(5)), 25) diff --git a/test/testWorkspaces/disconnect/src/Assert.flix b/test/testWorkspaces/disconnect/src/Assert.flix deleted file mode 100644 index 1962b5d9..00000000 --- a/test/testWorkspaces/disconnect/src/Assert.flix +++ /dev/null @@ -1,3 +0,0 @@ -mod Assert { - pub def eq(_: t, _: t): Bool = true -} diff --git a/test/testWorkspaces/disconnect/src/Main.flix b/test/testWorkspaces/disconnect/src/Main.flix deleted file mode 100644 index 9d926bf3..00000000 --- a/test/testWorkspaces/disconnect/src/Main.flix +++ /dev/null @@ -1,11 +0,0 @@ -// Blank line -/// An algebraic data type for shapes. -enum Shape { - case Circle(Int32), // circle radius - case Square(Int32), // side length - case Rectangle(Int32, Int32) // height and width -} - -// Computes the area of a 2 by 4. -def main(): Unit \ IO = - println(area(Shape.Rectangle(2, 4))) diff --git a/test/testWorkspaces/rename/src/Main.flix b/test/testWorkspaces/rename/src/Main.flix index 4cb96028..1bc6c1d5 100644 --- a/test/testWorkspaces/rename/src/Main.flix +++ b/test/testWorkspaces/rename/src/Main.flix @@ -7,7 +7,7 @@ enum Shape { /// Computes the area of the given shape using /// pattern matching and basic arithmetic. -def area /*!area1*/(s /*!s1*/: Shape): Int32 = match s /*!s2*/ { +def area(s /*!s1*/: Shape): Int32 = match s /*!s2*/ { case Shape.Circle(r) => 3 * (r * r) case Shape.Square(w) => w * w case Shape.Rectangle(h, w) => h * w @@ -15,4 +15,4 @@ def area /*!area1*/(s /*!s1*/: Shape): Int32 = match s /*!s2*/ { // Computes the area of a 2 by 4. def main(): Unit \ IO = - println(area /*!area2*/(Shape.Rectangle(2, 4))) + println(area(Shape.Rectangle(2, 4)))