@@ -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
230231final 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
377385public 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+
0 commit comments