diff --git a/lib/ASTGen/Sources/ASTGen/Macros.swift b/lib/ASTGen/Sources/ASTGen/Macros.swift index 52751fa704d16..7ac35ce30cab1 100644 --- a/lib/ASTGen/Sources/ASTGen/Macros.swift +++ b/lib/ASTGen/Sources/ASTGen/Macros.swift @@ -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 { diff --git a/lib/ASTGen/Sources/ASTGen/PluginMessages.swift b/lib/ASTGen/Sources/ASTGen/PluginMessages.swift index 971c52ff7f185..de5e44f0cfa74 100644 --- a/lib/ASTGen/Sources/ASTGen/PluginMessages.swift +++ b/lib/ASTGen/Sources/ASTGen/PluginMessages.swift @@ -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 @@ -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 } @@ -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