Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Commit rev 6058 question

(1/1)

ollydbg:
When discuss this patch:
CodeCompletion: fixes UnnamedStruct in the classBrowser, 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


--- Code: ----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;
 }

--- End code ---

The function parameter is "token index" as I see, but it was changed to "file index"?????

EDIT:
old:

--- Code: ---int newitem = AddTokenToList(newToken,forceidx);
--- End code ---

new:

--- Code: ---int newItem = AddTokenToList(newToken, fileIndex);
--- End code ---

I see that AddTokenToList() function's second parameter is the token index not file index.

ollydbg:
The lucky thing is:

--- Code: ---size_t fileIdx = (fileIndex<0) ? newToken->m_FileIdx : (size_t)fileIndex;
--- End code ---
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.

--- Code: ---m_FilesMap[fileIdx].insert(newItem);
--- End code ---

ollydbg:
Ok, a patch to fix this issue (include the CodeCompletion: fixes UnnamedStruct in the classBrowser)

EDIT: update to version 2 of the patch

ollydbg:
Version 3 of the patch.
See attachment.

Navigation

[0] Message Index

Go to full version