Skip to content

Commit 920bba7

Browse files
committed
Format files
1 parent 1e0ed33 commit 920bba7

4 files changed

Lines changed: 74 additions & 64 deletions

File tree

Tool/Sources/CodeiumService/LanguageServer/CodeiumInstallationManager.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public struct CodeiumInstallationManager {
1111
case badURL(String)
1212
case invalidResponse
1313
case invalidData
14-
14+
1515
var errorDescription: String? {
1616
switch self {
1717
case .badURL: return "URL is invalid"
@@ -20,14 +20,13 @@ public struct CodeiumInstallationManager {
2020
}
2121
}
2222
}
23-
23+
2424
public func getLatestSupportedVersion() -> String {
25-
if isEnterprise{
26-
return UserDefaults.shared.value(for: \.codeiumEnterpriseVersion);
25+
if isEnterprise {
26+
return UserDefaults.shared.value(for: \.codeiumEnterpriseVersion)
2727
}
28-
29-
return Self.latestSupportedVersion;
30-
28+
29+
return Self.latestSupportedVersion
3130
}
3231

3332
func getEnterprisePortalVersion() async throws -> String {

Tool/Sources/CodeiumService/LanguageServer/CodeiumLanguageServer.swift

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class CodeiumLanguageServer {
3636
self.supportURL = supportURL
3737
self.terminationHandler = terminationHandler
3838
self.launchHandler = launchHandler
39-
self.project_paths = []
39+
project_paths = []
4040
process = Process()
4141
transport = IOTransport()
4242

@@ -64,16 +64,16 @@ final class CodeiumLanguageServer {
6464
if isEnterpriseMode {
6565
process.arguments?.append("--enterprise_mode")
6666
}
67-
67+
6868
let indexEnabled = UserDefaults.shared.value(for: \.codeiumIndexEnabled)
6969
if indexEnabled {
7070
let indexingMaxFileSize = UserDefaults.shared.value(for: \.codeiumIndexingMaxFileSize)
71-
if (indexEnabled) {
72-
process.arguments?.append("--enable_local_search")
73-
process.arguments?.append("--enable_index_service")
74-
process.arguments?.append("--search_max_workspace_file_count")
75-
process.arguments?.append("\(indexingMaxFileSize)")
76-
Logger.codeium.info("Indexing Enabled")
71+
if indexEnabled {
72+
process.arguments?.append("--enable_local_search")
73+
process.arguments?.append("--enable_index_service")
74+
process.arguments?.append("--search_max_workspace_file_count")
75+
process.arguments?.append("\(indexingMaxFileSize)")
76+
Logger.codeium.info("Indexing Enabled")
7777
}
7878
}
7979

@@ -193,38 +193,39 @@ extension CodeiumLanguageServer: CodeiumLSP {
193193
}
194194
}
195195
}
196-
196+
197197
func updateIndexing() async {
198198
let indexEnabled = UserDefaults.shared.value(for: \.codeiumIndexEnabled)
199199
if !indexEnabled {
200200
return
201201
}
202-
203202

204203
let curr_proj_paths = await getProjectPaths()
205-
204+
206205
// Add all workspaces that are in the curr_proj_paths but not in the previous project paths
207206
for curr_proj_path in curr_proj_paths {
208-
if !self.project_paths.contains(curr_proj_path) && FileManager.default.fileExists(atPath: curr_proj_path) {
209-
_ = try? await self.sendRequest(CodeiumRequest.AddTrackedWorkspace(requestBody: .init(
207+
if !project_paths.contains(curr_proj_path) && FileManager.default
208+
.fileExists(atPath: curr_proj_path)
209+
{
210+
_ = try? await sendRequest(CodeiumRequest.AddTrackedWorkspace(requestBody: .init(
210211
workspace: curr_proj_path
211212
)))
212213
}
213214
}
214-
215+
215216
// Remove all workspaces that are in previous project paths but not in the curr_proj_paths
216-
for proj_path in self.project_paths {
217-
if !curr_proj_paths.contains(proj_path) && FileManager.default.fileExists(atPath: proj_path) {
218-
_ = try? await self.sendRequest(CodeiumRequest.RemoveTrackedWorkspace(requestBody: .init(
217+
for proj_path in project_paths {
218+
if !curr_proj_paths.contains(proj_path) && FileManager.default
219+
.fileExists(atPath: proj_path)
220+
{
221+
_ = try? await sendRequest(CodeiumRequest.RemoveTrackedWorkspace(requestBody: .init(
219222
workspace: proj_path
220223
)))
221224
}
222225
}
223226
// These should be identical now
224-
self.project_paths = curr_proj_paths
225-
227+
project_paths = curr_proj_paths
226228
}
227-
228229
}
229230

230231
final class IOTransport {
@@ -329,7 +330,7 @@ class WorkspaceParser: NSObject, XMLParserDelegate {
329330
self.workspaceFileURL = workspaceFileURL
330331
self.workspaceBaseURL = workspaceBaseURL
331332
}
332-
333+
333334
func parse() -> [String] {
334335
guard let parser = XMLParser(contentsOf: workspaceFileURL) else {
335336
print("Failed to create XML parser for file: \(workspaceFileURL.path)")
@@ -339,9 +340,15 @@ class WorkspaceParser: NSObject, XMLParserDelegate {
339340
parser.parse()
340341
return projectPaths
341342
}
342-
343+
343344
// XMLParserDelegate methods
344-
func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String]) {
345+
func parser(
346+
_ parser: XMLParser,
347+
didStartElement elementName: String,
348+
namespaceURI: String?,
349+
qualifiedName qName: String?,
350+
attributes attributeDict: [String: String]
351+
) {
345352
if elementName == "FileRef", let location = attributeDict["location"] {
346353
var project_path: String
347354
if location.starts(with: "group:") && pathEndsWithXcodeproj(location) {
@@ -350,28 +357,29 @@ class WorkspaceParser: NSObject, XMLParserDelegate {
350357
return
351358
}
352359
let relative_base_path = relative_project_url.deletingLastPathComponent()
353-
project_path = (self.workspaceBaseURL.appendingPathComponent(relative_base_path.relativePath)).standardized.path
354-
} else if location.starts(with: "absolute:") && pathEndsWithXcodeproj(location){
360+
project_path = (
361+
workspaceBaseURL
362+
.appendingPathComponent(relative_base_path.relativePath)
363+
).standardized.path
364+
} else if location.starts(with: "absolute:") && pathEndsWithXcodeproj(location) {
355365
let abs_url = URL(fileURLWithPath: String(location.dropFirst("absolute:".count)))
356366
project_path = abs_url.deletingLastPathComponent().standardized.path
357367
} else {
358368
return
359369
}
360370
if FileManager.default.fileExists(atPath: project_path) {
361-
362371
projectPaths.append(project_path)
363372
}
364373
}
365374
}
366-
375+
367376
func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error) {
368377
print("Failed to parse XML: \(parseError.localizedDescription)")
369378
}
370-
379+
371380
func pathEndsWithXcodeproj(_ path: String) -> Bool {
372381
return path.hasSuffix(".xcodeproj")
373382
}
374-
375383
}
376384

377385
public func getProjectPaths() async -> [String] {
@@ -380,10 +388,14 @@ public func getProjectPaths() async -> [String] {
380388
}
381389

382390
let workspacebaseURL = workspaceURL.deletingLastPathComponent()
383-
391+
384392
let workspaceContentsURL = workspaceURL.appendingPathComponent("contents.xcworkspacedata")
385-
386-
let parser = WorkspaceParser(workspaceFileURL: workspaceContentsURL, workspaceBaseURL: workspacebaseURL)
393+
394+
let parser = WorkspaceParser(
395+
workspaceFileURL: workspaceContentsURL,
396+
workspaceBaseURL: workspacebaseURL
397+
)
387398
let absolutePaths = parser.parse()
388399
return absolutePaths
389400
}
401+

Tool/Sources/CodeiumService/Services/CodeiumService.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public class CodeiumService {
147147
try await Task.sleep(nanoseconds: 5_000_000_000)
148148
}
149149
}
150-
150+
151151
self.workspaceTask = Task { [weak self] in
152152
while true {
153153
try Task.checkCancellation()
@@ -257,7 +257,7 @@ extension CodeiumService: CodeiumSuggestionServiceType {
257257

258258
requestCounter += 1
259259
let languageId = languageIdentifierFromFileURL(fileURL)
260-
let relativePath = getRelativePath(of: fileURL)
260+
let relativePath = getRelativePath(of: fileURL)
261261

262262
let task = Task {
263263
let request = try await CodeiumRequest.GetCompletion(requestBody: .init(
@@ -350,7 +350,7 @@ extension CodeiumService: CodeiumSuggestionServiceType {
350350
URLQueryItem(name: "ide_name", value: metadata.ide_name),
351351
URLQueryItem(name: "ide_version", value: metadata.ide_version),
352352
URLQueryItem(name: "web_server_url", value: webServerUrl),
353-
URLQueryItem(name: "ide_telemetry_enabled", value: "true")
353+
URLQueryItem(name: "ide_telemetry_enabled", value: "true"),
354354
]
355355

356356
if let url = components.url {
@@ -367,7 +367,7 @@ extension CodeiumService: CodeiumSuggestionServiceType {
367367
metadata: getMetadata(),
368368
completion_id: suggestion.id
369369
)))
370-
}
370+
}
371371

372372
public func notifyOpenTextDocument(fileURL: URL, content: String) async throws {
373373
let relativePath = getRelativePath(of: fileURL)
@@ -392,14 +392,14 @@ extension CodeiumService: CodeiumSuggestionServiceType {
392392
}
393393

394394
public func notifyOpenWorkspace(workspaceURL: URL) async throws {
395-
_ = try await (try setupServerIfNeeded()).sendRequest(
395+
_ = try await (setupServerIfNeeded()).sendRequest(
396396
CodeiumRequest
397397
.AddTrackedWorkspace(requestBody: .init(workspace: workspaceURL.path))
398398
)
399399
}
400400

401401
public func notifyCloseWorkspace(workspaceURL: URL) async throws {
402-
_ = try await (try setupServerIfNeeded()).sendRequest(
402+
_ = try await (setupServerIfNeeded()).sendRequest(
403403
CodeiumRequest
404404
.RemoveTrackedWorkspace(requestBody: .init(workspace: workspaceURL.path))
405405
)
@@ -432,7 +432,7 @@ extension CodeiumService: CodeiumSuggestionServiceType {
432432
.map(\.url.path),
433433
workspace_paths: [workspaceURL.path]
434434
))
435-
_ = try await (try setupServerIfNeeded()).sendRequest(request)
435+
_ = try await (setupServerIfNeeded()).sendRequest(request)
436436
}
437437

438438
public func terminate() {

Tool/Sources/Preferences/Keys.swift

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ public extension UserDefaultPreferenceKeys {
187187
var runNodeWith: PreferenceKey<NodeRunner> {
188188
.init(defaultValue: .env, key: "RunNodeWith")
189189
}
190-
190+
191191
var gitHubCopilotLoadKeyChainCertificates: PreferenceKey<Bool> {
192192
.init(defaultValue: false, key: "GitHubCopilotLoadKeyChainCertificates")
193193
}
194-
194+
195195
var gitHubCopilotPretendIDEToBeVSCode: PreferenceKey<Bool> {
196196
.init(defaultValue: false, key: "GitHubCopilotPretendIDEToBeVSCode")
197197
}
@@ -215,19 +215,18 @@ public extension UserDefaultPreferenceKeys {
215215
var codeiumApiUrl: PreferenceKey<String> {
216216
.init(defaultValue: "", key: "CodeiumApiUrl")
217217
}
218-
218+
219219
var codeiumEnterpriseVersion: PreferenceKey<String> {
220220
.init(defaultValue: "", key: "CodeiumEnterpriseVersion")
221221
}
222222

223223
var codeiumIndexEnabled: PreferenceKey<Bool> {
224224
.init(defaultValue: false, key: "CodeiumIndexEnabled")
225225
}
226-
226+
227227
var codeiumIndexingMaxFileSize: PreferenceKey<Int> {
228228
.init(defaultValue: 5000, key: "CodeiumIndexingMaxFileSize")
229229
}
230-
231230
}
232231

233232
// MARK: - Chat Models
@@ -319,7 +318,7 @@ public extension UserDefaultPreferenceKeys {
319318
var hideCommonPrecedingSpacesInPromptToCode: PreferenceKey<Bool> {
320319
.init(defaultValue: true, key: "HideCommonPrecedingSpacesInPromptToCode")
321320
}
322-
321+
323322
var wrapCodeInPromptToCode: PreferenceKey<Bool> {
324323
.init(defaultValue: true, key: "WrapCodeInPromptToCode")
325324
}
@@ -375,23 +374,23 @@ public extension UserDefaultPreferenceKeys {
375374
var acceptSuggestionWithTab: PreferenceKey<Bool> {
376375
.init(defaultValue: true, key: "AcceptSuggestionWithTab")
377376
}
378-
377+
379378
var acceptSuggestionWithModifierCommand: PreferenceKey<Bool> {
380379
.init(defaultValue: false, key: "SuggestionWithModifierCommand")
381380
}
382-
381+
383382
var acceptSuggestionWithModifierOption: PreferenceKey<Bool> {
384383
.init(defaultValue: false, key: "SuggestionWithModifierOption")
385384
}
386-
385+
387386
var acceptSuggestionWithModifierControl: PreferenceKey<Bool> {
388387
.init(defaultValue: false, key: "SuggestionWithModifierControl")
389388
}
390-
389+
391390
var acceptSuggestionWithModifierShift: PreferenceKey<Bool> {
392391
.init(defaultValue: false, key: "SuggestionWithModifierShift")
393392
}
394-
393+
395394
var acceptSuggestionWithModifierOnlyForSwift: PreferenceKey<Bool> {
396395
.init(defaultValue: false, key: "SuggestionWithModifierOnlyForSwift")
397396
}
@@ -403,7 +402,7 @@ public extension UserDefaultPreferenceKeys {
403402
var isSuggestionSenseEnabled: PreferenceKey<Bool> {
404403
.init(defaultValue: false, key: "IsSuggestionSenseEnabled")
405404
}
406-
405+
407406
var isSuggestionTypeInTheMiddleEnabled: PreferenceKey<Bool> {
408407
.init(defaultValue: true, key: "IsSuggestionTypeInTheMiddleEnabled")
409408
}
@@ -506,23 +505,23 @@ public extension UserDefaultPreferenceKeys {
506505
var preferredChatModelIdForWebScope: PreferenceKey<String> {
507506
.init(defaultValue: "", key: "PreferredChatModelIdForWebScope")
508507
}
509-
508+
510509
var disableFloatOnTopWhenTheChatPanelIsDetached: PreferenceKey<Bool> {
511510
.init(defaultValue: true, key: "DisableFloatOnTopWhenTheChatPanelIsDetached")
512511
}
513-
512+
514513
var keepFloatOnTopIfChatPanelAndXcodeOverlaps: PreferenceKey<Bool> {
515514
.init(defaultValue: true, key: "KeepFloatOnTopIfChatPanelAndXcodeOverlaps")
516515
}
517-
516+
518517
var openChatMode: PreferenceKey<OpenChatMode> {
519518
.init(defaultValue: .chatPanel, key: "OpenChatMode")
520519
}
521-
520+
522521
var openChatInBrowserURL: PreferenceKey<String> {
523522
.init(defaultValue: "", key: "OpenChatInBrowserURL")
524523
}
525-
524+
526525
var openChatInBrowserInInAppBrowser: PreferenceKey<Bool> {
527526
.init(defaultValue: true, key: "OpenChatInBrowserInInAppBrowser")
528527
}
@@ -579,7 +578,7 @@ public extension UserDefaultPreferenceKeys {
579578
key: "ChatCodeFont"
580579
)
581580
}
582-
581+
583582
var terminalFont: PreferenceKey<UserDefaultsStorageBox<StorableFont>> {
584583
.init(
585584
defaultValue: .init(.init(nsFont: .monospacedSystemFont(ofSize: 12, weight: .regular))),

0 commit comments

Comments
 (0)