When discuss this patch:
CodeCompletion: fixes UnnamedStruct in the classBrowser (https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=3494&group_id=5358), see the commens there, the main issue is:
I see that in rev =/@6057&compare[]=/@6058]WebSVN - codeblocks - Path Comparison - / Rev 6057 and / Rev 6058 (http://cb.biplab.in/websvn/comp.php?repname=codeblocks&compare[)
-int TokensTree::AddToken(Token* newToken,int forceidx)
+int TokensTree::AddToken(Token* newToken, int fileIndex)
{
if (!newToken)
return -1;
const wxString & name = newToken->m_Name;
- static TokenIdxSet tmp_tokens = TokenIdxSet();
- // tmp_tokens.clear();
+ static TokenIdxSet tmpTokens = TokenIdxSet();
// Insert the token's name and the token in the (inserted?) list
- size_t idx2 = m_Tree.AddItem(name,tmp_tokens,false);
- TokenIdxSet& curlist = m_Tree.GetItemAtPos(idx2);
+ size_t idx = m_Tree.AddItem(name, tmpTokens);
+ TokenIdxSet& curList = m_Tree.GetItemAtPos(idx);
+
+ int newItem = AddTokenToList(newToken, fileIndex);
+ curList.insert(newItem);
- int newitem = AddTokenToList(newToken,forceidx);
- curlist.insert(newitem);
- m_FilesMap[newToken->m_FileIdx].insert(newitem);
+ size_t fileIdx = (fileIndex<0) ? newToken->m_FileIdx : (size_t)fileIndex;
+ m_FilesMap[fileIdx].insert(newItem);
// Add Token (if applicable) to the namespaces indexes
if (newToken->m_ParentIndex < 0)
{
newToken->m_ParentIndex = -1;
- m_GlobalNameSpace.insert(newitem);
+ m_GlobalNameSpace.insert(newItem);
if (newToken->m_TokenKind == tkNamespace)
- m_TopNameSpaces.insert(newitem);
+ m_TopNameSpaces.insert(newItem);
}
// All done!
- return newitem;
+ return newItem;
}
The function parameter is "token index" as I see, but it was changed to "file index"?????
EDIT:
old:
int newitem = AddTokenToList(newToken,forceidx);
new:
int newItem = AddTokenToList(newToken, fileIndex);
I see that AddTokenToList() function's second parameter is the token index not file index.
The lucky thing is:
size_t fileIdx = (fileIndex<0) ? newToken->m_FileIdx : (size_t)fileIndex;
Here, fileIndex is always < 0 (Unless we construct the Token tree from the cache)
So, the later code always works OK, because fileIdx is always newToken->m_FileIdx.
m_FilesMap[fileIdx].insert(newItem);