Skip to content

Commit 2836eec

Browse files
committed
WIP
1 parent b9580e4 commit 2836eec

File tree

5 files changed

+42
-503
lines changed

5 files changed

+42
-503
lines changed

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -427,16 +427,4 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
427427
)
428428
}
429429
}
430-
431-
for node in SYNTAX_NODES where node.isSyntaxCollection {
432-
DeclSyntax(
433-
"""
434-
extension \(raw: node.name): CustomReflectable {
435-
public var customMirror: Mirror {
436-
return Mirror(self, unlabeledChildren: self.map{ $0 })
437-
}
438-
}
439-
"""
440-
)
441-
}
442430
}

Sources/SwiftSyntax/Syntax.swift

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -604,14 +604,10 @@ public extension SyntaxProtocol {
604604
return Mirror(self, children: [:])
605605
}
606606

607-
/// Same as `debugDescription` but includes all children.
608-
var recursiveDescription: String {
609-
debugDescription(includeChildren: true)
610-
}
611-
612607
/// Returns a summarized dump of this node.
613608
/// - Parameters:
614-
/// - includeChildren: Whether to also dump children, false by default.
609+
/// - includeChildNames: Add the name of each child before the child itself.
610+
/// `false` by default.
615611
/// - includeTrivia: Add trivia to each dumped node, which the default
616612
/// dump skips.
617613
/// - converter: The location converter for the root of the tree. Adds
@@ -621,7 +617,7 @@ public extension SyntaxProtocol {
621617
/// - indentLevel: The starting indent level, 0 by default. Each level is 2
622618
/// spaces.
623619
func debugDescription(
624-
includeChildren: Bool = true,
620+
includeChildNames: Bool = false,
625621
includeTrivia: Bool = false,
626622
converter: SourceLocationConverter? = nil,
627623
mark: SyntaxProtocol? = nil,
@@ -630,7 +626,6 @@ public extension SyntaxProtocol {
630626
var str = ""
631627
debugWrite(
632628
to: &str,
633-
includeChildren: includeChildren,
634629
includeTrivia: includeTrivia,
635630
converter: converter,
636631
mark: mark,
@@ -641,7 +636,6 @@ public extension SyntaxProtocol {
641636

642637
private func debugWrite<Target: TextOutputStream>(
643638
to target: inout Target,
644-
includeChildren: Bool,
645639
includeTrivia: Bool,
646640
converter: SourceLocationConverter? = nil,
647641
mark: SyntaxProtocol? = nil,
@@ -680,22 +674,22 @@ public extension SyntaxProtocol {
680674
target.write(" ***")
681675
}
682676

683-
if includeChildren {
684-
for (num, child) in allChildren.enumerated() {
685-
let isLastChild = num == allChildren.count - 1
686-
target.write("\n")
687-
target.write(indentString)
688-
target.write(isLastChild ? "╰─" : "├─")
689-
let childIndentString = indentString + (isLastChild ? " " : "")
690-
child.debugWrite(
691-
to: &target,
692-
includeChildren: includeChildren,
693-
includeTrivia: includeTrivia,
694-
converter: converter,
695-
mark: mark,
696-
indentString: childIndentString
697-
)
677+
for (num, child) in allChildren.enumerated() {
678+
let isLastChild = num == allChildren.count - 1
679+
target.write("\n")
680+
target.write(indentString)
681+
target.write(isLastChild ? "╰─" : "├─")
682+
let childIndentString = indentString + (isLastChild ? " " : "")
683+
if case .layout(let layout) = type(of: child).structure {
684+
target.write("\(layout[num]): ")
698685
}
686+
child.debugWrite(
687+
to: &target,
688+
includeTrivia: includeTrivia,
689+
converter: converter,
690+
mark: mark,
691+
indentString: childIndentString
692+
)
699693
}
700694
}
701695
}
@@ -804,14 +798,14 @@ extension ReversedTokenSequence: CustomReflectable {
804798
}
805799
}
806800

807-
/// Expose `recursiveDescription` on raw nodes for debugging purposes.
808-
extension RawSyntaxNodeProtocol {
809-
/// Print this raw syntax node including all of its children.
810-
/// Intended for debugging purposes only.
811-
var recursiveDescription: String {
812-
return Syntax(raw: raw).recursiveDescription
813-
}
814-
}
801+
///// Expose `recursiveDescription` on raw nodes for debugging purposes.
802+
//extension RawSyntaxNodeProtocol {
803+
// /// Print this raw syntax node including all of its children.
804+
// /// Intended for debugging purposes only.
805+
// var recursiveDescription: String {
806+
// return Syntax(raw: raw).recursiveDescription
807+
// }
808+
//}
815809

816810
@available(*, unavailable, message: "use 'Syntax' instead")
817811
public struct SyntaxNode {}

0 commit comments

Comments
 (0)