Skip to content
Merged
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
5 changes: 5 additions & 0 deletions Release Notes/600.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@
- Pull request: https://github.com/apple/swift-syntax/pull/2531
- Migration steps: Use `if case .backslash = triviaPiece` instead

- All symbols in `SwiftCompilerPluginMessageHandling` are now SPI
- Description: This module is only intended to be used from some internal components. Any other modules should not use them directly.
- Pull request: https://github.com/apple/swift-syntax/pull/2489
- Migration steps: Stop using this module.

## Template

- *Affected API or two word description*
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftCompilerPlugin/CompilerPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#if swift(>=6.0)
public import SwiftSyntaxMacros
private import Foundation
private import SwiftCompilerPluginMessageHandling
@_spi(PluginMessage) private import SwiftCompilerPluginMessageHandling
#else
import SwiftSyntaxMacros
import Foundation
import SwiftCompilerPluginMessageHandling
@_spi(PluginMessage) import SwiftCompilerPluginMessageHandling
#endif

#if os(Windows)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import SwiftSyntaxMacros
#endif

/// Optional features.
@_spi(PluginMessage)
public enum PluginFeature: String {
case loadPluginLibrary = "load-plugin-library"
}

/// A type that provides the actual plugin functions.
@_spi(PluginMessage)
public protocol PluginProvider {
/// Resolve macro type by the module name and the type name.
func resolveMacro(moduleName: String, typeName: String) throws -> Macro.Type
Expand All @@ -37,6 +39,7 @@ public protocol PluginProvider {

/// Low level message connection to the plugin host.
/// This encapsulates the connection and the message serialization.
@_spi(PluginMessage)
public protocol MessageConnection {
/// Send a message to the peer.
func sendMessage<TX: Encodable>(_ message: TX) throws
Expand Down Expand Up @@ -66,6 +69,7 @@ struct HostCapability {
/// the response.
///
/// The low level connection and the provider is injected by the client.
@_spi(PluginMessage)
public class CompilerPluginMessageHandler<Connection: MessageConnection, Provider: PluginProvider> {
/// Message channel for bidirectional communication with the plugin host.
let connection: Connection
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftCompilerPluginMessageHandling/Macros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import SwiftBasicFormat
import SwiftDiagnostics
import SwiftOperators
import SwiftSyntax
@_spi(ExperimentalLanguageFeature) import SwiftSyntaxMacroExpansion
@_spi(MacroExpansion) @_spi(ExperimentalLanguageFeature) import SwiftSyntaxMacroExpansion
@_spi(ExperimentalLanguageFeature) import SwiftSyntaxMacros

extension CompilerPluginMessageHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
//===----------------------------------------------------------------------===//

/// Old compiler might send '.declaration' as "freeStandingDeclaration".
@_spi(PluginMessage) public extension PluginMessage.MacroRole {
@_spi(PluginMessage)
public extension PluginMessage.MacroRole {
init(from decoder: Decoder) throws {
let stringValue = try decoder.singleValueContainer().decode(String.self)
if let role = Self(rawValue: stringValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

// NOTE: Types in this file should be self-contained and should not depend on any non-stdlib types.

@_spi(PluginMessage)
public enum HostToPluginMessage: Codable {
/// Send capability of the host, and get capability of the plugin.
case getCapability(
Expand Down Expand Up @@ -49,6 +50,7 @@ public enum HostToPluginMessage: Codable {
)
}

@_spi(PluginMessage)
public enum PluginToHostMessage: Codable {
case getCapabilityResult(
capability: PluginMessage.PluginCapability
Expand Down Expand Up @@ -78,6 +80,7 @@ public enum PluginToHostMessage: Codable {
)
}

@_spi(PluginMessage)
public enum PluginMessage {
public static var PROTOCOL_VERSION_NUMBER: Int { 7 } // Pass extension protocol list

Expand Down