mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[incrParse] Allow whitespaces to be reparsed in test
This greatly improves the ergonomics of writing tests and outweighs the ability to test which whitespaces get parsed since their parsing overhead should be minimal.
This commit is contained in:
@@ -509,9 +509,19 @@ bool verifyReusedRegions(ByteBasedSourceRangeSet ExpectedReparseRegions,
|
||||
bool NoUnexpectedParse = true;
|
||||
|
||||
for (auto ReparseRegion : UnexpectedReparseRegions.Ranges) {
|
||||
NoUnexpectedParse = false;
|
||||
auto ReparseRange = ReparseRegion.toSourceRange(SourceMgr, BufferID);
|
||||
|
||||
// To improve the ergonomics when writing tests we do not want to complain
|
||||
// about reparsed whitespaces.
|
||||
auto RangeStr =
|
||||
CharSourceRange(SourceMgr, ReparseRange.Start, ReparseRange.End).str();
|
||||
llvm::Regex WhitespaceOnlyRegex("^\\s*$", llvm::Regex::Newline);
|
||||
if (WhitespaceOnlyRegex.match(RangeStr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NoUnexpectedParse = false;
|
||||
|
||||
llvm::errs() << "\nERROR: Unexpectedly reparsed following region:\n";
|
||||
ReparseRange.print(llvm::errs(), SourceMgr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user