File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -2000,7 +2000,7 @@ extension SourceKitServer {
2000
2000
}
2001
2001
return index. occurrences ( ofUSR: usr, roles: roles) . compactMap { indexToLSPLocation ( $0. location) }
2002
2002
}
2003
- return locations. sorted ( )
2003
+ return locations. unique . sorted ( )
2004
2004
}
2005
2005
2006
2006
private func indexToLSPCallHierarchyItem(
Original file line number Diff line number Diff line change
1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // This source file is part of the Swift.org open source project
4
+ //
5
+ // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See https://swift.org/LICENSE.txt for license information
9
+ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ import LanguageServerProtocol
14
+ import SKTestSupport
15
+ import XCTest
16
+
17
+ /// Tests that test the overall state of the SourceKit-LSP server, that's not really specific to any language
18
+ final class ReferencesTests : XCTestCase {
19
+ func testReferencesInMacro( ) async throws {
20
+ let ws = try await IndexedSingleSwiftFileWorkspace (
21
+ """
22
+ import Observation
23
+
24
+ @available(macOS 14.0, *)
25
+ 1️⃣@Observable
26
+ class 2️⃣Foo {
27
+ var x: Int = 2
28
+ }
29
+ """
30
+ )
31
+
32
+ let response = try await ws. testClient. send (
33
+ ReferencesRequest (
34
+ textDocument: TextDocumentIdentifier ( ws. fileURI) ,
35
+ position: ws. positions [ " 2️⃣ " ] ,
36
+ context: ReferencesContext ( includeDeclaration: true )
37
+ )
38
+ )
39
+ XCTAssertEqual (
40
+ response,
41
+ [
42
+ Location ( uri: ws. fileURI, range: Range ( ws. positions [ " 1️⃣ " ] ) ) ,
43
+ Location ( uri: ws. fileURI, range: Range ( ws. positions [ " 2️⃣ " ] ) ) ,
44
+ ]
45
+ )
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments