Skip to content

Commit 1db6a66

Browse files
Small refactors
1 parent b5d7186 commit 1db6a66

File tree

9 files changed

+14
-13
lines changed

9 files changed

+14
-13
lines changed

CodeEdit/Features/LSP/Registry/InstallationQueueManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/// A class to manage queued installations of language servers
11-
class InstallationQueueManager {
11+
final class InstallationQueueManager {
1212
static let shared: InstallationQueueManager = .init()
1313

1414
/// The maximum number of concurrent installations allowed

CodeEdit/Features/LSP/Registry/PackageManagerProtocol.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ import Foundation
1010
protocol PackageManagerProtocol {
1111
var shellClient: ShellClient { get }
1212

13+
/// Performs any initialization steps for installing a package, such as creating the directory
14+
/// and virtual environments.
1315
func initialize(in packagePath: URL) async throws
16+
/// Calls the shell commands to install a package
1417
func install(method installationMethod: InstallationMethod) async throws
18+
/// Gets the location of the binary that was installed
1519
func getBinaryPath(for package: String) -> String
20+
/// Checks if the shell commands for the package manager are available or not
1621
func isInstalled() async -> Bool
1722
}
1823

CodeEdit/Features/LSP/Registry/PackageManagers/CargoPackageManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
class CargoPackageManager: PackageManagerProtocol {
10+
final class CargoPackageManager: PackageManagerProtocol {
1111
private let installationDirectory: URL
1212

1313
internal let shellClient: ShellClient
@@ -80,7 +80,7 @@ class CargoPackageManager: PackageManagerProtocol {
8080
let output = versionOutput.reduce(into: "") {
8181
$0 += $1.trimmingCharacters(in: .whitespacesAndNewlines)
8282
}
83-
return output.contains("cargo")
83+
return output.starts(with: "cargo")
8484
} catch {
8585
print("Cargo version check failed: \(error)")
8686
return false

CodeEdit/Features/LSP/Registry/PackageManagers/GithubPackageManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
class GithubPackageManager: PackageManagerProtocol {
10+
final class GithubPackageManager: PackageManagerProtocol {
1111
private let installationDirectory: URL
1212

1313
internal let shellClient: ShellClient

CodeEdit/Features/LSP/Registry/PackageManagers/GolangPackageManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
class GolangPackageManager: PackageManagerProtocol {
10+
final class GolangPackageManager: PackageManagerProtocol {
1111
private let installationDirectory: URL
1212
internal let shellClient: ShellClient
1313

CodeEdit/Features/LSP/Registry/PackageManagers/NPMPackageManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
class NPMPackageManager: PackageManagerProtocol {
10+
final class NPMPackageManager: PackageManagerProtocol {
1111
private let installationDirectory: URL
1212

1313
internal let shellClient: ShellClient

CodeEdit/Features/LSP/Registry/PackageManagers/PipPackageManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
class PipPackageManager: PackageManagerProtocol {
10+
final class PipPackageManager: PackageManagerProtocol {
1111
private let installationDirectory: URL
1212

1313
internal let shellClient: ShellClient

CodeEdit/Features/LSP/Registry/RegistryManager.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ import ZIPFoundation
1212
final class RegistryManager {
1313
static let shared: RegistryManager = .init()
1414

15-
internal let installPath = FileManager.default.homeDirectoryForCurrentUser
16-
.appending(path: "Library")
17-
.appending(path: "Application Support")
18-
.appending(path: "CodeEdit")
19-
.appending(path: "language-servers")
15+
internal let installPath = Settings.shared.baseURL.appending(path: "language-servers")
2016

2117
/// The URL of where the registry.json file will be downloaded from
2218
internal let registryURL = URL(

CodeEdit/Features/Settings/Pages/Extensions/LanguageServerRowView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ struct LanguageServerRowView: View, Equatable {
245245
let colors: [Color] = [
246246
.blue, .green, .orange, .red, .purple, .pink, .teal, .yellow, .indigo, .cyan
247247
]
248-
let hashValue = abs(cleanedTitle.hashValue) % colors.count
248+
let hashValue = abs(cleanedTitle.hash) % colors.count
249249
return AnyShapeStyle(colors[hashValue].gradient)
250250
}
251251

0 commit comments

Comments
 (0)