Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A Swift symbol demangling library. Converts mangled Swift symbols into human-rea
mangled string → Demangler or OldDemangler → Node tree → NodePrinter → demangled string
```

- **Public API** (`String+Demangling.swift`): `String.demangled`, `String.demangling(_:)`, `String.symbolKind`
- **Public API** (`String+Demangling.swift`): `String.demangled`, `String.demangling(_:)`, `String.node`, `String.symbolKind`; `Node` traversal: `kind`, `children`, `text`, `index`, type checks (`isAlias`, `isClass`, `isEnum`, `isProtocol`, `isStruct`), kind queries (`isDeclName`, `isAnyGeneric`, `isEntity`, `isRequirement`, `isContext`, `isFunctionAttr`, `isMacroExpansion`)
- **Demangler** (`Demangler.swift`): Handles modern mangling (`$s`, `$S` prefixes). Stack-based iterative parsing
- **OldDemangler** (`OldDemangler.swift`): Handles legacy `_T` prefix. Recursive descent parsing
- **Demanglerable protocol** (`Demanglerable.swift`): Low-level parsing interface shared by both demanglers (`peekChar`, `nextChar`, `nextIf`, etc.)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDemangle/Demangler/Demangler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2873,7 +2873,7 @@ class Demangler: Demanglerable, Mangling {
}

var context = popNode { kind in
kind.isMacroExpandion
kind.isMacroExpansion
}

if context == nil {
Expand Down
9 changes: 5 additions & 4 deletions Sources/SwiftDemangle/Demangler/String+Demangling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public extension String {
}
})
}

var node: Node? {
demangleSymbolAsNode(printDebugInformation: false)
}

var symbolKind: Node.Kind? {
guard let node = demangleSymbolAsNode(printDebugInformation: false) else {
return nil
}
return node.extractSymbolKind()
node?.extractSymbolKind()
}
}
33 changes: 17 additions & 16 deletions Sources/SwiftDemangle/Node/Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class Node {

private weak var parent: Node?

private(set) var kind: Kind
public private(set) var kind: Kind
private(set) var payload: Payload
private(set) var _children: [Node] {
didSet {
Expand All @@ -22,6 +22,8 @@ public final class Node {
}

var copyOfChildren: [Node] { _children }

public var children: [Node] { copyOfChildren }

fileprivate var numberOfParent: Int {
var count = 0
Expand Down Expand Up @@ -222,7 +224,7 @@ public final class Node {
kind == .Identifier && text == desired
}

var text: String {
public var text: String {
if case let .text(text) = self.payload {
return text
} else {
Expand All @@ -234,7 +236,7 @@ public final class Node {
self.payload.isText
}

var index: UInt64? {
public var index: UInt64? {
switch self.payload {
case let .index(index):
return index
Expand Down Expand Up @@ -696,7 +698,7 @@ extension Node {

var isClassType: Bool { kind == .Class }

var isAlias: Bool {
public var isAlias: Bool {
switch self.kind {
case .Type:
return firstChild.isAlias
Expand All @@ -707,7 +709,7 @@ extension Node {
}
}

var isClass: Bool {
public var isClass: Bool {
switch self.kind {
case .Type:
return firstChild.isClass
Expand All @@ -718,7 +720,7 @@ extension Node {
}
}

var isEnum: Bool {
public var isEnum: Bool {
switch self.kind {
case .Type:
return firstChild.isEnum
Expand All @@ -729,7 +731,7 @@ extension Node {
}
}

var isProtocol: Bool {
public var isProtocol: Bool {
switch self.kind {
case .Type:
return firstChild.isProtocol
Expand All @@ -740,7 +742,7 @@ extension Node {
}
}

var isStruct: Bool {
public var isStruct: Bool {
switch self.kind {
case .Type:
return firstChild.isStruct
Expand Down Expand Up @@ -1593,36 +1595,35 @@ extension Node.Kind {
.HasSymbolQuery,
]

var isDeclName: Bool {
public var isDeclName: Bool {
Self.declNames.contains(self)
}

var isAnyGeneric: Bool {
public var isAnyGeneric: Bool {
Self.anyGenerics.contains(self)
}

var isEntity: Bool {
public var isEntity: Bool {
if self == .Type {
return true
} else {
return isContext
}
}

var isRequirement: Bool {
public var isRequirement: Bool {
Self.requirements.contains(self)
}


var isContext: Bool {
public var isContext: Bool {
Self.contexts.contains(self)
}

var isFunctionAttr: Bool {
public var isFunctionAttr: Bool {
Self.functionAttrs.contains(self)
}

var isMacroExpandion: Bool {
public var isMacroExpansion: Bool {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed typo.

switch self {
case .AccessorAttachedMacroExpansion,
.MemberAttributeAttachedMacroExpansion,
Expand Down
Loading