Skip to content

Commit 342548f

Browse files
committed
Patch Cleaning
1 parent 0f429bd commit 342548f

File tree

8 files changed

+41
-21
lines changed

8 files changed

+41
-21
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@
453453
6C9AE6962D1DD71500FAE8D2 /* SemanticTokenHighlightProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C9AE6952D1DD71500FAE8D2 /* SemanticTokenHighlightProvider.swift */; };
454454
6C9AE6992D1DD84600FAE8D2 /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6C9AE6982D1DD84600FAE8D2 /* CodeEditSourceEditor */; };
455455
6C9AE69B2D1DF80300FAE8D2 /* SemanticTokenStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C9AE69A2D1DF80300FAE8D2 /* SemanticTokenStorage.swift */; };
456-
6C9AE69D2D1DF84300FAE8D2 /* ConcreteSemanticTokenStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C9AE69C2D1DF84300FAE8D2 /* ConcreteSemanticTokenStorage.swift */; };
456+
6C9AE69D2D1DF84300FAE8D2 /* LSPSemanticTokenStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C9AE69C2D1DF84300FAE8D2 /* LSPSemanticTokenStorage.swift */; };
457457
6CA1AE952B46950000378EAB /* EditorInstance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA1AE942B46950000378EAB /* EditorInstance.swift */; };
458458
6CAAF68A29BC9C2300A1F48A /* (null) in Sources */ = {isa = PBXBuildFile; };
459459
6CAAF69229BCC71C00A1F48A /* (null) in Sources */ = {isa = PBXBuildFile; };
@@ -1153,7 +1153,7 @@
11531153
6C9AE6702D14A9F700FAE8D2 /* LazyServiceWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyServiceWrapper.swift; sourceTree = "<group>"; };
11541154
6C9AE6952D1DD71500FAE8D2 /* SemanticTokenHighlightProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SemanticTokenHighlightProvider.swift; sourceTree = "<group>"; };
11551155
6C9AE69A2D1DF80300FAE8D2 /* SemanticTokenStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SemanticTokenStorage.swift; sourceTree = "<group>"; };
1156-
6C9AE69C2D1DF84300FAE8D2 /* ConcreteSemanticTokenStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConcreteSemanticTokenStorage.swift; sourceTree = "<group>"; };
1156+
6C9AE69C2D1DF84300FAE8D2 /* LSPSemanticTokenStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LSPSemanticTokenStorage.swift; sourceTree = "<group>"; };
11571157
6CA1AE942B46950000378EAB /* EditorInstance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorInstance.swift; sourceTree = "<group>"; };
11581158
6CABB1A029C5593800340467 /* SearchPanelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchPanelView.swift; sourceTree = "<group>"; };
11591159
6CB52DC82AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CEWorkspaceFileManager+FileManagement.swift"; sourceTree = "<group>"; };
@@ -3106,7 +3106,7 @@
31063106
6C9AE69E2D1DF8DE00FAE8D2 /* SemanticTokenStorage */ = {
31073107
isa = PBXGroup;
31083108
children = (
3109-
6C9AE69C2D1DF84300FAE8D2 /* ConcreteSemanticTokenStorage.swift */,
3109+
6C9AE69C2D1DF84300FAE8D2 /* LSPSemanticTokenStorage.swift */,
31103110
6C52466F2D1E5CC100F57F11 /* SemanticTokenRange.swift */,
31113111
6C9AE69A2D1DF80300FAE8D2 /* SemanticTokenStorage.swift */,
31123112
);
@@ -4537,7 +4537,7 @@
45374537
B6041F5229D7D6D6000F3454 /* SettingsWindow.swift in Sources */,
45384538
6139B9162C29B36500CA584B /* CETaskStatus.swift in Sources */,
45394539
B6EA1FF829DB78DB001BF195 /* ThemeSettingThemeRow.swift in Sources */,
4540-
6C9AE69D2D1DF84300FAE8D2 /* ConcreteSemanticTokenStorage.swift in Sources */,
4540+
6C9AE69D2D1DF84300FAE8D2 /* LSPSemanticTokenStorage.swift in Sources */,
45414541
587B9E7629301D8F00AC7927 /* GitTime.swift in Sources */,
45424542
587B9E5D29301D8F00AC7927 /* GitLabUserRouter.swift in Sources */,
45434543
588847692992ABCA00996D95 /* Array+SortURLs.swift in Sources */,

CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

CodeEdit/Features/Documents/CodeFileDocument/CodeFileDocument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ final class CodeFileDocument: NSDocument, ObservableObject {
5454
@Published var lspCoordinator: LSPContentCoordinator?
5555

5656
/// Set by ``LanguageServer`` when initialized.
57-
@Published var lspHighlightProvider: SemanticTokenHighlightProvider<ConcreteSemanticTokenStorage>?
57+
@Published var lspHighlightProvider: SemanticTokenHighlightProvider<LSPSemanticTokenStorage>?
5858

5959
/// Used to override detected languages.
6060
@Published var language: CodeLanguage?

CodeEdit/Features/LSP/Editor/SemanticTokenStorage/ConcreteSemanticTokenStorage.swift renamed to CodeEdit/Features/LSP/Editor/SemanticTokenStorage/LSPSemanticTokenStorage.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import CodeEditSourceEditor
1616
/// tokens and their decoded counterparts. It supports applying delta updates from the language server.
1717
///
1818
/// See ``SemanticTokenHighlightProvider`` for it's connection to the editor view.
19-
final class ConcreteSemanticTokenStorage: SemanticTokenStorage {
19+
final class LSPSemanticTokenStorage: SemanticTokenStorage {
20+
/// Represents compressed semantic token data received from a language server.
2021
struct CurrentState {
2122
let requestId: String?
2223
let tokenData: [UInt32]
@@ -59,7 +60,7 @@ final class ConcreteSemanticTokenStorage: SemanticTokenStorage {
5960
/// To calculate invalidated ranges:
6061
/// - Grabs all semantic tokens that *will* be updated and invalidates their ranges
6162
/// - Loops over all inserted tokens and invalidates their ranges
62-
/// This may result in duplicated ranges. It's up to the object using this method to de-duplicate if necessary.
63+
/// This may result in duplicated ranges. It's up to the caller to de-duplicate if necessary.
6364
///
6465
/// - Parameter deltas: The deltas to apply.
6566
/// - Returns: All ranges invalidated by the applied deltas.
@@ -129,6 +130,7 @@ final class ConcreteSemanticTokenStorage: SemanticTokenStorage {
129130
// MARK: - Binary Search
130131

131132
/// Perform a binary search to find the given position
133+
/// - Complexity: O(log n)
132134
func findIndex(of position: Position, data: ArraySlice<SemanticToken>) -> Int {
133135
var lower = 0
134136
var upper = data.count

CodeEdit/Features/LSP/Editor/SemanticTokenStorage/SemanticTokenStorage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import CodeEditSourceEditor
1111

1212
/// Defines a protocol for an object to provide a storage mechanism for semantic tokens.
1313
///
14-
/// There is only one concrete type that conforms to this in CE, but this protocol is used in testing.
15-
/// See ``ConcreteSemanticTokenStorage`` for use.
14+
/// There is only one concrete type that conforms to this in CE, but this protocol is useful in testing.
15+
/// See ``LSPSemanticTokenStorage`` for use.
1616
protocol SemanticTokenStorage: AnyObject {
1717
var lastRequestId: String? { get }
1818

CodeEdit/Features/LSP/LanguageServer/Capabilities/LanguageServer+DocumentSync.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ extension LanguageServer {
2929
)
3030
try await lspInstance.textDocumentDidOpen(DidOpenTextDocumentParams(textDocument: textDocument))
3131

32-
await updateIsolatedDocument(document)
33-
try await document.lspHighlightProvider?.documentDidChange()
32+
try await updateIsolatedDocument(document)
3433
} catch {
3534
logger.warning("addDocument: Error \(error)")
3635
throw error
@@ -126,9 +125,10 @@ extension LanguageServer {
126125
}
127126

128127
@MainActor
129-
private func updateIsolatedDocument(_ document: CodeFileDocument) {
128+
private func updateIsolatedDocument(_ document: CodeFileDocument) async throws {
130129
document.lspCoordinator = openFiles.contentCoordinator(for: document)
131130
document.lspHighlightProvider = openFiles.semanticHighlighter(for: document)
131+
try await document.lspHighlightProvider?.documentDidChange()
132132
}
133133

134134
// swiftlint:disable line_length

CodeEdit/Features/LSP/LanguageServer/LanguageServerFileMap.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class LanguageServerFileMap {
1515
let uri: String
1616
var documentVersion: Int
1717
var contentCoordinator: LSPContentCoordinator
18-
var semanticHighlighter: SemanticTokenHighlightProvider<ConcreteSemanticTokenStorage>?
18+
var semanticHighlighter: SemanticTokenHighlightProvider<LSPSemanticTokenStorage>?
1919
}
2020

2121
private var trackedDocuments: NSMapTable<NSString, CodeFileDocument>
@@ -98,7 +98,7 @@ class LanguageServerFileMap {
9898

9999
func semanticHighlighter(
100100
for document: CodeFileDocument
101-
) -> SemanticTokenHighlightProvider<ConcreteSemanticTokenStorage>? {
101+
) -> SemanticTokenHighlightProvider<LSPSemanticTokenStorage>? {
102102
guard let uri = document.languageServerURI else { return nil }
103103
return trackedDocumentData[uri]?.semanticHighlighter
104104
}

CodeEditTests/Features/LSP/SemanticTokenStorageTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import LanguageServerProtocol
1212

1313
final class SemanticTokenStorageTests: XCTestCase {
1414
func testInvalidation() {
15-
let storage = ConcreteSemanticTokenStorage()
16-
storage.state = ConcreteSemanticTokenStorage.CurrentState(
15+
let storage = LSPSemanticTokenStorage()
16+
storage.state = LSPSemanticTokenStorage.CurrentState(
1717
requestId: nil,
1818
tokenData: [0, 0, 2, 0, 0],
1919
tokens: [SemanticToken(line: 0, char: 0, length: 2, type: 0, modifiers: 0)]

0 commit comments

Comments
 (0)