Skip to content

Commit de87c16

Browse files
committed
Move MacroTools to a separate package,
Fix some availability tests
1 parent bd4a537 commit de87c16

22 files changed

+106
-61
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
/Packages
44
xcuserdata/
55
DerivedData/
6-
.swiftpm/configuration/registries.json
7-
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8-
.swiftpm/xcode/xcshareddata/xcschemes
6+
.swiftpm/
97
.netrc

MacroTools/Package.resolved

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MacroTools/Package.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// swift-tools-version: 5.9
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "MacroTools",
7+
platforms: [
8+
.iOS(.v15),
9+
.macOS(.v12),
10+
.watchOS(.v8),
11+
.tvOS(.v15),
12+
.visionOS(.v1),
13+
.macCatalyst(.v15)
14+
],
15+
products: [
16+
.library(
17+
name: "MacroTools",
18+
targets: ["MacroTools"]),
19+
],
20+
dependencies: [
21+
.package(
22+
url: "https://github.com/swiftlang/swift-syntax.git",
23+
from: "601.0.1"
24+
),
25+
],
26+
targets: [
27+
.target(
28+
name: "MacroTools",
29+
dependencies: [
30+
.product(name: "SwiftSyntaxMacros", package: "swift-syntax")
31+
]
32+
),
33+
]
34+
)

Sources/MacroTools/AccessLevel.swift renamed to MacroTools/Sources/MacroTools/AccessLevel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import SwiftSyntax
99

1010
public enum AccessLevel {
11-
package static var allCases: Set<TokenSyntax> {
11+
public static var allCases: Set<TokenSyntax> {
1212
return [
1313
.keyword(.public),
1414
.keyword(.package),
@@ -21,7 +21,7 @@ public enum AccessLevel {
2121
}
2222

2323
extension TokenSyntax {
24-
package var isAccessLevel: Bool {
24+
public var isAccessLevel: Bool {
2525
guard case .keyword(let value) = tokenKind else {
2626
return false
2727
}

Sources/MacroTools/AttributeListSyntax+Extension.swift renamed to MacroTools/Sources/MacroTools/AttributeListSyntax+Extension.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ extension AttributeListSyntax.Element {
1212
///
1313
/// - Returns: An optional ``AttributeSyntax`` representing the attribute syntax,
1414
/// or ``nil`` if the node is not an attribute syntax.
15-
package var attribute: AttributeSyntax? {
15+
public var attribute: AttributeSyntax? {
1616
return self.as(AttributeSyntax.self)
1717
}
1818

1919
/// The name of the attribute.
2020
///
2121
/// - Returns: An optional ``TokenSyntax`` representing the name of the attribute,
2222
/// or ``nil`` if the name cannot be determined.
23-
package var name: TokenSyntax? {
23+
public var name: TokenSyntax? {
2424
let attributeName = attribute?.attributeName.as(IdentifierTypeSyntax.self)
2525
return attributeName?.name
2626
}

Sources/MacroTools/DeclarationSyntax/DeclSyntaxProtocol+Extension.swift renamed to MacroTools/Sources/MacroTools/DeclarationSyntax/DeclSyntaxProtocol+Extension.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import SwiftSyntax
1010
extension DeclSyntaxProtocol {
1111
/// Retrieves the declaration as a `DeclarationSyntax`
1212
/// if it conforms to any known declaration syntax types.
13-
package var declaration: (any DeclarationSyntax)? {
13+
public var declaration: (any DeclarationSyntax)? {
1414
if let declaration = self.as(StructDeclSyntax.self) {
1515
return declaration
1616
}
@@ -31,15 +31,15 @@ extension DeclSyntaxProtocol {
3131
}
3232

3333
/// Retrieves the type name as a ``TokenSyntax`` from the declaration.
34-
package var typeName: TokenSyntax? {
34+
public var typeName: TokenSyntax? {
3535
guard let declaration = declaration else {
3636
return nil
3737
}
3838
return declaration.name
3939
}
4040

4141
/// Retrieves the inherited types from the declaration's inheritance clause.
42-
package var inheritedTypes: InheritedTypeListSyntax? {
42+
public var inheritedTypes: InheritedTypeListSyntax? {
4343
guard let declaration = declaration else {
4444
return nil
4545
}

Sources/MacroTools/DeclarationSyntax/DeclarationSyntax.swift renamed to MacroTools/Sources/MacroTools/DeclarationSyntax/DeclarationSyntax.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import SwiftSyntax
99

1010
/// Protocol representing a declaration syntax element in Swift.
11-
package protocol DeclarationSyntax {
11+
public protocol DeclarationSyntax {
1212
/// The name of the type.
1313
var name: TokenSyntax {get}
1414

Sources/MacroTools/Diagnostics.swift renamed to MacroTools/Sources/MacroTools/Diagnostics.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
import SwiftSyntax
99
import SwiftDiagnostics
1010

11-
package struct NetworkingFixItMessage: FixItMessage {
12-
package var message: String
11+
public struct NetworkingFixItMessage: FixItMessage {
12+
public var message: String
1313

14-
package var fixItID: MessageID
14+
public var fixItID: MessageID
1515

16-
package init(message: String, fixItID: MessageID) {
16+
public init(message: String, fixItID: MessageID) {
1717
self.message = message
1818
self.fixItID = fixItID
1919
}
2020
}
2121

2222
extension Diagnostic {
23-
package var error: DiagnosticsError {
23+
public var error: DiagnosticsError {
2424
return DiagnosticsError(diagnostics: [self])
2525
}
2626
}
2727

2828
extension Diagnostic {
29-
package func fixIt(_ fixIt: (_ diag: Diagnostic) -> FixIt) -> Self {
29+
public func fixIt(_ fixIt: (_ diag: Diagnostic) -> FixIt) -> Self {
3030
return Diagnostic(
3131
node: node,
3232
position: position,

Sources/MacroTools/MacroArguments.swift renamed to MacroTools/Sources/MacroTools/MacroArguments.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal enum ArgumentFactory {
5151

5252
extension AttributeSyntax.Arguments {
5353
/// The named macro arguments.
54-
package var named: [String: TokenSyntax] {
54+
public var named: [String: TokenSyntax] {
5555
guard let arguments = self.as(LabeledExprListSyntax.self) else {
5656
return [:]
5757
}
@@ -66,7 +66,7 @@ extension AttributeSyntax.Arguments {
6666
}
6767

6868
/// The unnamed macro arguments.
69-
package var unnamed: [TokenSyntax] {
69+
public var unnamed: [TokenSyntax] {
7070
guard let arguments = self.as(LabeledExprListSyntax.self) else {
7171
return []
7272
}

Sources/MacroTools/VariableDeclSyntax+Extension.swift renamed to MacroTools/Sources/MacroTools/VariableDeclSyntax+Extension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import SwiftSyntax
99

1010
extension VariableDeclSyntax {
11-
package var name: TokenSyntax? {
11+
public var name: TokenSyntax? {
1212
let binding = bindings.first
1313
let pattern = binding?.pattern.as(IdentifierPatternSyntax.self)
1414
return pattern?.identifier

0 commit comments

Comments
 (0)