forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpers.swift
More file actions
33 lines (28 loc) · 1.04 KB
/
Helpers.swift
File metadata and controls
33 lines (28 loc) · 1.04 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
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)
}
static func fromRunningApplication(_ runningApplication: NSRunningApplication) -> AXUIElement {
let app = AXUIElementCreateApplication(runningApplication.processIdentifier)
app.setMessagingTimeout(2)
return app
}
}