Skip to content

Commit 45b1f94

Browse files
committed
[Rename] Allow renaming of symbols from another module
Retrieve the serialized location when checking rename availablity so that global rename works on references outside the module it was declared in. Resolves rdar://94671287.
1 parent 6b5f449 commit 45b1f94

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/Refactoring/Refactoring.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8811,7 +8811,7 @@ void swift::ide::collectRenameAvailabilityInfo(
88118811
AvailKind = RenameAvailableKind::Unavailable_system_symbol;
88128812
} else if (VD->getClangDecl()) {
88138813
AvailKind = RenameAvailableKind::Unavailable_decl_from_clang;
8814-
} else if (VD->getStartLoc().isInvalid()) {
8814+
} else if (VD->getLoc().isInvalid()) {
88158815
AvailKind = RenameAvailableKind::Unavailable_has_no_location;
88168816
} else if (!VD->hasName()) {
88178817
AvailKind = RenameAvailableKind::Unavailable_has_no_name;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/build)
3+
// RUN: split-file --leading-lines %s %t
4+
5+
// RUN: %target-swift-frontend -emit-module -module-name MyModule -emit-module-path %t/build/MyModule.swiftmodule -emit-module-source-info-path %t/build/MyModule.swiftsourceinfo %t/Action.swift
6+
7+
//--- Action.swift
8+
public protocol Action {}
9+
10+
//--- test.swift
11+
import MyModule
12+
13+
// RUN: %sourcekitd-test -req=cursor -pos=%(line+1):19 -length=6 -cursor-action %t/test.swift -- %t/test.swift -I %t/build | %FileCheck %s
14+
func test(action: Action) { }
15+
// CHECK: ACTIONS BEGIN
16+
// CHECK-NEXT: source.refactoring.kind.rename.global
17+
// CHECK-NEXT: Global Rename
18+
// CHECK-NOT: cannot be renamed

0 commit comments

Comments
 (0)