Skip to content

Commit 15ecf8d

Browse files
committed
Re-org, document
1 parent 54adb10 commit 15ecf8d

14 files changed

+92
-56
lines changed

CodeEdit/Features/LSP/Registry/PackageManagerError.swift renamed to CodeEdit/Features/LSP/Registry/Errors/PackageManagerError.swift

File renamed without changes.

CodeEdit/Features/LSP/Registry/RegistryManagerError.swift renamed to CodeEdit/Features/LSP/Registry/Errors/RegistryManagerError.swift

File renamed without changes.

CodeEdit/Features/LSP/Registry/InstallationMethod.swift renamed to CodeEdit/Features/LSP/Registry/Model/InstallationMethod.swift

File renamed without changes.

CodeEdit/Features/LSP/Registry/PackageManagerType.swift renamed to CodeEdit/Features/LSP/Registry/Model/PackageManagerType.swift

File renamed without changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// PackageSource.swift
3+
// CodeEdit
4+
//
5+
// Created by Khan Winter on 8/18/25.
6+
//
7+
8+
/// Generic package source information that applies to all installation methods.
9+
/// Takes all the necessary information from `RegistryItem`.
10+
struct PackageSource: Equatable, Codable {
11+
/// The raw source ID string from the registry
12+
let sourceId: String
13+
/// The type of the package manager
14+
let type: PackageManagerType
15+
/// Package name
16+
let pkgName: String
17+
/// The name in the registry.json file. Used for the folder name when saved.
18+
let entryName: String
19+
/// Package version
20+
let version: String
21+
/// URL for repository or download link
22+
let repositoryUrl: String?
23+
/// Git reference type if this is a git based package
24+
let gitReference: GitReference?
25+
/// Additional possible options
26+
var options: [String: String]
27+
28+
init(
29+
sourceId: String,
30+
type: PackageManagerType,
31+
pkgName: String,
32+
entryName: String,
33+
version: String,
34+
repositoryUrl: String? = nil,
35+
gitReference: GitReference? = nil,
36+
options: [String: String] = [:]
37+
) {
38+
self.sourceId = sourceId
39+
self.type = type
40+
self.pkgName = pkgName
41+
self.entryName = entryName
42+
self.version = version
43+
self.repositoryUrl = repositoryUrl
44+
self.gitReference = gitReference
45+
self.options = options
46+
}
47+
48+
enum GitReference: Equatable, Codable {
49+
case tag(String)
50+
case revision(String)
51+
}
52+
}

CodeEdit/Features/LSP/Registry/RegistryItem+Source.swift renamed to CodeEdit/Features/LSP/Registry/Model/RegistryItem+Source.swift

File renamed without changes.
File renamed without changes.

CodeEdit/Features/LSP/Registry/PackageManagerProtocol.swift

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

88
import Foundation
99

10+
/// The protocol each package manager conforms to for creating ``PackageManagerInstallOperation``s.
1011
protocol PackageManagerProtocol {
1112
var shellClient: ShellClient { get }
1213

@@ -17,49 +18,3 @@ protocol PackageManagerProtocol {
1718
/// Checks if the shell commands for the package manager are available or not
1819
func isInstalled(method installationMethod: InstallationMethod) -> PackageManagerInstallStep
1920
}
20-
21-
/// Generic package source information that applies to all installation methods.
22-
/// Takes all the necessary information from `RegistryItem`.
23-
struct PackageSource: Equatable, Codable {
24-
/// The raw source ID string from the registry
25-
let sourceId: String
26-
/// The type of the package manager
27-
let type: PackageManagerType
28-
/// Package name
29-
let pkgName: String
30-
/// The name in the registry.json file. Used for the folder name when saved.
31-
let entryName: String
32-
/// Package version
33-
let version: String
34-
/// URL for repository or download link
35-
let repositoryUrl: String?
36-
/// Git reference type if this is a git based package
37-
let gitReference: GitReference?
38-
/// Additional possible options
39-
var options: [String: String]
40-
41-
init(
42-
sourceId: String,
43-
type: PackageManagerType,
44-
pkgName: String,
45-
entryName: String,
46-
version: String,
47-
repositoryUrl: String? = nil,
48-
gitReference: GitReference? = nil,
49-
options: [String: String] = [:]
50-
) {
51-
self.sourceId = sourceId
52-
self.type = type
53-
self.pkgName = pkgName
54-
self.entryName = entryName
55-
self.version = version
56-
self.repositoryUrl = repositoryUrl
57-
self.gitReference = gitReference
58-
self.options = options
59-
}
60-
61-
enum GitReference: Equatable, Codable {
62-
case tag(String)
63-
case revision(String)
64-
}
65-
}

CodeEdit/Features/LSP/Registry/PackageManagers/Install/InstallStepConfirmation.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ enum InstallStepConfirmation {
99
case none
1010
case required(message: String)
1111
}
12-
13-
struct PackageManagerInstallStep: Identifiable {
14-
var id: String { name }
15-
let name: String
16-
let confirmation: InstallStepConfirmation
17-
let handler: (_ model: PackageManagerProgressModel) async throws -> Void
18-
}

CodeEdit/Features/LSP/Registry/PackageManagers/Install/PackageManagerInstallOperation.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
import Foundation
99
import Combine
1010

11+
/// An executable install operation for installing a ``RegistryItem``.
12+
///
13+
/// Has a single entry point, ``run()``, which kicks off the operation. UI can observe properties like the ``error``,
14+
/// ``runningState-swift.property``, or ``currentStep`` to monitor progress.
15+
///
16+
/// If a step requires confirmation, the ``waitingForConfirmation`` value will be filled.
1117
@MainActor
1218
final class PackageManagerInstallOperation: ObservableObject, Identifiable {
1319
enum RunningState {
@@ -34,10 +40,12 @@ final class PackageManagerInstallOperation: ObservableObject, Identifiable {
3440
let package: RegistryItem
3541
let steps: [PackageManagerInstallStep]
3642

43+
/// The step the operation is currently executing or stopped at.
3744
var currentStep: PackageManagerInstallStep? {
3845
steps[safe: currentStepIdx]
3946
}
4047

48+
/// The current state of the operation.
4149
var runningState: RunningState {
4250
if operationTask != nil {
4351
return .running
@@ -60,7 +68,12 @@ final class PackageManagerInstallOperation: ObservableObject, Identifiable {
6068
private var operationTask: Task<Void, Error>?
6169
private var confirmationContinuation: CheckedContinuation<Void, Never>?
6270
private var outputIdx = 0
63-
71+
72+
/// Create a new operation using a list of steps and a package description.
73+
/// See ``PackageManagerProtocol`` for
74+
/// - Parameters:
75+
/// - package: The package to install.
76+
/// - steps: The steps that make up the operation.
6477
init(package: RegistryItem, steps: [PackageManagerInstallStep]) {
6578
self.package = package
6679
self.steps = steps

0 commit comments

Comments
 (0)