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
2 changes: 1 addition & 1 deletion Sources/BuildServerIntegration/SwiftPMBuildServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ package actor SwiftPMBuildServer: BuiltInBuildServer {

signposter.emitEvent("Finished generating build plan", id: signpostID)

buildDescription = BuildDescription(buildPlan: plan)
buildDescription = BuildDescription(buildPlan: plan, pluginConfiguration: self.pluginConfiguration)
}

/// Make sure to execute any throwing statements before setting any
Expand Down
52 changes: 52 additions & 0 deletions Tests/SourceKitLSPTests/SwiftPMIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -902,4 +902,56 @@ final class SwiftPMIntegrationTests: SourceKitLSPTestCase {
let xSymbol = try XCTUnwrap(fooSymbol.children?.first(where: { $0.name == "x" }))
XCTAssertEqual(xSymbol.kind, .property)
}

func testPackagePlugin() async throws {
let project = try await SwiftPMTestProject(
files: [
"Test.swift": "",
"Plugins/PrintMessage/Plugin.swift": """
import PackagePlugin

@main
struct PrintMessagePlugin: CommandPlugin {
func performCommand(context: PluginContext, arguments: [String]) throws {
print("Message")
let x: String = 1
}
}
""",
],
manifest: """
import PackageDescription

let package = Package(
name: "PrintMessage",
platforms: [.macOS(.v14)],
products: [
.plugin(
name: "PrintMessage",
targets: ["PrintMessage"]
)
],
targets: [
.target(name: "MyLibrary"),
.plugin(
name: "PrintMessage",
capability: .command(
intent: .custom(
verb: "print-message",
description: "Prints message"
)
)
)
]
)
""",
// enableBackgroundIndexing: true
)
let (uri, _) = try! project.openDocument("Plugin.swift")
let diags = try await project.testClient.send(DocumentDiagnosticsRequest(textDocument: TextDocumentIdentifier(uri)))
XCTAssertEqual(
diags.fullReport?.items.map(\.message),
["Cannot convert value of type 'Int' to specified type 'String'"]
)
}
}