@@ -25,17 +25,6 @@ namespace refactoring {
2525using namespace swift ;
2626using namespace swift ::ide;
2727
28- namespace {
29-
30- // / Get the source file that corresponds to the given buffer.
31- SourceFile *getContainingFile (ModuleDecl *M, RangeConfig Range) {
32- auto &SM = M->getASTContext ().SourceMgr ;
33- // TODO: We should add an ID -> SourceFile mapping.
34- return M->getSourceFileContainingLocation (
35- SM.getRangeForBuffer (Range.BufferID ).getStart ());
36- }
37- } // namespace
38-
3928class RefactoringAction {
4029protected:
4130 ModuleDecl *MD;
@@ -50,14 +39,7 @@ class RefactoringAction {
5039public:
5140 RefactoringAction (ModuleDecl *MD, RefactoringOptions &Opts,
5241 SourceEditConsumer &EditConsumer,
53- DiagnosticConsumer &DiagConsumer)
54- : MD(MD), TheFile(getContainingFile(MD, Opts.Range)),
55- EditConsumer (EditConsumer), Ctx(MD->getASTContext ()),
56- SM(MD->getASTContext ().SourceMgr), DiagEngine(SM),
57- StartLoc(Lexer::getLocForStartOfToken(SM, Opts.Range.getStart(SM))),
58- PreferredName(Opts.PreferredName) {
59- DiagEngine.addConsumer (DiagConsumer);
60- }
42+ DiagnosticConsumer &DiagConsumer);
6143 virtual ~RefactoringAction () = default ;
6244 virtual bool performChange () = 0;
6345};
@@ -73,14 +55,7 @@ class TokenBasedRefactoringAction : public RefactoringAction {
7355public:
7456 TokenBasedRefactoringAction (ModuleDecl *MD, RefactoringOptions &Opts,
7557 SourceEditConsumer &EditConsumer,
76- DiagnosticConsumer &DiagConsumer)
77- : RefactoringAction(MD, Opts, EditConsumer, DiagConsumer) {
78- // Resolve the sema token and save it for later use.
79- CursorInfo =
80- evaluateOrDefault (TheFile->getASTContext ().evaluator ,
81- CursorInfoRequest{CursorInfoOwner (TheFile, StartLoc)},
82- new ResolvedCursorInfo ());
83- }
58+ DiagnosticConsumer &DiagConsumer);
8459};
8560
8661#define CURSOR_REFACTORING (KIND, NAME, ID ) \
@@ -106,13 +81,7 @@ class RangeBasedRefactoringAction : public RefactoringAction {
10681public:
10782 RangeBasedRefactoringAction (ModuleDecl *MD, RefactoringOptions &Opts,
10883 SourceEditConsumer &EditConsumer,
109- DiagnosticConsumer &DiagConsumer)
110- : RefactoringAction(MD, Opts, EditConsumer, DiagConsumer),
111- RangeInfo (evaluateOrDefault(
112- MD->getASTContext ().evaluator,
113- RangeInfoRequest(RangeInfoOwner(TheFile, Opts.Range.getStart(SM),
114- Opts.Range.getEnd(SM))),
115- ResolvedRangeInfo())) {}
84+ DiagnosticConsumer &DiagConsumer);
11685};
11786
11887#define RANGE_REFACTORING (KIND, NAME, ID ) \
0 commit comments