diff --git a/src/TestExplorer/TestExplorer.ts b/src/TestExplorer/TestExplorer.ts index 271a18005..88b72e1ad 100644 --- a/src/TestExplorer/TestExplorer.ts +++ b/src/TestExplorer/TestExplorer.ts @@ -365,13 +365,8 @@ export class TestExplorer { return; } - // get list of tests from `swift test --list-tests` - let listTestArguments: string[]; - if (toolchain.swiftVersion.isGreaterThanOrEqual(new Version(5, 8, 0))) { - listTestArguments = ["test", "list", "--skip-build"]; - } else { - listTestArguments = ["test", "--list-tests", "--skip-build"]; - } + // get list of tests from `swift test list --skip-build` + let listTestArguments: string[] = ["test", "list", "--skip-build"]; listTestArguments = [...listTestArguments, ...testBuildOptions]; const listTestsOperation = new SwiftExecOperation( listTestArguments, diff --git a/src/commands/createNewProject.ts b/src/commands/createNewProject.ts index 8cd6f9b7e..97ada464d 100644 --- a/src/commands/createNewProject.ts +++ b/src/commands/createNewProject.ts @@ -19,7 +19,6 @@ import { SwiftProjectTemplate, SwiftToolchain } from "../toolchain/toolchain"; import { showToolchainError } from "../ui/ToolchainSelection"; import { withDelayedProgress } from "../ui/withDelayedProgress"; import { execSwift } from "../utilities/utilities"; -import { Version } from "../utilities/version"; /** * Prompts the user to input project details and then executes `swift package init` @@ -34,16 +33,6 @@ export async function createNewProject(toolchain: SwiftToolchain | undefined): P return; } - // The context key `swift.createNewProjectAvailable` only works if the extension has been - // activated. As such, we also have to allow this command to run when no workspace is - // active. Show an error to the user if the command is unavailable. - if (!toolchain.swiftVersion.isGreaterThanOrEqual(new Version(5, 8, 0))) { - void vscode.window.showErrorMessage( - "Creating a new swift project is only available starting in swift version 5.8.0." - ); - return; - } - // Prompt the user for the type of project they would like to create const availableProjectTemplates = await toolchain.getProjectTemplates(); const selectedProjectTemplate = await vscode.window.showQuickPick< diff --git a/src/contextKeys.ts b/src/contextKeys.ts index 97524fce1..295c07c72 100644 --- a/src/contextKeys.ts +++ b/src/contextKeys.ts @@ -119,9 +119,7 @@ export function createContextKeys(): ContextKeys { return { updateKeysBasedOnActiveVersion(toolchainVersion: Version) { - this.createNewProjectAvailable = toolchainVersion.isGreaterThanOrEqual( - new Version(5, 8, 0) - ); + this.createNewProjectAvailable = true; this.switchPlatformAvailable = process.platform === "darwin" ? toolchainVersion.isGreaterThanOrEqual(new Version(6, 1, 0)) diff --git a/src/debugger/buildConfig.ts b/src/debugger/buildConfig.ts index 062431c31..d2f03ef95 100644 --- a/src/debugger/buildConfig.ts +++ b/src/debugger/buildConfig.ts @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// import * as fs from "fs/promises"; -import * as os from "os"; import * as path from "path"; import * as vscode from "vscode"; @@ -82,10 +81,6 @@ export class BuildConfigurationFactory { /** flag for enabling test discovery */ private testDiscoveryFlag(ctx: FolderContext): string[] { - // Test discovery is only available in SwiftPM 5.1 and later. - if (ctx.swiftVersion.isLessThan(new Version(5, 1, 0))) { - return []; - } // Test discovery is always enabled on Darwin. if (process.platform !== "darwin") { const hasLinuxMain = ctx.linuxMain.exists; @@ -465,17 +460,6 @@ export class TestingConfigurationFactory { }, }; default: - const swiftVersion = this.ctx.toolchain.swiftVersion; - if ( - swiftVersion.isLessThan(new Version(5, 7, 0)) && - swiftVersion.isGreaterThanOrEqual(new Version(5, 6, 0)) && - process.platform === "darwin" - ) { - // if debugging on macOS with Swift 5.6 we need to create a custom launch - // configuration so we can set the system architecture - return await this.createDarwin56TestConfiguration(); - } - let xcTestArgs = [ "test", ...(this.testKind === TestKind.coverage @@ -515,60 +499,6 @@ export class TestingConfigurationFactory { } /* eslint-enable no-case-declarations */ - /** - * Return custom Darwin test configuration that works with Swift 5.6 - **/ - private async createDarwin56TestConfiguration(): Promise { - if ((await this.ctx.swiftPackage.getTargets(TargetType.test)).length === 0) { - return null; - } - - let testFilterArg: string; - const testList = this.testList.join(","); - if (testList.length > 0) { - testFilterArg = `-XCTest ${testList}`; - } else { - testFilterArg = ""; - } - - const { folder, nameSuffix } = getFolderAndNameSuffix(this.ctx, true); - // On macOS, find the path to xctest - // and point it at the .xctest bundle from the configured build directory. - const xctestPath = this.ctx.toolchain.xcTestPath; - if (xctestPath === undefined) { - return null; - } - let arch: string; - switch (os.arch()) { - case "x64": - arch = "x86_64"; - break; - case "arm64": - arch = "arm64e"; - break; - default: - return null; - } - const sanitizer = this.ctx.toolchain.sanitizer(configuration.sanitizer); - const envCommands = Object.entries({ - ...swiftRuntimeEnv(), - ...configuration.folder(this.ctx.workspaceFolder).testEnvironmentVariables, - ...sanitizer?.runtimeEnvironment, - }).map(([key, value]) => `settings set target.env-vars ${key}="${value}"`); - - return { - type: SWIFT_LAUNCH_CONFIG_TYPE, - request: "custom", - name: `Test ${await this.ctx.swiftPackage.name}`, - targetCreateCommands: [`file -a ${arch} ${xctestPath}/xctest`], - processCreateCommands: [ - ...envCommands, - `process launch -w ${folder} -- ${testFilterArg} ${this.xcTestOutputPath()}`, - ], - preLaunchTask: `swift: Build All${nameSuffix}`, - }; - } - private addSwiftTestingFlagsArgs(args: string[]): string[] { if (!this.swiftTestingArguments) { throw new Error( diff --git a/src/sourcekit-lsp/LanguageClientManager.ts b/src/sourcekit-lsp/LanguageClientManager.ts index 13ec7d139..a5e0d87be 100644 --- a/src/sourcekit-lsp/LanguageClientManager.ts +++ b/src/sourcekit-lsp/LanguageClientManager.ts @@ -40,7 +40,6 @@ import { SourceKitLogMessageNotification, SourceKitLogMessageParams } from "./ex import { DidChangeActiveDocumentNotification } from "./extensions/DidChangeActiveDocumentRequest"; import { PollIndexRequest, WorkspaceSynchronizeRequest } from "./extensions/PollIndexRequest"; import { activateGetReferenceDocument } from "./getReferenceDocument"; -import { activateLegacyInlayHints } from "./inlayHints"; import { activatePeekDocuments } from "./peekDocuments"; interface LanguageClientManageOptions { @@ -165,21 +164,6 @@ export class LanguageClientManager implements vscode.Disposable { this.subscriptions.push(onChangeConfig); - // Swift versions prior to 5.6 don't support file changes, so need to restart - // lSP server when a file is either created or deleted - if (this.swiftVersion.isLessThan(new Version(5, 6, 0))) { - folderContext.workspaceContext.logger.debug("LSP: Adding new/delete file handlers"); - // restart LSP server on creation of a new file - const onDidCreateFileDisposable = vscode.workspace.onDidCreateFiles(() => { - void this.restart(); - }); - // restart LSP server on deletion of a file - const onDidDeleteFileDisposable = vscode.workspace.onDidDeleteFiles(() => { - void this.restart(); - }); - this.subscriptions.push(onDidCreateFileDisposable, onDidDeleteFileDisposable); - } - this.waitingOnRestartCount = 0; this.documentSymbolWatcher = undefined; this.cancellationToken = new vscode.CancellationTokenSource(); @@ -528,10 +512,6 @@ export class LanguageClientManager implements vscode.Disposable { // if sourcekit-lsp crashes during normal operation. errorHandler.enable(); - if (this.swiftVersion.isLessThan(new Version(5, 7, 0))) { - this.legacyInlayHints = activateLegacyInlayHints(client); - } - this.peekDocuments = activatePeekDocuments(client); this.getReferenceDocument = activateGetReferenceDocument(client); this.subscriptions.push(this.getReferenceDocument); diff --git a/src/toolchain/BuildFlags.ts b/src/toolchain/BuildFlags.ts index cd7512186..18534dbbc 100644 --- a/src/toolchain/BuildFlags.ts +++ b/src/toolchain/BuildFlags.ts @@ -16,7 +16,6 @@ import * as path from "path"; import configuration from "../configuration"; import { SwiftLogger } from "../logging/SwiftLogger"; import { execSwift } from "../utilities/utilities"; -import { Version } from "../utilities/version"; import { DarwinCompatibleTarget, SwiftToolchain, getDarwinTargetTriple } from "./toolchain"; /** Target info */ @@ -111,11 +110,7 @@ export class BuildFlags { */ buildPathFlags(): string[] { if (configuration.buildPath && configuration.buildPath.length > 0) { - if (this.toolchain.swiftVersion.isLessThan(new Version(5, 8, 0))) { - return ["--build-path", configuration.buildPath]; - } else { - return ["--scratch-path", configuration.buildPath]; - } + return ["--scratch-path", configuration.buildPath]; } else { return []; } diff --git a/src/toolchain/toolchain.ts b/src/toolchain/toolchain.ts index 174bd5e12..784a8db02 100644 --- a/src/toolchain/toolchain.ts +++ b/src/toolchain/toolchain.ts @@ -317,10 +317,6 @@ export class SwiftToolchain { * @returns a {@link SwiftProjectTemplate} for each discovered project type */ public async getProjectTemplates(): Promise { - // Only swift versions >=5.8.0 are supported - if (this.swiftVersion.isLessThan(new Version(5, 8, 0))) { - return []; - } // Parse the output from `swift package init --help` const { stdout } = await execSwift(["package", "init", "--help"], "default"); const lines = stdout.split(/\r?\n/g); diff --git a/test/integration-tests/WorkspaceContext.test.ts b/test/integration-tests/WorkspaceContext.test.ts index dde1cf20e..5a9dbaaaf 100644 --- a/test/integration-tests/WorkspaceContext.test.ts +++ b/test/integration-tests/WorkspaceContext.test.ts @@ -213,14 +213,6 @@ tag("medium").suite("WorkspaceContext Test Suite", () => { }); tag("small").test("get project templates", async () => { - // This is only supported in swift versions >=5.8.0 - const swiftVersion = workspaceContext.globalToolchain.swiftVersion; - if (swiftVersion.isLessThan(new Version(5, 8, 0))) { - await expect( - workspaceContext.globalToolchain.getProjectTemplates() - ).to.eventually.deep.equal([]); - return; - } // The output of `swift package init --help` will probably change at some point. // Just make sure that the most complex portions of the output are parsed correctly. const projectTemplates = await workspaceContext.globalToolchain.getProjectTemplates(); @@ -234,6 +226,7 @@ tag("medium").suite("WorkspaceContext Test Suite", () => { "A package with an executable that uses Swift Argument Parser. Use this template if you plan to have a rich set of command-line arguments.", }); // build-tool-plugin is only available in swift versions >=5.9.0 + const swiftVersion = workspaceContext.globalToolchain.swiftVersion; if (swiftVersion.isLessThan(new Version(5, 9, 0))) { return; } diff --git a/test/unit-tests/toolchain/BuildFlags.test.ts b/test/unit-tests/toolchain/BuildFlags.test.ts index 2c6793303..b1003b605 100644 --- a/test/unit-tests/toolchain/BuildFlags.test.ts +++ b/test/unit-tests/toolchain/BuildFlags.test.ts @@ -190,11 +190,11 @@ suite("BuildFlags Test Suite", () => { ]); }); - test("configuration provided, before swift 5.8", () => { - mockedToolchain.swiftVersion = new Version(5, 7, 0); + test("configuration provided", () => { + mockedToolchain.swiftVersion = new Version(5, 9, 0); buildPathConfig.setValue("/some/other/full/test/path"); expect(buildFlags.buildPathFlags()).to.deep.equal([ - "--build-path", + "--scratch-path", "/some/other/full/test/path", ]); });