diff --git a/Sources/BuildServerIntegration/SwiftPMBuildServer.swift b/Sources/BuildServerIntegration/SwiftPMBuildServer.swift index 042cf6177..0c8431430 100644 --- a/Sources/BuildServerIntegration/SwiftPMBuildServer.swift +++ b/Sources/BuildServerIntegration/SwiftPMBuildServer.swift @@ -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 diff --git a/Tests/SourceKitLSPTests/SwiftPMIntegrationTests.swift b/Tests/SourceKitLSPTests/SwiftPMIntegrationTests.swift index c04583dac..15ba5f50e 100644 --- a/Tests/SourceKitLSPTests/SwiftPMIntegrationTests.swift +++ b/Tests/SourceKitLSPTests/SwiftPMIntegrationTests.swift @@ -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'"] + ) + } }