Skip to content

Commit

Permalink
Merge pull request #79 from Adyen/remove-assertion-failure
Browse files Browse the repository at this point in the history
Fixed recursiveDescription formatting
  • Loading branch information
goergisn authored Jan 10, 2025
2 parents 748b253 + 8bdfaff commit c668b2b
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ extension CustomEnum: SimpleProtocol {
}
}

extension CustomEnum.NestedStructInExtension {
extension CustomEnum.NestedStructInExtension: CustomStringConvertible {

var description: String {
public var description: String {
return string
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct SwiftInterfaceChangeConsolidator: SwiftInterfaceChangeConsolidating {
let listOfChanges = listOfChanges(between: change, and: match)

if listOfChanges.isEmpty {
assertionFailure("We should not end up here - investigate how this happened")
print("We should not end up here - investigate how this happened")
break
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private extension SwiftInterfaceActor {
description.append("actor", with: modifiers.isEmpty ? "" : " ")
description.append(name, with: " ")
description.append(genericParameterDescription, with: "")
description.append(inheritance?.joined(separator: ", "), with: "") { ": \($0)" }
description.append(inheritance?.sorted().joined(separator: ", "), with: "") { ": \($0)" }
description.append(genericWhereClauseDescription, with: " ")
return description
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private extension SwiftInterfaceAssociatedType {
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
description.append("associatedtype", with: modifiers.isEmpty ? "" : " ")
description.append(name, with: " ")
description.append(inheritance?.joined(separator: ", "), with: "") { ": \($0)" }
description.append(inheritance?.sorted().joined(separator: ", "), with: "") { ": \($0)" }
description.append(initializerValue, with: " ") { "= \($0)" }
description.append(genericWhereClauseDescription, with: " ")
return description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private extension SwiftInterfaceClass {
description.append("class", with: modifiers.isEmpty ? "" : " ")
description.append(name, with: " ")
description.append(genericParameterDescription, with: "")
description.append(inheritance?.joined(separator: ", "), with: "") { ": \($0)" }
description.append(inheritance?.sorted().joined(separator: ", "), with: "") { ": \($0)" }
description.append(genericWhereClauseDescription, with: " ")
return description
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private extension SwiftInterfaceEnum {
description.append("enum", with: modifiers.isEmpty ? "" : " ")
description.append(name, with: " ")
description.append(genericParameterDescription, with: "")
description.append(inheritance?.joined(separator: ", "), with: "") { ": \($0)" }
description.append(inheritance?.sorted().joined(separator: ", "), with: "") { ": \($0)" }
description.append(genericWhereClauseDescription, with: " ")
return description
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private extension SwiftInterfaceExtension {
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
description.append("extension", with: modifiers.isEmpty ? "" : " ")
description.append(extendedType, with: " ")
description.append(inheritance?.joined(separator: ", "), with: "") { ": \($0)" }
description.append(inheritance?.sorted().joined(separator: ", "), with: "") { ": \($0)" }
description.append(genericWhereClauseDescription, with: " ")
return description
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private extension SwiftInterfaceProtocol {
description.append("protocol", with: modifiers.isEmpty ? "" : " ")
description.append(name, with: " ")
description.append(primaryAssociatedTypes.map { "<\($0.joined(separator: ", "))>" }, with: "")
description.append(inheritance?.joined(separator: ", "), with: "") { ": \($0)" }
description.append(inheritance?.sorted().joined(separator: ", "), with: "") { ": \($0)" }
description.append(genericWhereClauseDescription, with: " ")
return description
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private extension SwiftInterfaceStruct {
description.append("struct", with: modifiers.isEmpty ? "" : " ")
description.append(name, with: " ")
description.append(genericParameterDescription, with: "")
description.append(inheritance?.joined(separator: ", "), with: "") { ": \($0)" }
description.append(inheritance?.sorted().joined(separator: ", "), with: "") { ": \($0)" }
description.append(genericWhereClauseDescription, with: " ")
return description
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,12 @@ extension SwiftInterfaceElement {
var recursiveDescription = "\(indentedDescription(indentation: indentation))"
if !self.children.isEmpty {
recursiveDescription.append(" {")
for child in self.children {
for child in self.children.sorted(by: { $0.description < $1.description }) {
recursiveDescription.append("\n\(child.recursiveDescription(indentation: indentation + 1))")
}
recursiveDescription.append("\n\(String(repeating: spacer, count: indentation))}")
}

if indentation == 0 {
recursiveDescription.append("\n")
}

return recursiveDescription
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ extension SwiftInterfaceParser {

init(moduleName: String, elements: [any SwiftInterfaceElement]) {
self.moduleName = moduleName
self.children = elements

self.children = Self.mergeExtensions(for: self.children, moduleName: moduleName)
self.children = Self.mergeExtensions(for: elements, moduleName: moduleName)
self.children.forEach { $0.setupParentRelationships(parent: self) }
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/IntegrationTests/ReferencePackageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class ReferencePackageTests: XCTestCase {

let expectedLines = sanitizeOutput(expectedOutput).components(separatedBy: "\n")
let markdownOutputLines = sanitizeOutput(markdownOutput).components(separatedBy: "\n")

for i in 0..<expectedLines.count {
if expectedLines[i] != markdownOutputLines[i] {
XCTAssertEqual(expectedLines[i], markdownOutputLines[i])
XCTAssertEqual(expectedLines[i], markdownOutputLines[i], "Issue in line \(i)")
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,28 @@ _Comparing `new_private` to `old_private`_
## `ReferencePackage`
#### ❇️ Added
```javascript
public enum RawValueEnum: Swift.String, Swift.Equatable, Swift.Hashable, Swift.RawRepresentable {
public enum RawValueEnum: Swift.Equatable, Swift.Hashable, Swift.RawRepresentable, Swift.String {
case one
case two
public init?(rawValue: Swift.String)
public typealias RawValue = Swift.String
public var rawValue: Swift.String { get }
}

```
```javascript
public protocol ParentProtocol {
associatedtype ParentType: Swift.Equatable where Self.ParentType == Self.Iterator.Element
associatedtype Iterator: Swift.Collection
associatedtype ParentType: Swift.Equatable where Self.ParentType == Self.Iterator.Element
}

```
```javascript
public protocol ParentProtocol<ParentType> {
associatedtype ParentType: Swift.Equatable where Self.ParentType == Self.Iterator.Element
associatedtype Iterator: Swift.Collection
associatedtype ParentType: Swift.Equatable where Self.ParentType == Self.Iterator.Element
}

```
```javascript
public protocol SimpleProtocol

```
#### 🔀 Modified
```javascript
Expand Down Expand Up @@ -108,33 +104,26 @@ Changes:
extension Swift.Array {
public subscript(safe index: Swift.Int) -> Element? { get }
}

```
### `CustomClass`
#### ❇️ Added
```javascript
final public let a: Swift.Int { get }

```
```javascript
final public let b: Swift.Int { get }

```
```javascript
final public let c: Swift.Int { get }

```
```javascript
final public let d: Swift.Double { get }

```
```javascript
public subscript(index: Swift.Int) -> T? { get set }

```
```javascript
public var lazyVar: Swift.String { get set }

```
#### 🔀 Modified
```javascript
Expand Down Expand Up @@ -181,40 +170,33 @@ Changes:
#### ❇️ Added
```javascript
case a

```
```javascript
case b

```
```javascript
case c

```
```javascript
case caseWithNamedString(title: T)

```
```javascript
case d

```
```javascript
case e(ReferencePackage.CustomEnum<T>.NestedStructInExtension)

```
```javascript
extension ReferencePackage.CustomEnum where T == Swift.String {
public var titleOfCaseWithNamedString: Swift.String? { get }
}

```
```javascript
public struct NestedStructInExtension {
public let string: Swift.String { get }
public struct NestedStructInExtension: Swift.CustomStringConvertible {
public init(string: Swift.String = "Hello")
public let string: Swift.String { get }
public var description: Swift.String { get }
}

```
#### 🔀 Modified
```javascript
Expand Down Expand Up @@ -259,19 +241,15 @@ case caseWithString(Swift.String)
#### ❇️ Added
```javascript
associatedtype AnotherAssociatedType: Swift.Strideable

```
```javascript
associatedtype AnotherAssociatedType: Swift.Strideable

```
```javascript
associatedtype CustomAssociatedType: Swift.Equatable

```
```javascript
associatedtype CustomAssociatedType: Swift.Equatable

```
#### 🔀 Modified
```javascript
Expand Down Expand Up @@ -324,23 +302,18 @@ public struct NestedStruct {
@available(swift 5.9)
public let nestedVar: Swift.String { get }
}

```
```javascript
public typealias AnotherAssociatedType = Swift.Double

```
```javascript
public typealias CustomAssociatedType = Swift.Int

```
```javascript
public typealias Iterator = [ReferencePackage.CustomStruct<T>.AnotherAssociatedType]

```
```javascript
public typealias ParentType = Swift.Double

```
#### 🔀 Modified
```javascript
Expand Down Expand Up @@ -386,17 +359,14 @@ Changes:
```javascript
@_spi(SystemProgrammingInterface)
public typealias AnotherAssociatedType = T

```
```javascript
@_spi(SystemProgrammingInterface)
public typealias Iterator = [Swift.Double]

```
```javascript
@_spi(SystemProgrammingInterface)
public typealias ParentType = Swift.Double

```
#### 🔀 Modified
```javascript
Expand Down
Loading

0 comments on commit c668b2b

Please sign in to comment.