[IDE][Index][test] Update sourcekit/indexing support for latest property wrapper changes

The backing property for 'foo' is now '_foo', and the projected value '$foo'.
This updates Indexing to report occurrences of foo within both $foo and
_foo occurrences (rather than just $foo - the old _foo).

FindRelatedIdents was similarlar updated, so it reports 'foo' ranges in both
_foo and $foo.

CursorInfo now reports the USR, documentation, and location of foo when invoked
occurrences of $foo or _foo, but now leaves the name, type, and annotated
declaration of _foo/$foo as is. Having the same USR ensures rename invoked on
any of them will still rename via foo. Reporting foo's documentation comment
instead is just to present something more useful to the user.
This commit is contained in:
Nathan Hawes
2019-06-27 17:38:24 -07:00
parent c547e6885e
commit e08a6c1994
15 changed files with 201 additions and 66 deletions

View File

@@ -91,11 +91,6 @@ bool CursorInfoResolver::tryResolve(ValueDecl *D, TypeDecl *CtorTyRef,
VD = Parent;
}
}
// If this is the backing property of a property wrapper, treat it as
// the wrapped value instead.
if (auto *Wrapped = VD->getOriginalWrappedProperty()) {
D = Wrapped;
}
}
CursorInfo.setValueRef(D, CtorTyRef, ExtTyRef, IsRef, Ty, ContainerType);
return true;
@@ -791,9 +786,10 @@ bool NameMatcher::tryResolve(ASTWalker::ParentTy Node, SourceLoc NameLoc,
WasResolved = true;
}
if (Range.getByteLength() > 1 && Range.str().front() == '$') {
// Also try after any leading dollar for name references of wrapped
// properties, e.g. 'foo' in '$foo' occurrences.
if (Range.getByteLength() > 1 &&
(Range.str().front() == '_' || Range.str().front() == '$')) {
// Also try after any leading _ or $ for name references of wrapped
// properties, e.g. 'foo' in '_foo' and '$foo' occurrences.
auto NewRange = CharSourceRange(Range.getStart().getAdvancedLoc(1),
Range.getByteLength() - 1);
if (NewRange.getStart() == Next.Loc) {