/// which maps the macro definition position to the scope and the MacroData.
NamePositionScopeMacroMap macros;
- /// positions of child buffers in the buffer
+ /// Each child Buffer is listed in this map, together with where
+ /// it is included in this Buffer.
+ typedef map<Buffer const * const, DocIterator> BufferPositionMap;
+ BufferPositionMap children_positions;
+ /// We also have a map from the positions where Buffers are included
+ /// to those Buffers and their scope (whose point RKH does not yet
+ /// understand).
+ // FIXME Surely one of these is enough?
struct ScopeBuffer {
- ScopeBuffer() : buffer(nullptr) {}
+ ScopeBuffer() = default;
ScopeBuffer(DocIterator const & s, Buffer const * b)
: scope(s), buffer(b) {}
DocIterator scope;
Buffer const * buffer;
};
- /// position of children buffers in this buffer
- typedef map<Buffer const * const, DocIterator> BufferPositionMap;
- BufferPositionMap children_positions;
- /// map from children inclusion positions to their scope and their buffer
typedef map<DocIterator, ScopeBuffer> PositionScopeBufferMap;
PositionScopeBufferMap position_to_children;
void Buffer::checkChildBuffers()
{
- for (auto const & bit : d->children_positions) {
- DocIterator dit = bit.second;
- Buffer * cbuf = const_cast<Buffer *>(bit.first);
+ for (auto const & kid : d->children_positions) {
+ DocIterator const & dit = kid.second;
+ Buffer * cbuf = const_cast<Buffer *>(kid.first);
if (!cbuf || !theBufferList().isLoaded(cbuf))
continue;
Inset * inset = dit.nextInset();
onlyPath(absFileName())).absFileName();
if (oldloc == newloc)
continue;
- // the location of the child file is incorrect.
+ // the location of the child file is incorrect. e.g., it
+ // had a relative path which does not now point to the correct
+ // file (after saveAs, usually).
cbuf->setParent(nullptr);
inset_inc->setChildBuffer(nullptr);
}