The class will be moved into libToolingCore as followup.
The new behaviors in this patch:
- New #include is inserted in the right position in a #include block to
preserver sorted #includes. This is best effort - only works when the
block is already sorted.
- When inserting multiple #includes to the end of a file which doesn't
end with a "\n" character, a "\n" will be prepended to each #include.
This is a special and rare case that was previously handled. This is now
relaxed to avoid complexity as it's rare in practice.
I would personally keep the function non-const and not use mutable fields here.
Even though it's logically const, I would strive towards keeping the things const only if there are actually immutable
One particular problem that could be avoided is accidentally calling the const methods concurrently on different threads.
But up to you if you actually want to make this change.