@@ -212,10 +212,9 @@ final class CallHierarchyTests: XCTestCase {
212
212
result,
213
213
[
214
214
CallHierarchyItem (
215
- name: " foo " ,
215
+ name: " FilePathIndex:: foo" ,
216
216
kind: . method,
217
217
tags: nil ,
218
- detail: " FilePathIndex " ,
219
218
uri: try project. uri ( for: " lib.cpp " ) ,
220
219
range: try Range ( project. position ( of: " 2️⃣ " , in: " lib.cpp " ) ) ,
221
220
selectionRange: try Range ( project. position ( of: " 2️⃣ " , in: " lib.cpp " ) ) ,
@@ -583,10 +582,9 @@ final class CallHierarchyTests: XCTestCase {
583
582
[
584
583
CallHierarchyIncomingCall (
585
584
from: CallHierarchyItem (
586
- name: " foo() " ,
585
+ name: " MyClass. foo()" ,
587
586
kind: . method,
588
587
tags: nil ,
589
- detail: " MyClass " ,
590
588
uri: project. fileURI,
591
589
range: Range ( project. positions [ " 1️⃣ " ] ) ,
592
590
selectionRange: Range ( project. positions [ " 1️⃣ " ] ) ,
@@ -764,4 +762,92 @@ final class CallHierarchyTests: XCTestCase {
764
762
]
765
763
)
766
764
}
765
+
766
+ func testInitializerInCallHierarchy( ) async throws {
767
+ try await SkipUnless . indexOnlyHasContainedByRelationsToIndexedDecls ( )
768
+ let project = try await IndexedSingleSwiftFileTestProject (
769
+ """
770
+ func 1️⃣foo() {}
771
+
772
+ struct Bar {
773
+ 2️⃣init() {
774
+ 3️⃣foo()
775
+ }
776
+ }
777
+ """
778
+ )
779
+ let prepare = try await project. testClient. send (
780
+ CallHierarchyPrepareRequest (
781
+ textDocument: TextDocumentIdentifier ( project. fileURI) ,
782
+ position: project. positions [ " 1️⃣ " ]
783
+ )
784
+ )
785
+ let initialItem = try XCTUnwrap ( prepare? . only)
786
+ let calls = try await project. testClient. send ( CallHierarchyIncomingCallsRequest ( item: initialItem) )
787
+ XCTAssertEqual (
788
+ calls,
789
+ [
790
+ CallHierarchyIncomingCall (
791
+ from: CallHierarchyItem (
792
+ name: " Bar.init() " ,
793
+ kind: . constructor,
794
+ tags: nil ,
795
+ uri: project. fileURI,
796
+ range: Range ( project. positions [ " 2️⃣ " ] ) ,
797
+ selectionRange: Range ( project. positions [ " 2️⃣ " ] ) ,
798
+ data: . dictionary( [
799
+ " usr " : . string( " s:4test3BarVACycfc " ) ,
800
+ " uri " : . string( project. fileURI. stringValue) ,
801
+ ] )
802
+ ) ,
803
+ fromRanges: [ Range ( project. positions [ " 3️⃣ " ] ) ]
804
+ )
805
+ ]
806
+ )
807
+ }
808
+
809
+ func testCallHierarchyOfNestedClass( ) async throws {
810
+ try await SkipUnless . indexOnlyHasContainedByRelationsToIndexedDecls ( )
811
+ let project = try await IndexedSingleSwiftFileTestProject (
812
+ """
813
+ func 1️⃣foo() {}
814
+
815
+ struct Outer {
816
+ struct Bar {
817
+ 2️⃣init() {
818
+ 3️⃣foo()
819
+ }
820
+ }
821
+ }
822
+ """
823
+ )
824
+ let prepare = try await project. testClient. send (
825
+ CallHierarchyPrepareRequest (
826
+ textDocument: TextDocumentIdentifier ( project. fileURI) ,
827
+ position: project. positions [ " 1️⃣ " ]
828
+ )
829
+ )
830
+ let initialItem = try XCTUnwrap ( prepare? . only)
831
+ let calls = try await project. testClient. send ( CallHierarchyIncomingCallsRequest ( item: initialItem) )
832
+ XCTAssertEqual (
833
+ calls,
834
+ [
835
+ CallHierarchyIncomingCall (
836
+ from: CallHierarchyItem (
837
+ name: " Bar.init() " ,
838
+ kind: . constructor,
839
+ tags: nil ,
840
+ uri: project. fileURI,
841
+ range: Range ( project. positions [ " 2️⃣ " ] ) ,
842
+ selectionRange: Range ( project. positions [ " 2️⃣ " ] ) ,
843
+ data: . dictionary( [
844
+ " usr " : . string( " s:4test5OuterV3BarVAEycfc " ) ,
845
+ " uri " : . string( project. fileURI. stringValue) ,
846
+ ] )
847
+ ) ,
848
+ fromRanges: [ Range ( project. positions [ " 3️⃣ " ] ) ]
849
+ )
850
+ ]
851
+ )
852
+ }
767
853
}
0 commit comments