Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- When editing .sourcekit-lsp/config.json use the JSON schema from the toolchain ([#1979](https://github.com/swiftlang/vscode-swift/pull/1979))

### Fixed

- Omit `--scratch-path` when enumerating plugins with `swift package plugin --list` ([#1996](https://github.com/swiftlang/vscode-swift/pull/1996))

## 2.14.2 - 2025-12-07

### Fixed
Expand Down
7 changes: 3 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,9 @@ function handleFolderEvent(logger: SwiftLogger): (event: FolderEvent) => Promise
// function called when a folder is added. I broke this out so we can trigger it
// without having to await for it.
async function folderAdded(folder: FolderContext, workspace: WorkspaceContext) {
if (
!configuration.folder(folder.workspaceFolder).disableAutoResolve ||
configuration.backgroundCompilation.enabled
) {
const disableAutoResolve = configuration.folder(folder.workspaceFolder).disableAutoResolve;
const backgroundCompilationEnabled = configuration.backgroundCompilation.enabled;
if (!disableAutoResolve || backgroundCompilationEnabled) {
// if background compilation is set then run compile at startup unless
// this folder is a sub-folder of the workspace folder. This is to avoid
// kicking off compile for multiple projects at the same time
Expand Down
36 changes: 23 additions & 13 deletions src/toolchain/BuildFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,27 @@ export class BuildFlags {
private withSwiftSDKFlags(args: string[]): string[] {
switch (args[0]) {
case "package": {
const subcommand = args.splice(0, 2).concat(this.buildPathFlags());
switch (subcommand[1]) {
case "dump-symbol-graph":
case "diagnose-api-breaking-changes":
case "resolve": {
// These two tools require building the package, so SDK
// flags are needed. Destination control flags are
// required to be placed before subcommand options.
return [...subcommand, ...this.swiftpmSDKFlags(), ...args];
switch (args[1]) {
case "plugin":
// Don't append build path flags for `swift package plugin` commands
return args;
default: {
const subcommand = args.splice(0, 2).concat(this.buildPathFlags());
switch (subcommand[1]) {
case "dump-symbol-graph":
case "diagnose-api-breaking-changes":
case "resolve": {
// These two tools require building the package, so SDK
// flags are needed. Destination control flags are
// required to be placed before subcommand options.
return [...subcommand, ...this.swiftpmSDKFlags(), ...args];
}
default:
// Other swift-package subcommands operate on the host,
// so it doesn't need to know about the destination.
return subcommand.concat(args);
}
}
default:
// Other swift-package subcommands operate on the host,
// so it doesn't need to know about the destination.
return subcommand.concat(args);
}
}
case "build":
Expand Down Expand Up @@ -212,6 +219,9 @@ export class BuildFlags {
const disableSandboxFlags = ["--disable-sandbox", "-Xswiftc", "-disable-sandbox"];
switch (args[0]) {
case "package": {
if (args[1] === "plugin") {
return args;
}
return [args[0], ...disableSandboxFlags, ...args.slice(1)];
}
case "build":
Expand Down
31 changes: 31 additions & 0 deletions test/unit-tests/toolchain/BuildFlags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
import { expect } from "chai";
import { beforeEach } from "mocha";
import * as sinon from "sinon";

import configuration from "@src/configuration";
Expand Down Expand Up @@ -242,6 +243,13 @@ suite("BuildFlags Test Suite", () => {

suite("withAdditionalFlags", () => {
const sdkConfig = mockGlobalValue(configuration, "sdk");
const buildPathConfig = mockGlobalValue(configuration, "buildPath");

beforeEach(() => {
buildPathConfig.setValue("");
sdkConfig.setValue("");
sandboxConfig.setValue(false);
});

test("package", () => {
for (const sub of ["dump-symbol-graph", "diagnose-api-breaking-changes", "resolve"]) {
Expand Down Expand Up @@ -284,6 +292,29 @@ suite("BuildFlags Test Suite", () => {
]);
});

test("package plugin", () => {
buildPathConfig.setValue("");
sdkConfig.setValue("");
expect(
buildFlags.withAdditionalFlags(["package", "plugin", "my-plugin"])
).to.deep.equal(["package", "plugin", "my-plugin"]);

buildPathConfig.setValue("/some/build/path");
expect(
buildFlags.withAdditionalFlags(["package", "plugin", "my-plugin", "--verbose"])
).to.deep.equal(["package", "plugin", "my-plugin", "--verbose"]);

sdkConfig.setValue("/some/full/path/to/sdk");
expect(
buildFlags.withAdditionalFlags(["package", "plugin", "my-plugin"])
).to.deep.equal(["package", "plugin", "my-plugin"]);

sandboxConfig.setValue(true);
expect(
buildFlags.withAdditionalFlags(["package", "plugin", "my-plugin"])
).to.deep.equal(["package", "plugin", "my-plugin"]);
});

test("build", () => {
sdkConfig.setValue("");
expect(
Expand Down