Skip to content

Commit 5281cdf

Browse files
committed
Add debug area
1 parent 4e92f80 commit 5281cdf

2 files changed

Lines changed: 42 additions & 3 deletions

File tree

Tool/Sources/XcodeInspector/AppInstanceInspector.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class AppInstanceInspector: ObservableObject {
66
public let processIdentifier: pid_t
77
public let bundleURL: URL?
88
public let bundleIdentifier: String?
9+
public let name: String
910

1011
public var appElement: AXUIElement {
1112
let app = AXUIElementCreateApplication(runningApplication.processIdentifier)
@@ -38,6 +39,7 @@ public class AppInstanceInspector: ObservableObject {
3839

3940
init(runningApplication: NSRunningApplication) {
4041
self.runningApplication = runningApplication
42+
name = runningApplication.localizedName ?? "Unknown"
4143
processIdentifier = runningApplication.processIdentifier
4244
bundleURL = runningApplication.bundleURL
4345
bundleIdentifier = runningApplication.bundleIdentifier

Tool/Sources/XcodeInspector/Apps/XcodeAppInstanceInspector.swift

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,6 @@ private func isCompletionPanel(_ element: AXUIElement) -> Bool {
423423

424424
public extension AXUIElement {
425425
var tabBars: [AXUIElement] {
426-
// Searching by traversing with AXUIElement is (Xcode) resource consuming, we should skip
427-
// as much as possible!
428-
429426
guard let editArea: AXUIElement = {
430427
if description == "editor area" { return self }
431428
return firstChild(where: { $0.description == "editor area" })
@@ -471,4 +468,44 @@ public extension AXUIElement {
471468

472469
return tabBars
473470
}
471+
472+
var debugArea: AXUIElement? {
473+
guard let editArea: AXUIElement = {
474+
if description == "editor area" { return self }
475+
return firstChild(where: { $0.description == "editor area" })
476+
}() else { return nil }
477+
478+
var debugArea: AXUIElement?
479+
editArea.traverse { element, _ in
480+
let description = element.description
481+
if description == "Tab Bar" {
482+
return .skipDescendants
483+
}
484+
485+
if element.identifier == "editor context" {
486+
return .skipDescendantsAndSiblings
487+
}
488+
489+
if element.isSourceEditor {
490+
return .skipDescendantsAndSiblings
491+
}
492+
493+
if description == "Code Coverage Ribbon" {
494+
return .skipDescendants
495+
}
496+
497+
if description == "Debug Area" {
498+
debugArea = element
499+
return .skipDescendants
500+
}
501+
502+
if description == "debug bar" {
503+
return .skipDescendants
504+
}
505+
506+
return .continueSearching
507+
}
508+
509+
return debugArea
510+
}
474511
}

0 commit comments

Comments
 (0)