forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkspaceFileProvider.swift
More file actions
38 lines (30 loc) · 1.34 KB
/
WorkspaceFileProvider.swift
File metadata and controls
38 lines (30 loc) · 1.34 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
import ConversationServiceProvider
import CopilotForXcodeKit
import Foundation
public protocol WorkspaceFileProvider {
func getProjects(by workspaceURL: URL) -> [URL]
func getFilesInActiveWorkspace(workspaceURL: URL, workspaceRootURL: URL) -> [FileReference]
func isXCProject(_ url: URL) -> Bool
func isXCWorkspace(_ url: URL) -> Bool
func fileExists(atPath: String) -> Bool
}
public class FileChangeWatcherWorkspaceFileProvider: WorkspaceFileProvider {
public init() {}
public func getProjects(by workspaceURL: URL) -> [URL] {
guard let workspaceInfo = WorkspaceFile.getWorkspaceInfo(workspaceURL: workspaceURL)
else { return [] }
return WorkspaceFile.getProjects(workspace: workspaceInfo).compactMap { URL(string: $0.uri) }
}
public func getFilesInActiveWorkspace(workspaceURL: URL, workspaceRootURL: URL) -> [FileReference] {
return WorkspaceFile.getFilesInActiveWorkspace(workspaceURL: workspaceURL, workspaceRootURL: workspaceRootURL)
}
public func isXCProject(_ url: URL) -> Bool {
return WorkspaceFile.isXCProject(url)
}
public func isXCWorkspace(_ url: URL) -> Bool {
return WorkspaceFile.isXCWorkspace(url)
}
public func fileExists(atPath: String) -> Bool {
return FileManager.default.fileExists(atPath: atPath)
}
}