Skip to content

Commit 01449ae

Browse files
committed
Update ReferencesRequest to match version 3.14 of the LSP spec
1 parent 2338339 commit 01449ae

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

Sources/LanguageServerProtocol/ReferencesRequest.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,20 @@ public struct ReferencesRequest: RequestType, Hashable {
3333
/// The document location at which to lookup symbol information.
3434
public var position: Position
3535

36-
/// Whether to include the declaration in the list of symbols, or just the references.
37-
public var includeDeclaration: Bool?
36+
public var context: ReferencesContext
3837

39-
public init(textDocument: TextDocumentIdentifier, position: Position, includeDeclaration: Bool? = nil) {
38+
public init(textDocument: TextDocumentIdentifier, position: Position, context: ReferencesContext) {
4039
self.textDocument = textDocument
4140
self.position = position
41+
self.context = context
42+
}
43+
}
44+
45+
public struct ReferencesContext: Codable, Hashable {
46+
/// Whether to include the declaration in the list of symbols, or just the references.
47+
public var includeDeclaration: Bool
48+
49+
public init(includeDeclaration: Bool) {
4250
self.includeDeclaration = includeDeclaration
4351
}
4452
}

Sources/SourceKit/SourceKitServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ extension SourceKitServer {
688688
log("performing indexed jump-to-def with usr \(usr)")
689689

690690
var roles: SymbolRole = [.reference]
691-
if req.params.includeDeclaration != false {
691+
if req.params.context.includeDeclaration {
692692
roles.formUnion([.declaration, .definition])
693693
}
694694

Tests/SourceKitTests/SourceKitTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ final class SKTests: XCTestCase {
8282

8383
let refs = try ws.sk.sendSync(ReferencesRequest(
8484
textDocument: locDef.docIdentifier,
85-
position: locDef.position))
85+
position: locDef.position,
86+
context: ReferencesContext(includeDeclaration: true)))
8687

8788
XCTAssertEqual(Set(refs), [
8889
Location(locDef),

Tests/SourceKitTests/SwiftPMIntegration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class SwiftPMIntegrationTests: XCTestCase {
2222
let call = ws.testLoc("Lib.foo:call")
2323
let def = ws.testLoc("Lib.foo:def")
2424
try ws.openDocument(call.url, language: .swift)
25-
let refs = try ws.sk.sendSync(ReferencesRequest(textDocument: call.docIdentifier, position: call.position))
25+
let refs = try ws.sk.sendSync(ReferencesRequest(textDocument: call.docIdentifier, position: call.position, context: ReferencesContext(includeDeclaration: true)))
2626

2727
XCTAssertEqual(Set(refs), [
2828
Location(call),

0 commit comments

Comments
 (0)