mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[incrParse] Add coloured output indicating which code got reused
This commit is contained in:
@@ -417,9 +417,9 @@ int doIncrementalParse(const char *MainExecutablePath,
|
||||
SourceLoc End = SourceMgr.getLocForOffset(BufferID, ReuseRange.second);
|
||||
|
||||
ReuseLog << "Reused ";
|
||||
Start.printLineAndColumn(ReuseLog, SourceMgr);
|
||||
Start.printLineAndColumn(ReuseLog, SourceMgr, BufferID);
|
||||
ReuseLog << " to ";
|
||||
End.printLineAndColumn(ReuseLog, SourceMgr);
|
||||
End.printLineAndColumn(ReuseLog, SourceMgr, BufferID);
|
||||
ReuseLog << '\n';
|
||||
}
|
||||
}
|
||||
@@ -430,6 +430,21 @@ int doIncrementalParse(const char *MainExecutablePath,
|
||||
out << *Root;
|
||||
llvm::outs() << "\n";
|
||||
|
||||
auto CurrentOffset = 0;
|
||||
auto SourceText = SourceMgr.getEntireTextForBuffer(BufferID);
|
||||
|
||||
llvm::outs() << "\n\n";
|
||||
|
||||
for (auto ReuseRange : Cache.getReusedRanges()) {
|
||||
llvm::outs().changeColor(llvm::buffer_ostream::Colors::RED);
|
||||
llvm::outs() << SourceText.substr(CurrentOffset,
|
||||
ReuseRange.first - CurrentOffset);
|
||||
llvm::outs().changeColor(llvm::buffer_ostream::Colors::GREEN);
|
||||
llvm::outs() << SourceText.substr(ReuseRange.first,
|
||||
ReuseRange.second - ReuseRange.first);
|
||||
CurrentOffset = ReuseRange.second;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user