diff --git a/Package.resolved b/Package.resolved index 8649a6c..5c8c2bf 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "5d36627594955e7c1e9d5ca6b02c23ee9dc8e0d4ce73dc310b34fa6d1b966434", + "originHash" : "ef9c8ff40b986db3a591fe3c50d79e4fe2a9e11749d84a72fbe97babc9ba3683", "pins" : [ { "identity" : "swift-argument-parser", @@ -37,6 +37,15 @@ "version" : "602.0.0" } }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system", + "state" : { + "revision" : "7c6ad0fc39d0763e0b699210e4124afd5041c5df", + "version" : "1.6.4" + } + }, { "identity" : "swift-tree-sitter", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index 8fc7ace..c319e07 100644 --- a/Package.swift +++ b/Package.swift @@ -36,6 +36,7 @@ let package = Package( .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), .package(url: "https://github.com/swiftlang/swift-syntax", from: "602.0.0"), .package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"), + .package(url: "https://github.com/apple/swift-system", from: "1.6.1"), ], targets: [ .macro( @@ -67,7 +68,11 @@ let package = Package( ), .target( name: "Common", - dependencies: ["Macros"], + dependencies: [ + "Macros", + .product(name: "SystemPackage", package: "swift-system"), + + ], swiftSettings: [.enableExperimentalFeature("CodeItemMacros")], ), .target( @@ -90,6 +95,7 @@ let package = Package( name: "Tests", dependencies: [ "P4Compiler", "P4Runtime", "P4Lang", "Macros", "TreeSitterExtensions", "Common", + .product(name: "SystemPackage", package: "swift-system"), ], swiftSettings: [.enableExperimentalFeature("CodeItemMacros")], ), diff --git a/Sources/Common/SourceCode.swift b/Sources/Common/SourceCode.swift index f839be4..7411228 100644 --- a/Sources/Common/SourceCode.swift +++ b/Sources/Common/SourceCode.swift @@ -16,7 +16,7 @@ // along with this program. If not, see . import Foundation -import System +import SystemPackage /// Represent a location in a post-preprocessed piece of P4 source code. public struct SourceLocation: Equatable, CustomStringConvertible { @@ -145,9 +145,7 @@ func do_preprocess( } // Try to make a url from the configured file. - guard let included_url = URL.init(filePath: included_path) else { - return .Error(Error(withMessage: "Could not convert \(included_path) into a URL")) - } + let included_url = URL.init(filePath: included_path.string) // By calling ourselves recursively, the include being processed will // be _completely_ expanded (including any nested includes). @@ -203,9 +201,7 @@ public struct SourceCodePreprocessor { return .Error(Error(withMessage: "Could not open \(file) for preprocessing")) } - guard let url = URL.init(filePath: file_to_open) else { - return .Error(Error(withMessage: "Could not convert \(file_to_open) into a URL")) - } + let url = URL.init(filePath: file_to_open.string) switch do_preprocess(url, self.manager) { case .Ok((let location, let contents)): diff --git a/Tests/p4rseTests/SupportTests/SourceCode.swift b/Tests/p4rseTests/SupportTests/SourceCode.swift index b32ba72..8189f23 100644 --- a/Tests/p4rseTests/SupportTests/SourceCode.swift +++ b/Tests/p4rseTests/SupportTests/SourceCode.swift @@ -21,7 +21,7 @@ import P4Compiler import P4Lang import P4Runtime import SwiftTreeSitter -import System +import SystemPackage import Testing import TreeSitter import TreeSitterP4