Skip to content

[5.9][Macros] Unify PluginMessages.swift #67038

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
Jun 30, 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
3 changes: 2 additions & 1 deletion lib/ASTGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ add_pure_swift_host_library(swiftASTGen STATIC
Sources/ASTGen/Macros.swift
Sources/ASTGen/Misc.swift
Sources/ASTGen/PluginHost.swift
Sources/ASTGen/PluginMessages.swift
Sources/ASTGen/SourceFile.swift
Sources/ASTGen/SourceManager.swift
Sources/ASTGen/SourceManager+MacroExpansionContext.swift
Expand All @@ -26,11 +25,13 @@ add_pure_swift_host_library(swiftASTGen STATIC
swiftAST
SWIFT_DEPENDENCIES
SwiftSyntax::SwiftBasicFormat
SwiftSyntax::SwiftCompilerPluginMessageHandling
SwiftSyntax::SwiftDiagnostics
SwiftSyntax::SwiftOperators
SwiftSyntax::SwiftParser
SwiftSyntax::SwiftParserDiagnostics
SwiftSyntax::SwiftSyntax
SwiftSyntax::SwiftSyntaxBuilder
SwiftSyntax::SwiftSyntaxMacros
SwiftSyntax::SwiftSyntaxMacroExpansion
swiftLLVMJSON
Expand Down
6 changes: 5 additions & 1 deletion lib/ASTGen/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ let package = Package(
.target(
name: "swiftASTGen",
dependencies: [
.product(name: "SwiftBasicFormat", package: "swift-syntax"),
.product(name: "SwiftCompilerPluginMessageHandling", package: "swift-syntax"),
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftOperators", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax"),
.product(name: "SwiftParserDiagnostics", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"),
"swiftLLVMJSON"
Expand Down
3 changes: 2 additions & 1 deletion lib/ASTGen/Sources/ASTGen/Macros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import SwiftDiagnostics
import SwiftOperators
import SwiftParser
import SwiftSyntax
import SwiftSyntaxBuilder
import SwiftSyntaxMacros
import SwiftSyntaxMacroExpansion
@_spi(PluginMessage) import SwiftCompilerPluginMessageHandling

extension SyntaxProtocol {
func token(at position: AbsolutePosition) -> TokenSyntax? {
Expand Down Expand Up @@ -829,7 +831,6 @@ func expandAttachedMacroIPC(
macro: .init(moduleName: macro.moduleName, typeName: macro.typeName, name: macroName),
macroRole: macroRole,
discriminator: discriminator,
qualifiedType: qualifiedType,
attributeSyntax: customAttributeSyntax,
declSyntax: declSyntax,
parentDeclSyntax: parentDeclSyntax,
Expand Down
1 change: 1 addition & 0 deletions lib/ASTGen/Sources/ASTGen/PluginHost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import CASTBridging
import CBasicBridging
import SwiftSyntax
import swiftLLVMJSON
@_spi(PluginMessage) import SwiftCompilerPluginMessageHandling

enum PluginError: String, Error, CustomStringConvertible {
case stalePlugin = "plugin is stale"
Expand Down
190 changes: 0 additions & 190 deletions lib/ASTGen/Sources/ASTGen/PluginMessages.swift

This file was deleted.

2 changes: 1 addition & 1 deletion test/Macros/macro_plugin_error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func test() {
// FIXME: Should be more user friendly message.

let _: String = #fooMacro(1)
// expected-error @-1 {{typeMismatch(swiftASTGen.PluginToHostMessage}}
// expected-error @-1 {{typeMismatch(SwiftCompilerPluginMessageHandling.PluginToHostMessage}}
let _: String = #fooMacro(2)
// expected-error @-1 {{failed to receive result from plugin (from macro 'fooMacro')}}
let _: String = #fooMacro(3)
Expand Down