Skip to content

Commit a527e20

Browse files
committed
[Index] Fix extension type location
The end loc is wrong when generic args are present, just use `getLoc` which uses the name loc.
1 parent 582462e commit a527e20

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

lib/Index/Index.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,8 @@ static bool isMemberwiseInit(swift::ValueDecl *D) {
103103
}
104104

105105
static SourceLoc getLocForExtension(ExtensionDecl *D) {
106-
// Use the 'End' token of the range, in case it is a compound name, e.g.
107-
// extension A.B {}
108-
// we want the location of 'B' token.
109-
if (auto *repr = D->getExtendedTypeRepr()) {
110-
return repr->getSourceRange().End;
111-
}
106+
if (auto *repr = D->getExtendedTypeRepr())
107+
return repr->getLoc();
112108
return SourceLoc();
113109
}
114110

test/Index/index_imported.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ extension IntArray {
9292
func flam() {}
9393
}
9494

95-
// FIXME: Column 22 here is wrong...
9695
extension ArrayOf<Int> {
97-
// CHECK: [[@LINE-1]]:22 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF | Def | rel: 0
96+
// CHECK: [[@LINE-1]]:11 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF | Def | rel: 0
9897
// CHECK-NEXT: [[@LINE-2]]:11 | type-alias/Swift | ArrayOf | s:3Lib7ArrayOfa | Ref | rel: 0
9998
// CHECK-NEXT: [[@LINE-3]]:11 | struct/Swift | Array | s:Sa | Ref,Impl,RelExt | rel: 1
10099
// CHECK-NEXT: RelExt | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF

test/Index/roles.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,8 @@ class Subclass: BaseClass {
565565
}
566566
}
567567

568-
// FIXME: Column 15 here is wrong...
569568
extension [Int] {
570-
// CHECK: [[@LINE-1]]:15 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE3fooyyF | Def | rel: 0
569+
// CHECK: [[@LINE-1]]:11 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE3fooyyF | Def | rel: 0
571570
// CHECK-NEXT: [[@LINE-2]]:11 | struct/Swift | Array | s:Sa | Ref,Impl,RelExt | rel: 1
572571
// CHECK-NEXT: RelExt | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE3fooyyF
573572
// CHECK-NEXT: [[@LINE-4]]:12 | struct/Swift | Int | s:Si | Ref | rel: 0
@@ -602,9 +601,8 @@ extension IntArray {
602601
func flam() {}
603602
}
604603

605-
// FIXME: Column 22 here is wrong...
606604
extension ArrayOf<Int> {
607-
// CHECK: [[@LINE-1]]:22 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF | Def | rel: 0
605+
// CHECK: [[@LINE-1]]:11 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF | Def | rel: 0
608606
// CHECK-NEXT: [[@LINE-2]]:11 | type-alias/Swift | ArrayOf | s:14swift_ide_test7ArrayOfa | Ref | rel: 0
609607
// CHECK-NEXT: [[@LINE-3]]:11 | struct/Swift | Array | s:Sa | Ref,Impl,RelExt | rel: 1
610608
// CHECK-NEXT: RelExt | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF

0 commit comments

Comments
 (0)