Merge pull request #63906 from bnbarham/add-nested-expansion

[Refactor] Allow expanding nested macros
This commit is contained in:
Ben Barham
2023-03-02 20:43:35 -08:00
committed by GitHub
19 changed files with 242 additions and 145 deletions

View File

@@ -730,27 +730,12 @@ RenameRangeCollector::indexSymbolToRenameLoc(const index::IndexSymbol &symbol,
isFunctionLike, isNonProtocolType};
}
ArrayRef<SourceFile*>
collectSourceFiles(ModuleDecl *MD, SmallVectorImpl<SourceFile *> &Scratch) {
for (auto Unit : MD->getFiles()) {
if (auto SF = dyn_cast<SourceFile>(Unit)) {
Scratch.push_back(SF);
}
}
return llvm::makeArrayRef(Scratch);
}
/// Get the source file that contains the given range and belongs to the module.
/// Get the source file that corresponds to the given buffer.
SourceFile *getContainingFile(ModuleDecl *M, RangeConfig Range) {
SmallVector<SourceFile*, 4> Files;
for (auto File : collectSourceFiles(M, Files)) {
if (File->getBufferID()) {
if (File->getBufferID().value() == Range.BufferId) {
return File;
}
}
}
return nullptr;
auto &SM = M->getASTContext().SourceMgr;
// TODO: We should add an ID -> SourceFile mapping.
return M->getSourceFileContainingLocation(
SM.getRangeForBuffer(Range.BufferID).getStart());
}
class RefactoringAction {
@@ -8804,7 +8789,7 @@ getDescriptiveRefactoringKindName(RefactoringKind Kind) {
}
SourceLoc swift::ide::RangeConfig::getStart(SourceManager &SM) {
return SM.getLocForLineCol(BufferId, Line, Column);
return SM.getLocForLineCol(BufferID, Line, Column);
}
SourceLoc swift::ide::RangeConfig::getEnd(SourceManager &SM) {