Skip to content

[Macros] Update PluginMessages for 'customAttrbuteSyntax' rename. #63958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2023
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
2 changes: 1 addition & 1 deletion lib/ASTGen/Sources/ASTGen/Macros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ func expandAttachedMacroIPC(
macro: .init(moduleName: macro.moduleName, typeName: macro.typeName, name: macroName),
macroRole: macroRole,
discriminator: discriminator,
customAttributeSyntax: customAttributeSyntax,
attributeSyntax: customAttributeSyntax,
declSyntax: declSyntax,
parentDeclSyntax: parentDeclSyntax)
do {
Expand Down
38 changes: 32 additions & 6 deletions lib/ASTGen/Sources/ASTGen/PluginMessages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,44 @@
//
//===----------------------------------------------------------------------===//

// NOTE: This file should be synced between swift and swift-syntax repository.
// NOTE: Types in this file should be self-contained and should not depend on any non-stdlib types.

internal enum HostToPluginMessage: Codable {
case getCapability

case expandFreestandingMacro(
macro: PluginMessage.MacroReference,
discriminator: String,
syntax: PluginMessage.Syntax)
syntax: PluginMessage.Syntax
)

case expandAttachedMacro(
macro: PluginMessage.MacroReference,
macroRole: PluginMessage.MacroRole,
discriminator: String,
customAttributeSyntax: PluginMessage.Syntax,
attributeSyntax: PluginMessage.Syntax,
declSyntax: PluginMessage.Syntax,
parentDeclSyntax: PluginMessage.Syntax?)
parentDeclSyntax: PluginMessage.Syntax?
)
}

internal enum PluginToHostMessage: Codable {
case expandFreestandingMacroResult(
expandedSource: String?,
diagnostics: [PluginMessage.Diagnostic])
diagnostics: [PluginMessage.Diagnostic]
)

case expandAttachedMacroResult(
expandedSources: [String]?,
diagnostics: [PluginMessage.Diagnostic])
diagnostics: [PluginMessage.Diagnostic]
)

case getCapabilityResult(capability: PluginMessage.PluginCapability)
}

/*namespace*/ internal enum PluginMessage {
static var PROTOCOL_VERSION_NUMBER: Int { 2 } // Added 'MacroRole.conformance'
static var PROTOCOL_VERSION_NUMBER: Int { 3 } // Renamed 'customAttributeSyntax' to 'attributeSyntax'.

struct PluginCapability: Codable {
var protocolVersion: Int
Expand Down Expand Up @@ -69,9 +76,17 @@ internal enum PluginToHostMessage: Codable {
}

struct SourceLocation: Codable {
/// A file ID consisting of the module name and file name (without full path),
/// as would be generated by the macro expansion `#fileID`.
var fileID: String

/// A full path name as would be generated by the macro expansion `#filePath`,
/// e.g., `/home/taylor/alison.swift`.
var fileName: String

/// UTF-8 offset of the location in the file.
var offset: Int

var line: Int
var column: Int
}
Expand All @@ -84,12 +99,23 @@ internal enum PluginToHostMessage: Codable {
}
struct Position: Codable {
var fileName: String
/// UTF-8 offset in the file.
var offset: Int

static var invalid: Self {
.init(fileName: "", offset: 0)
}
}
struct PositionRange: Codable {
var fileName: String
/// UTF-8 offset of the start of the range in the file.
var startOffset: Int
/// UTF-8 offset of the end of the range in the file.
var endOffset: Int

static var invalid: Self {
.init(fileName: "", startOffset: 0, endOffset: 0)
}
}
struct Note: Codable {
var position: Position
Expand Down