mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[sourcekitd] Fix cursor resolving when pointing inside string interpolations of return statements
rdar://36336648
This commit is contained in:
@@ -149,9 +149,17 @@ bool CursorInfoResolver::walkToDeclPost(Decl *D) {
|
||||
}
|
||||
|
||||
bool CursorInfoResolver::walkToStmtPre(Stmt *S) {
|
||||
// Getting the character range for the statement, to account for interpolation
|
||||
// strings. The token range for the interpolation string is the whole string,
|
||||
// with begin/end locations pointing at the beginning of the string, so if
|
||||
// there is a token location inside the string, it will seem as if it is out
|
||||
// of the source range, unless we convert to character range.
|
||||
|
||||
// FIXME: Even implicit Stmts should have proper ranges that include any
|
||||
// non-implicit Stmts (fix Stmts created for lazy vars).
|
||||
if (!S->isImplicit() && !rangeContainsLoc(S->getSourceRange()))
|
||||
if (!S->isImplicit() &&
|
||||
!rangeContainsLoc(Lexer::getCharSourceRangeFromSourceRange(
|
||||
getSourceMgr(), S->getSourceRange())))
|
||||
return false;
|
||||
return !tryResolve(S);
|
||||
}
|
||||
@@ -249,6 +257,14 @@ SourceManager &NameMatcher::getSourceMgr() const {
|
||||
return SrcFile.getASTContext().SourceMgr;
|
||||
}
|
||||
|
||||
bool CursorInfoResolver::rangeContainsLoc(SourceRange Range) const {
|
||||
return getSourceMgr().rangeContainsTokenLoc(Range, LocToResolve);
|
||||
}
|
||||
|
||||
bool CursorInfoResolver::rangeContainsLoc(CharSourceRange Range) const {
|
||||
return Range.contains(LocToResolve);
|
||||
}
|
||||
|
||||
std::vector<ResolvedLoc> NameMatcher::resolve(ArrayRef<UnresolvedLoc> Locs, ArrayRef<Token> Tokens) {
|
||||
|
||||
// Note the original indices and sort them in reverse source order
|
||||
|
||||
Reference in New Issue
Block a user