Skip to content

Commit df47d38

Browse files
committed
Updates CompletionSessionID to use Atomic after rebasing
1 parent 40c37bb commit df47d38

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/SourceKitLSP/Swift/CodeCompletionSession.swift

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@ import SwiftExtensions
2222
import SwiftParser
2323
@_spi(SourceKitLSP) import SwiftRefactor
2424
import SwiftSyntax
25+
import Synchronization
2526

2627
/// Uniquely identifies a code completion session. We need this so that when resolving a code completion item, we can
2728
/// verify that the item to resolve belongs to the code completion session that is currently open.
2829
struct CompletionSessionID: Equatable {
29-
private static let nextSessionID = AtomicUInt32(initialValue: 0)
30+
private static let nextSessionID: Atomic<Int> = Atomic(0)
3031

31-
let value: UInt32
32+
let value: Int
3233

33-
init(value: UInt32) {
34+
init(value: Int) {
3435
self.value = value
3536
}
3637

3738
static func next() -> CompletionSessionID {
38-
return CompletionSessionID(value: nextSessionID.fetchAndIncrement())
39+
return CompletionSessionID(value: nextSessionID.add(1, ordering: .sequentiallyConsistent).oldValue)
3940
}
4041
}
4142

@@ -60,7 +61,7 @@ struct CompletionItemData: LSPAnyCodable {
6061
return nil
6162
}
6263
self.uri = uri
63-
self.sessionId = CompletionSessionID(value: UInt32(sessionId))
64+
self.sessionId = CompletionSessionID(value: sessionId)
6465
self.itemId = itemId
6566
}
6667

0 commit comments

Comments
 (0)