-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add Linux support #9
Changes from all commits
6e0e67f
9d4225d
826b677
b7fbeea
ae37d73
e8acaf4
972e650
c0e3e25
2215c4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,16 +79,16 @@ let package = Package( | |
.product(name: "ArgumentParser", package: "swift-argument-parser"), | ||
.product(name: "SwiftSyntax", package: "swift-syntax"), | ||
.product(name: "SwiftParser", package: "swift-syntax"), | ||
.byNameItem(name: "ZippyJSON", condition: .when(platforms: [.iOS, .tvOS, .macOS])), | ||
"SafeDICore", | ||
"ZippyJSON", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
] | ||
), | ||
.testTarget( | ||
name: "SafeDIToolTests", | ||
dependencies: [ | ||
.product(name: "ArgumentParser", package: "swift-argument-parser"), | ||
.byNameItem(name: "ZippyJSON", condition: .when(platforms: [.iOS, .tvOS, .macOS])), | ||
"SafeDITool", | ||
"ZippyJSON", | ||
] | ||
), | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ public final class DependencyTreeGenerator { | |
for try await generatedRoot in taskGroup { | ||
generatedRoots.append(generatedRoot) | ||
} | ||
return generatedRoots.sorted().joined(separator: "\n\n").trimmingCharacters(in: .whitespacesAndNewlines) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return generatedRoots.sorted().joined(separator: "\n\n") | ||
} | ||
|
||
let importsWhitespace = imports.isEmpty ? "" : "\n" | ||
|
@@ -69,7 +69,7 @@ public final class DependencyTreeGenerator { | |
|
||
// MARK: - DependencyTreeGeneratorError | ||
|
||
enum DependencyTreeGeneratorError: Error, CustomStringConvertible { | ||
private enum DependencyTreeGeneratorError: Error, CustomStringConvertible { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a necessary change but noticed that I'd forgotten to make this |
||
|
||
case noInstantiableFound(TypeDescription) | ||
case unfulfillableProperties([UnfulfillableProperty]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,7 @@ public enum TypeDescription: Codable, Hashable, Comparable, Sendable { | |
case let .closure(arguments, isAsync, doesThrow, returnType): | ||
return "(\(arguments.map { $0.asSource }.joined(separator: ", ")))\([isAsync ? " async" : "", doesThrow ? " throws" : ""].filter { !$0.isEmpty }.joined()) -> \(returnType.asSource)" | ||
case let .unknown(text): | ||
return text.trimmingCharacters(in: .whitespacesAndNewlines) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since |
||
return text | ||
} | ||
} | ||
|
||
|
@@ -280,9 +280,8 @@ extension TypeSyntax { | |
returnType: typeIdentifier.returnClause.type.typeDescription) | ||
|
||
} else { | ||
assertionFailure("TypeSyntax of unknown type. Defaulting to `description`.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We haven't gotten any value out of this |
||
// The description is a source-accurate description of this node, so it is a reasonable fallback. | ||
return .unknown(text: description) | ||
return .unknown(text: trimmedDescription) | ||
} | ||
} | ||
} | ||
|
@@ -304,7 +303,7 @@ extension ExprSyntax { | |
if let base = memberAccessExpr.base { | ||
return base.typeDescription | ||
} else { | ||
return .unknown(text: memberAccessExpr.description) | ||
return .unknown(text: memberAccessExpr.trimmedDescription) | ||
} | ||
} else { | ||
if let base = memberAccessExpr.base { | ||
|
@@ -321,7 +320,7 @@ extension ExprSyntax { | |
) | ||
} | ||
} else { | ||
return .unknown(text: memberAccessExpr.description) | ||
return .unknown(text: memberAccessExpr.trimmedDescription) | ||
} | ||
} | ||
} else if let genericExpr = GenericSpecializationExprSyntax(self) { | ||
|
@@ -339,7 +338,7 @@ extension ExprSyntax { | |
parentType: parentType, generics: genericTypeVisitor.genericArguments | ||
) | ||
case .any, .array, .attributed, .closure, .composition, .dictionary, .implicitlyUnwrappedOptional, .metatype, .optional, .some, .tuple, .unknown: | ||
return .unknown(text: description) | ||
return .unknown(text: trimmedDescription) | ||
} | ||
} else if let tupleExpr = TupleExprSyntax(self) { | ||
let tupleTypes = tupleExpr.elements.map(\.expression.typeDescription) | ||
|
@@ -377,7 +376,7 @@ extension ExprSyntax { | |
returnType: returnType.typeDescription | ||
) | ||
} else { | ||
return .unknown(text: description) | ||
return .unknown(text: trimmedDescription) | ||
} | ||
} else if let optionalChainingExpr = OptionalChainingExprSyntax(self) { | ||
return .optional(optionalChainingExpr.expression.typeDescription) | ||
|
@@ -398,7 +397,7 @@ extension ExprSyntax { | |
value: onlyElement.value.typeDescription | ||
) | ||
} else { | ||
return .unknown(text: description) | ||
return .unknown(text: trimmedDescription) | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2732,13 +2732,11 @@ final class SafeDIToolTests: XCTestCase { | |
line: UInt = #line, | ||
block: () async throws -> ReturnType | ||
) async { | ||
var didThrow = false | ||
do { | ||
_ = try await block() | ||
XCTFail("Did not throw error!", line: line) | ||
} catch { | ||
didThrow = true | ||
XCTAssertEqual((error as CustomStringConvertible).description, errorDescription, line: line) | ||
XCTAssertEqual("\(error)", errorDescription, line: line) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was required to get tests working on Linux. |
||
} | ||
XCTAssertTrue(didThrow, "Did not throw error!", line: line) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a directly related change but I figured I'd bump while I was here.