-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathContextUtils.swift
More file actions
34 lines (28 loc) · 1.41 KB
/
ContextUtils.swift
File metadata and controls
34 lines (28 loc) · 1.41 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
import ConversationServiceProvider
import XcodeInspector
import Foundation
import Logger
import Workspace
import SystemUtils
public struct ContextUtils {
public static func getFilesInActiveWorkspace(workspaceURL: URL?) -> [FileReference] {
if let workspaceURL = workspaceURL, let info = WorkspaceFile.getWorkspaceInfo(workspaceURL: workspaceURL) {
return WorkspaceFile.getFilesInActiveWorkspace(workspaceURL: info.workspaceURL, workspaceRootURL: info.projectURL)
}
guard let workspaceURL = XcodeInspector.shared.realtimeActiveWorkspaceURL,
let workspaceRootURL = XcodeInspector.shared.realtimeActiveProjectURL else {
return []
}
let files = WorkspaceFile.getFilesInActiveWorkspace(workspaceURL: workspaceURL, workspaceRootURL: workspaceRootURL)
return files
}
public static let workspaceReadabilityErrorMessageProvider: FileUtils.ReadabilityErrorMessageProvider = { status in
switch status {
case .readable: return nil
case .notFound:
return "Copilot can't access this workspace. It may have been removed or is temporarily unavailable."
case .permissionDenied:
return "Copilot can't access this workspace. Enable \"Files & Folders\" access in [System Settings](x-apple.systempreferences:com.apple.preference.security?Privacy_FilesAndFolders)"
}
}
}