Skip to content

Commit 4000b67

Browse files
committed
Make Model Conform To CodeSuggestionDelegate
1 parent 1629154 commit 4000b67

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

Example/CodeEditSourceEditorExample/CodeEditSourceEditorExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/CodeEditSourceEditor/JumpToDefinition/JumpToDefinitionLink.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@
88
import Foundation
99
import SwiftUI
1010

11-
public struct JumpToDefinitionLink: Identifiable, Sendable {
11+
public struct JumpToDefinitionLink: Identifiable, Sendable, CodeSuggestionEntry {
1212
public var id: String { url?.absoluteString ?? "\(targetRange)" }
1313
/// Leave as `nil` if the link is in the same document.
1414
public let url: URL?
15-
public let targetPosition: CursorPosition
15+
public let targetPosition: CursorPosition?
1616
public let targetRange: NSRange
1717

18-
public let typeName: String
19-
public let sourcePreview: String
18+
public let label: String
19+
public let sourcePreview: String?
2020

2121
public let image: Image
2222
public let imageColor: Color
2323

24+
public var detail: String? { nil }
25+
public var pathComponents: [String]? { url?.pathComponents ?? [] }
26+
public var deprecated: Bool { false }
27+
2428
public init(
2529
url: URL?,
2630
targetPosition: CursorPosition,
@@ -33,7 +37,7 @@ public struct JumpToDefinitionLink: Identifiable, Sendable {
3337
self.url = url
3438
self.targetPosition = targetPosition
3539
self.targetRange = targetRange
36-
self.typeName = typeName
40+
self.label = typeName
3741
self.sourcePreview = sourcePreview
3842
self.image = image
3943
self.imageColor = imageColor

Sources/CodeEditSourceEditor/JumpToDefinition/JumpToDefinitionModel.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ final class JumpToDefinitionModel {
4949
}
5050

5151
// MARK: - Jump Action
52-
52+
5353
/// Performs the jump action.
5454
/// - Parameter location: The location to query the delegate for.
5555
func performJump(at location: NSRange) {
@@ -132,3 +132,27 @@ final class JumpToDefinitionModel {
132132
)
133133
}
134134
}
135+
136+
extension JumpToDefinitionModel: CodeSuggestionDelegate {
137+
func completionSuggestionsRequested(
138+
textView: TextViewController,
139+
cursorPosition: CursorPosition
140+
) async -> (windowPosition: CursorPosition, items: [CodeSuggestionEntry])? {
141+
nil
142+
}
143+
144+
nonisolated func completionOnCursorMove(
145+
textView: TextViewController,
146+
cursorPosition: CursorPosition
147+
) -> [CodeSuggestionEntry]? {
148+
nil
149+
}
150+
151+
nonisolated func completionWindowApplyCompletion(
152+
item: CodeSuggestionEntry,
153+
textView: TextViewController,
154+
cursorPosition: CursorPosition
155+
) {
156+
157+
}
158+
}

Sources/CodeEditSourceEditor/TreeSitter/TreeSitterClient+Temporary.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
extension TreeSitterClient {
11-
func temporaryHighlight() -> NSAttributedString {
12-
13-
}
11+
// func temporaryHighlight() -> NSAttributedString {
12+
//
13+
// }
1414
}

0 commit comments

Comments
 (0)