Avoid storing a SourceManager on JSONFixitWriter

Switch to storing the necessary edit information
instead.
This commit is contained in:
Hamish Knight
2023-09-15 18:27:49 +01:00
parent 746128c7aa
commit febb019a86
4 changed files with 52 additions and 30 deletions

View File

@@ -216,7 +216,7 @@ class JSONFixitWriter
std::string FixitsOutputPath;
std::unique_ptr<llvm::raw_ostream> OSPtr;
bool FixitAll;
std::vector<SingleEdit> AllEdits;
SourceEdits AllEdits;
public:
JSONFixitWriter(std::string fixitsOutputPath,
@@ -229,9 +229,8 @@ private:
const DiagnosticInfo &Info) override {
if (!(FixitAll || shouldTakeFixit(Info)))
return;
for (const auto &Fix : Info.FixIts) {
AllEdits.push_back({SM, Fix.getRange(), Fix.getText().str()});
}
for (const auto &Fix : Info.FixIts)
AllEdits.addEdit(SM, Fix.getRange(), Fix.getText());
}
bool finishProcessing() override {
@@ -251,7 +250,7 @@ private:
return true;
}
swift::writeEditsInJson(llvm::makeArrayRef(AllEdits), *OS);
swift::writeEditsInJson(AllEdits, *OS);
return false;
}
};