see the source code:
void TokensTree::RecalcData()
{
#if CC_TOKEN_DEBUG_OUTPUT
wxStopWatch sw;
#endif
TRACE(_T("RecalcData() : Calculating full inheritance tree."));
// first loop to convert ancestors string to token indices for each token
for (size_t i = 0; i < size(); ++i)
{
Token* token = at(i);
if (!token)
continue;
if (!(token->m_TokenKind & (tkClass | tkTypedef | tkEnum | tkNamespace)))
continue;
if (token->m_AncestorsString.IsEmpty())
continue;
// only local symbols might change inheritance
// if (!token->m_IsLocal)
// continue;
the last two line was comment out in rev 2855 by mandrav.
Note: currently, the function RecalcData() is not used in CC. we use a new method to dynamically call the hierarchy. which is:
class A :public B,C{};
class D :public B,C{};
class C :public X{};
Once the parser finish parsing, then, A's ancestorString is "B,C", D's ancestorString is "B,C", and C's ancestorString is "X".
Now, every thing is OK, we do not call RecalcData(). What's RecalcData() does can divided to two stages:
1, transform the ancestorString to ancestor Idx on evey tokens of the tree. so, A's ancestorIdx will have index to Token B, and index C
D's ancestorIdx will have index to Token B, and index C ; D's ancestorIdx will have index to Token X. no further hierarchy is calculated. meanwhile, all the ancestorString will be cleared.(as they were transform to Idxs)
2, calculate the full hierarchy, which means a recursive function call:
A's ancestorIdx will have index to Token B, Token C and Token X. (Token X added by calculate the hierarchy)
D's ancestorIdx will have index to Token B, and Token C and Token X. (Token X added by calculate the hierarchy)
C's ancestorIdx will have index to Token X. (the same as stage 1)
The currently way we use was "calculate the fully hierarchy on the Tokens we would like to use". which means if we want to query information of Token A, we only calculate the "stage 1 and stage 2" on the exact token A.
BTW:
This thread was suggested to move to CC's sub forum to record such info.