mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST] Factor out Expr::getNameLoc
There are a bunch of AST nodes that can have associated DeclNameLocs, make sure we cover them all. I don't think this makes a difference for `unwrapPropertyWrapperParameterTypes` since the extra cases should be invalid, but for cursor info it ensures we handle UnresolvedMemberExprs.
This commit is contained in:
@@ -214,23 +214,6 @@ private:
|
||||
return Action::Continue();
|
||||
}
|
||||
|
||||
/// Retrieve the name location for an expression that supports cursor info.
|
||||
DeclNameLoc getExprNameLoc(Expr *E) {
|
||||
if (auto *DRE = dyn_cast<DeclRefExpr>(E))
|
||||
return DRE->getNameLoc();
|
||||
|
||||
if (auto *UDRE = dyn_cast<UnresolvedDeclRefExpr>(E))
|
||||
return UDRE->getNameLoc();
|
||||
|
||||
if (auto *ODRE = dyn_cast<OverloadedDeclRefExpr>(E))
|
||||
return ODRE->getNameLoc();
|
||||
|
||||
if (auto *UDE = dyn_cast<UnresolvedDotExpr>(E))
|
||||
return UDE->getNameLoc();
|
||||
|
||||
return DeclNameLoc();
|
||||
}
|
||||
|
||||
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
|
||||
if (auto closure = dyn_cast<ClosureExpr>(E)) {
|
||||
DeclContextStack.push_back(closure);
|
||||
@@ -247,7 +230,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if (getExprNameLoc(E).getBaseNameLoc() != LocToResolve)
|
||||
if (E->getNameLoc().getBaseNameLoc() != LocToResolve)
|
||||
return Action::Continue(E);
|
||||
|
||||
assert(Result == nullptr);
|
||||
|
||||
Reference in New Issue
Block a user