10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
13
- #include " swift/IDE/SourceEntityWalker.h"
14
13
#include " swift/AST/ASTContext.h"
15
14
#include " swift/AST/ASTWalker.h"
16
15
#include " swift/AST/Decl.h"
26
25
#include " swift/Basic/SourceManager.h"
27
26
#include " swift/Parse/Lexer.h"
28
27
#include " clang/Basic/Module.h"
28
+ #include " swift/IDE/SourceEntityWalker.h"
29
+ #include " swift/IDE/Utils.h"
29
30
30
31
using namespace swift ;
31
32
@@ -93,19 +94,6 @@ class SemaAnnotator : public ASTWalker {
93
94
bool passCallArgNames (Expr *Fn, ArgumentList *ArgList);
94
95
95
96
bool shouldIgnore (Decl *D);
96
-
97
- ValueDecl *extractDecl (Expr *Fn) const {
98
- Fn = Fn->getSemanticsProvidingExpr ();
99
- if (auto *DRE = dyn_cast<DeclRefExpr>(Fn))
100
- return DRE->getDecl ();
101
- if (auto ApplyE = dyn_cast<ApplyExpr>(Fn))
102
- return extractDecl (ApplyE->getFn ());
103
- if (auto *ACE = dyn_cast<AutoClosureExpr>(Fn)) {
104
- if (auto *Unwrapped = ACE->getUnwrappedCurryThunkExpr ())
105
- return extractDecl (Unwrapped);
106
- }
107
- return nullptr ;
108
- }
109
97
};
110
98
111
99
} // end anonymous namespace
@@ -800,7 +788,11 @@ passReference(ValueDecl *D, Type Ty, SourceLoc BaseNameLoc, SourceRange Range,
800
788
if (!CtorRefs.empty () && BaseNameLoc.isValid ()) {
801
789
Expr *Fn = CtorRefs.back ()->getFn ();
802
790
if (Fn->getLoc () == BaseNameLoc) {
803
- D = extractDecl (Fn);
791
+ D = ide::getReferencedDecl (Fn).second .getDecl ();
792
+ if (D == nullptr ) {
793
+ assert (false && " Unhandled constructor reference" );
794
+ return true ;
795
+ }
804
796
CtorTyRef = TD;
805
797
}
806
798
}
@@ -815,12 +807,6 @@ passReference(ValueDecl *D, Type Ty, SourceLoc BaseNameLoc, SourceRange Range,
815
807
}
816
808
}
817
809
818
- if (D == nullptr ) {
819
- // FIXME: When does this happen?
820
- assert (false && " unhandled reference" );
821
- return true ;
822
- }
823
-
824
810
CharSourceRange CharRange =
825
811
Lexer::getCharSourceRangeFromSourceRange (D->getASTContext ().SourceMgr ,
826
812
Range);
@@ -839,7 +825,7 @@ bool SemaAnnotator::passReference(ModuleEntity Mod,
839
825
}
840
826
841
827
bool SemaAnnotator::passCallArgNames (Expr *Fn, ArgumentList *ArgList) {
842
- ValueDecl *D = extractDecl (Fn);
828
+ ValueDecl *D = ide::getReferencedDecl (Fn). second . getDecl ( );
843
829
if (!D)
844
830
return true ; // continue.
845
831
0 commit comments