mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
This adds a sourcekitd plugin that drives the code completion requests. It also includes a `CompletionScoring` module that’s used to rank code completion results based on their contextual match, allowing us to show more relevant code completion results at the top.
49 lines
1.5 KiB
Swift
49 lines
1.5 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import Foundation
|
|
|
|
extension MatchCollator {
|
|
package struct Match {
|
|
/// For client use, has no meaning to CompletionScoring, useful when mapping Match instances back to
|
|
/// higher level constructs.
|
|
package var identifier: Int
|
|
|
|
package var batchIndex: Int
|
|
|
|
package var candidateIndex: Int
|
|
|
|
/// Items with the same (groupID, batchID) sort together. Initially used to locate types with their initializers.
|
|
package var groupID: Int?
|
|
|
|
package var score: CompletionScore
|
|
|
|
package init(batchIndex: Int, candidateIndex: Int, groupID: Int?, score: CompletionScore) {
|
|
self.init(
|
|
identifier: 0,
|
|
batchIndex: batchIndex,
|
|
candidateIndex: candidateIndex,
|
|
groupID: groupID,
|
|
score: score
|
|
)
|
|
}
|
|
|
|
package init(identifier: Int, batchIndex: Int, candidateIndex: Int, groupID: Int?, score: CompletionScore) {
|
|
self.identifier = identifier
|
|
self.batchIndex = batchIndex
|
|
self.candidateIndex = candidateIndex
|
|
self.groupID = groupID
|
|
self.score = score
|
|
}
|
|
}
|
|
}
|