-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathHelpers.swift
More file actions
41 lines (34 loc) · 1.31 KB
/
Helpers.swift
File metadata and controls
41 lines (34 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import AppKit
import Foundation
public extension NSRunningApplication {
var isXcode: Bool { bundleIdentifier == "com.apple.dt.Xcode" }
var isCopilotForXcodeExtensionService: Bool {
bundleIdentifier == Bundle.main.bundleIdentifier
}
}
public extension FileManager {
func fileIsDirectory(atPath path: String) -> Bool {
var isDirectory: ObjCBool = false
let exists = fileExists(atPath: path, isDirectory: &isDirectory)
return isDirectory.boolValue && exists
}
}
extension AXUIElement {
var realtimeDocumentURL: URL? {
guard let window = self.focusedWindow,
window.identifier == "Xcode.WorkspaceWindow"
else { return nil }
return WorkspaceXcodeWindowInspector.extractDocumentURL(windowElement: window)
}
var realtimeWorkspaceURL: URL? {
guard let window = self.focusedWindow,
window.identifier == "Xcode.WorkspaceWindow"
else { return nil }
return WorkspaceXcodeWindowInspector.extractWorkspaceURL(windowElement: window)
}
static func fromRunningApplication(_ runningApplication: NSRunningApplication) -> AXUIElement {
let app = AXUIElementCreateApplication(runningApplication.processIdentifier)
app.setMessagingTimeout(2)
return app
}
}