mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #63714 from ahoppen/ahoppen/ideinspectiontarget-charsourcerange
[IDE] Check whether an AST node contains the IDE inspection point based on `CharSourceRange`
This commit is contained in:
@@ -214,6 +214,13 @@ public:
|
||||
(isBeforeInBuffer(R.Start, Loc) && isBeforeInBuffer(Loc, R.End));
|
||||
}
|
||||
|
||||
/// Returns true if range \c R contains the location \c Loc. The location
|
||||
/// \c Loc should point at the beginning of the token.
|
||||
bool rangeContainsTokenLoc(CharSourceRange R, SourceLoc Loc) const {
|
||||
return Loc == R.getStart() || (isBeforeInBuffer(R.getStart(), Loc) &&
|
||||
isBeforeInBuffer(Loc, R.getEnd()));
|
||||
}
|
||||
|
||||
/// Returns true if range \c Enclosing contains the range \c Inner.
|
||||
bool rangeContains(SourceRange Enclosing, SourceRange Inner) const {
|
||||
return rangeContainsTokenLoc(Enclosing, Inner.Start) &&
|
||||
@@ -221,10 +228,11 @@ public:
|
||||
}
|
||||
|
||||
/// Returns true if range \p R contains the code-completion location, if any.
|
||||
bool rangeContainsIDEInspectionTarget(SourceRange R) const {
|
||||
return IDEInspectionTargetBufferID
|
||||
? rangeContainsTokenLoc(R, getIDEInspectionTargetLoc())
|
||||
: false;
|
||||
bool rangeContainsIDEInspectionTarget(CharSourceRange R) const {
|
||||
if (!IDEInspectionTargetBufferID) {
|
||||
return false;
|
||||
}
|
||||
return rangeContainsTokenLoc(R, getIDEInspectionTargetLoc());
|
||||
}
|
||||
|
||||
/// Returns the buffer ID for the specified *valid* location.
|
||||
|
||||
Reference in New Issue
Block a user