Skip to content

Commit 54a700c

Browse files
committed
Consolidating DeclSyntax extensions
1 parent 8eab64c commit 54a700c

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import SwiftSyntax
2+
3+
extension SyntaxCollection {
4+
5+
/// Produces a description where all elements in the list are mapped to their `trimmedDescription`
6+
var sanitizedList: [String] {
7+
self.map { $0.trimmedDescription }
8+
}
9+
}
10+
11+
extension InheritedTypeListSyntax {
12+
13+
/// Produces a description where all elements in the list are mapped to their type's `trimmedDescription`
14+
var sanitizedList: [String] {
15+
self.map { $0.type.trimmedDescription }
16+
}
17+
}
18+
19+
extension AccessorBlockSyntax {
20+
21+
/// Produces a description where all newlines and spaces are replaced by a single space
22+
///
23+
/// e.g. "get\n set\n" -> "get set"
24+
var sanitizedDescription: String {
25+
accessors.trimmedDescription.replacingOccurrences(of: "[\n ]+", with: " ", options: .regularExpression)
26+
}
27+
}

Sources/Helpers/Models/SwiftInterface/DeclSyntax+Convenience/AccessorBlockSyntax+Convenience.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

Sources/Helpers/Models/SwiftInterface/DeclSyntax+Convenience/SyntaxCollection+Convenience.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)