Skip to content

Commit 93bc397

Browse files
committed
add my comments
1 parent 0517f3b commit 93bc397

4 files changed

Lines changed: 17 additions & 0 deletions

File tree

Tool/Sources/BuiltinExtension/BuiltinExtensionWorkspacePlugin.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public final class BuiltinExtensionWorkspacePlugin: WorkspacePlugin {
99
super.init(workspace: workspace)
1010
}
1111

12+
// this calls Copilot notifyOpenTextDocument
1213
override public func didOpenFilespace(_ filespace: Filespace) {
1314
notifyOpenFile(filespace: filespace)
1415
}
@@ -32,6 +33,7 @@ public final class BuiltinExtensionWorkspacePlugin: WorkspacePlugin {
3233
}
3334
}
3435

36+
// this calls Copilot notifyOpenTextDocument
3537
public func notifyOpenFile(filespace: Filespace) {
3638
Task {
3739
guard filespace.isTextReadable else { return }

Tool/Sources/GitHubCopilotService/GitHubCopilotExtension.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public final class GitHubCopilotExtension: BuiltinExtension {
4242

4343
public func workspaceDidClose(_: WorkspaceInfo) {}
4444

45+
// this calls Copilot notifyOpenTextDocument
4546
public func workspace(_ workspace: WorkspaceInfo, didOpenDocumentAt documentURL: URL) {
4647
guard isLanguageServerInUse else { return }
4748
// check if file size is larger than 15MB, if so, return immediately

Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotService.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public protocol GitHubCopilotSuggestionServiceType {
3636
func notifyShown(_ completion: CodeSuggestion) async
3737
func notifyAccepted(_ completion: CodeSuggestion, acceptedLength: Int?) async
3838
func notifyRejected(_ completions: [CodeSuggestion]) async
39+
// tells Copilot LSP that a file has been opened
3940
func notifyOpenTextDocument(fileURL: URL, content: String) async throws
4041
func notifyChangeTextDocument(fileURL: URL, content: String, version: Int) async throws
4142
func notifyCloseTextDocument(fileURL: URL) async throws

Tool/Sources/XcodeInspector/XcodeInspector.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ public final class XcodeInspector: ObservableObject {
140140
latestNonRootWorkspaceURL = nil
141141
}
142142

143+
// finds running Xcode instances
143144
let runningApplications = NSWorkspace.shared.runningApplications
144145
xcodes = runningApplications
145146
.filter { $0.isXcode }
147+
// creates a XcodeAppInstanceInspector for each Xcode instance
146148
.map(XcodeAppInstanceInspector.init(runningApplication:))
147149
let activeXcode = xcodes.first(where: \.isActive)
148150
latestActiveXcode = activeXcode ?? xcodes.first
@@ -160,6 +162,7 @@ public final class XcodeInspector: ObservableObject {
160162
}
161163

162164
await withThrowingTaskGroup(of: Void.self) { [weak self] group in
165+
// activation
163166
group.addTask { [weak self] in // Did activate app
164167
let sequence = NSWorkspace.shared.notificationCenter
165168
.notifications(named: NSWorkspace.didActivateApplicationNotification)
@@ -193,6 +196,7 @@ public final class XcodeInspector: ObservableObject {
193196
}
194197
}
195198

199+
// termination
196200
group.addTask { [weak self] in // Did terminate app
197201
let sequence = NSWorkspace.shared.notificationCenter
198202
.notifications(named: NSWorkspace.didTerminateApplicationNotification)
@@ -242,6 +246,7 @@ public final class XcodeInspector: ObservableObject {
242246
}
243247
}
244248

249+
// accessibility API issues
245250
group.addTask { [weak self] in // malfunctioning
246251
let sequence = NotificationCenter.default
247252
.notifications(named: .accessibilityAPIMalfunctioning)
@@ -267,6 +272,10 @@ public final class XcodeInspector: ObservableObject {
267272
}
268273
}
269274

275+
// Get the focused UI element
276+
// Determine if it's a source editor
277+
// Monitor for focus changes
278+
270279
@XcodeInspectorActor
271280
private func setActiveXcode(_ xcode: XcodeAppInstanceInspector) {
272281
previousActiveApplication = activeApplication
@@ -279,9 +288,12 @@ public final class XcodeInspector: ObservableObject {
279288

280289
activeXcode = xcode
281290
latestActiveXcode = xcode
291+
// active document
282292
activeDocumentURL = xcode.documentURL
293+
// focused window
283294
focusedWindow = xcode.focusedWindow
284295
completionPanel = xcode.completionPanel
296+
// project root
285297
activeProjectRootURL = xcode.projectRootURL
286298
activeWorkspaceURL = xcode.workspaceURL
287299
focusedWindow = xcode.focusedWindow
@@ -304,6 +316,7 @@ public final class XcodeInspector: ObservableObject {
304316
}
305317

306318
focusedElement = getFocusedElementAndRecordStatus(xcode.appElement)
319+
// focused editor
307320
if let editorElement = focusedElement, editorElement.isSourceEditor {
308321
focusedEditor = .init(
309322
runningApplication: xcode.runningApplication,

0 commit comments

Comments
 (0)