diff --git a/Changelog.md b/Changelog.md index a70f662..9519abb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added support for Swift 5.4 and 5.5. + #12 by @compnerd and @mattt. + ## [0.2.0] - 2020-11-11 ### Added diff --git a/Package@swift-5.4.swift b/Package@swift-5.4.swift new file mode 100644 index 0000000..a3fc35c --- /dev/null +++ b/Package@swift-5.4.swift @@ -0,0 +1,33 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SwiftSemantics", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "SwiftSemantics", + targets: ["SwiftSemantics"] + ), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + .package(name: "SwiftSyntax", + url: "https://github.com/apple/swift-syntax.git", + .revision("release/5.4")), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "SwiftSemantics", + dependencies: ["SwiftSyntax"] + ), + .testTarget( + name: "SwiftSemanticsTests", + dependencies: ["SwiftSemantics"] + ), + ] +) diff --git a/Package@swift-5.5.swift b/Package@swift-5.5.swift new file mode 100644 index 0000000..65acbee --- /dev/null +++ b/Package@swift-5.5.swift @@ -0,0 +1,33 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SwiftSemantics", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "SwiftSemantics", + targets: ["SwiftSemantics"] + ), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + .package(name: "SwiftSyntax", + url: "https://github.com/apple/swift-syntax.git", + .revision("release/5.5")), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "SwiftSemantics", + dependencies: ["SwiftSyntax"] + ), + .testTarget( + name: "SwiftSemanticsTests", + dependencies: ["SwiftSemantics"] + ), + ] +) diff --git a/Sources/SwiftSemantics/Declarations/Class.swift b/Sources/SwiftSemantics/Declarations/Class.swift index f8df0d4..b143191 100644 --- a/Sources/SwiftSemantics/Declarations/Class.swift +++ b/Sources/SwiftSemantics/Declarations/Class.swift @@ -71,7 +71,13 @@ extension Class: ExpressibleBySyntax { public init(_ node: ClassDeclSyntax) { attributes = node.attributes?.compactMap{ $0.as(AttributeSyntax.self) }.map { Attribute($0) } ?? [] modifiers = node.modifiers?.map { Modifier($0) } ?? [] + + #if swift(>=5.5) + keyword = node.classOrActorKeyword.text.trimmed + #else keyword = node.classKeyword.text.trimmed + #endif + name = node.identifier.text.trimmed inheritance = node.inheritanceClause?.inheritedTypeCollection.map { $0.typeName.description.trimmed } ?? [] genericParameters = node.genericParameterClause?.genericParameterList.map { GenericParameter($0) } ?? []