String representation of CursorKind

This commit is contained in:
Greg Shuflin committed 2026-03-19 04:28:18 -07:00
1 parent 1dc83a7d37
commit 3569373c6f
2 files changed
+7 -1

No files matched your search

+6
View File
@@ -122,4 +122,10 @@ def ofRaw (n : UInt32) : CursorKind :=
| 350 => .translationUnit
| n => .other n
instance : ToString CursorKind where
toString k :=
let r := repr k |>.pretty
let pfx := "CursorKind."
if r.startsWith pfx then (r.drop pfx.length).toString else r
end CursorKind
+1 -1
View File
@@ -8,7 +8,7 @@ partial def printAST (cursor : Clang.Cursor) (indent : Nat := 0) : IO Unit := do
let typeSpelling ← Clang.getCursorTypeSpelling cursor
let loc ← Clang.getCursorLocation cursor
let pad := "".pushn ' ' (indent * 2)
IO.println s!"{pad}{repr kind} \"{spelling}\" type=\"{typeSpelling}\" {loc.file}:{loc.line}:{loc.column}"
IO.println s!"{pad}{kind} \"{spelling}\" type=\"{typeSpelling}\" {loc.file}:{loc.line}:{loc.column}"
let children ← Clang.getChildren cursor
for child in children do
let fromMain ← Clang.isFromMainFile child