mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[IDE] Update CursorInfo and FindRelatedIdents to treat property wrapper backing properties as the underlying property
This is the final piece to get rename and findRelatedIdents to include all foo and $foo occurrences, for example, in the set of occurrences to be renamed or shown, regardless of whether they were initiated on a foo or $foo. Resolves rdar://problem/51695783.
This commit is contained in:
@@ -1884,8 +1884,11 @@ private:
|
||||
bool walkToDeclPre(Decl *D, CharSourceRange Range) override {
|
||||
if (Cancelled)
|
||||
return false;
|
||||
if (auto *V = dyn_cast<VarDecl>(D))
|
||||
D = V->getCanonicalVarDecl();
|
||||
if (auto *V = dyn_cast<VarDecl>(D)) {
|
||||
// Handle references to the implicitly generated vars in case statements
|
||||
// matching multiple patterns
|
||||
D = V->getCanonicalVarDecl();
|
||||
}
|
||||
if (D == Dcl)
|
||||
return passId(Range);
|
||||
return true;
|
||||
@@ -1896,10 +1899,19 @@ private:
|
||||
if (Cancelled)
|
||||
return false;
|
||||
|
||||
if (auto *V = dyn_cast<VarDecl>(D))
|
||||
if (auto *V = dyn_cast<VarDecl>(D)) {
|
||||
D = V->getCanonicalVarDecl();
|
||||
else if (CtorTyRef)
|
||||
|
||||
// If we have a backing property of a property wrapper, use the wrapped
|
||||
// property instead (i.e. if this is $foo, pretend it's foo).
|
||||
if (auto *Wrapped = V->getOriginalWrappedProperty()) {
|
||||
assert(Range.getByteLength() > 1 && Range.str().front() == '$');
|
||||
D = Wrapped;
|
||||
Range = CharSourceRange(Range.getStart().getAdvancedLoc(1), Range.getByteLength() - 1);
|
||||
}
|
||||
} else if (CtorTyRef) {
|
||||
D = CtorTyRef;
|
||||
}
|
||||
|
||||
if (D == Dcl)
|
||||
return passId(Range);
|
||||
|
||||
Reference in New Issue
Block a user