Skip to content

Commit b03be81

Browse files
committed
Rename to LegacyActiveDocumentChatContextCollector
1 parent cb1a085 commit b03be81

3 files changed

Lines changed: 48 additions & 45 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import Foundation
2+
import SuggestionModel
3+
import XcodeInspector
4+
5+
struct Information {
6+
let editorContent: SourceEditor.Content?
7+
let selectedContent: String
8+
let documentURL: URL
9+
let projectURL: URL
10+
let language: CodeLanguage
11+
}
12+
13+
func getEditorInformation() -> Information {
14+
let editorContent = XcodeInspector.shared.focusedEditor?.content
15+
let documentURL = XcodeInspector.shared.activeDocumentURL
16+
let projectURL = XcodeInspector.shared.activeProjectURL
17+
let language = languageIdentifierFromFileURL(documentURL)
18+
19+
if let editorContent, let range = editorContent.selections.first {
20+
let startIndex = min(
21+
max(0, range.start.line),
22+
editorContent.lines.endIndex - 1
23+
)
24+
let endIndex = min(
25+
max(startIndex, range.end.line),
26+
editorContent.lines.endIndex - 1
27+
)
28+
let selectedContent = editorContent.lines[startIndex...endIndex]
29+
return .init(
30+
editorContent: editorContent,
31+
selectedContent: selectedContent.joined(),
32+
documentURL: documentURL,
33+
projectURL: projectURL,
34+
language: language
35+
)
36+
}
37+
38+
return .init(
39+
editorContent: editorContent,
40+
selectedContent: "",
41+
documentURL: documentURL,
42+
projectURL: projectURL,
43+
language: language
44+
)
45+
}
46+

Core/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/ActiveDocumentChatContextCollector.swift renamed to Core/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/LegacyActiveDocumentChatContextCollector.swift

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import SuggestionModel
55
import XcodeInspector
66
import ChatContextCollector
77

8-
public struct ActiveDocumentChatContextCollector: ChatContextCollector {
8+
public struct LegacyActiveDocumentChatContextCollector: ChatContextCollector {
99
public init() {}
1010

1111
public func generateContext(
@@ -104,47 +104,4 @@ public struct ActiveDocumentChatContextCollector: ChatContextCollector {
104104
}
105105
}
106106

107-
extension ActiveDocumentChatContextCollector {
108-
struct Information {
109-
let editorContent: SourceEditor.Content?
110-
let selectedContent: String
111-
let documentURL: URL
112-
let projectURL: URL
113-
let language: CodeLanguage
114-
}
115-
116-
func getEditorInformation() -> Information {
117-
let editorContent = XcodeInspector.shared.focusedEditor?.content
118-
let documentURL = XcodeInspector.shared.activeDocumentURL
119-
let projectURL = XcodeInspector.shared.activeProjectURL
120-
let language = languageIdentifierFromFileURL(documentURL)
121-
122-
if let editorContent, let range = editorContent.selections.first {
123-
let startIndex = min(
124-
max(0, range.start.line),
125-
editorContent.lines.endIndex - 1
126-
)
127-
let endIndex = min(
128-
max(startIndex, range.end.line),
129-
editorContent.lines.endIndex - 1
130-
)
131-
let selectedContent = editorContent.lines[startIndex...endIndex]
132-
return .init(
133-
editorContent: editorContent,
134-
selectedContent: selectedContent.joined(),
135-
documentURL: documentURL,
136-
projectURL: projectURL,
137-
language: language
138-
)
139-
}
140-
141-
return .init(
142-
editorContent: editorContent,
143-
selectedContent: "",
144-
documentURL: documentURL,
145-
projectURL: projectURL,
146-
language: language
147-
)
148-
}
149-
}
150107

Core/Sources/ChatService/AllContextCollector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ChatContextCollector
33
import WebChatContextCollector
44

55
let allContextCollectors: [any ChatContextCollector] = [
6-
ActiveDocumentChatContextCollector(),
6+
LegacyActiveDocumentChatContextCollector(),
77
WebChatContextCollector(),
88
]
99

0 commit comments

Comments
 (0)