Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: ollydbg on May 11, 2010, 04:02:39 am

Title: swap between a header file and a implementation file problem
Post by: ollydbg on May 11, 2010, 04:02:39 am
I find a problem, If I open the Codeblocks.cbp, and open the file:
sdk\cbeditor.cpp

Then, you will see NO cbEditor entry in the CC's symbol browser.  (The options is: Current files symbols)

But once you do a swap to open the header file, which is
include\cbeditor.h

Then, you will see the cbEditor class information in the CC's symbol browser.

This means: the current way of doing header/implementation files can be improved.
At least, when we open cbeditor.cpp, the symbol tree should show the cbEditor.

right?
Title: Re: swap between a header file and a implementation file problem
Post by: hakim on May 13, 2010, 11:47:16 am
Yup, that's the regression I reported here (http://forums.codeblocks.org/index.php/topic,12434.0.html) a bit earlier. It would be really nice if someone fixed it. BTW, it's just symbol browser bug - everything works just fine in code completion toolbar.
Title: Re: swap between a header file and a implementation file problem
Post by: ollydbg on May 13, 2010, 02:40:58 pm
The code snippet about this problem is show below.
In the classbrowser.cpp

Code
void ClassBrowser::UpdateView(bool checkHeaderSwap)
{
    m_pActiveProject = 0;
    TRACE(_T("ClassBrowser::UpdateView(), the old m_ActiveFilename = %s"),m_ActiveFilename.wx_str());
    wxString oldActiveFilename = m_ActiveFilename;
    m_ActiveFilename.Clear();

    if (m_pParser && !Manager::IsAppShuttingDown())
    {
        m_pActiveProject = Manager::Get()->GetProjectManager()->GetActiveProject();
        cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
        if (ed)
        {
            //m_ActiveFilename = ed->GetFilename().BeforeLast(_T('.'));
            // the above line is a bug (see https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1559&group_id=5358)
            m_ActiveFilename = ed->GetFilename().AfterLast(wxFILE_SEP_PATH);
            if (m_ActiveFilename.Find(_T('.')) != wxNOT_FOUND)
            {
                m_ActiveFilename = ed->GetFilename().BeforeLast(wxFILE_SEP_PATH) + wxFILE_SEP_PATH + m_ActiveFilename.BeforeLast(_T('.'));
                m_ActiveFilename.Append(_T('.'));
            }
            else
                m_ActiveFilename = ed->GetFilename();
        }
        TRACE(_T("ClassBrowser::UpdateView(), the new m_ActiveFilename = %s"),m_ActiveFilename.wx_str());

        if (checkHeaderSwap && oldActiveFilename.IsSameAs(m_ActiveFilename))
        {
            TRACE(_T("ClassBrowser::UpdateView() match the old filename, return!"));
            return;
        }


        BuildTree();

        wxSplitterWindow* splitter = XRCCTRL(*this, "splitterWin", wxSplitterWindow);
        if (m_pParser->ClassBrowserOptions().treeMembers)
        {
            splitter->SplitHorizontally(m_Tree, m_TreeBottom);
            m_TreeBottom->Show(true);
        }
        else
        {
            splitter->Unsplit();
            m_TreeBottom->Show(false);
        }

    }
    else
        m_Tree->DeleteAllItems();
}

You will see, the function BuildTree() will build the tree control, basically depend on the variable: m_ActiveFilename

So, what does m_ActiveFilename means.

For example, you have these files in your project.
Code
a:\abc\def\hij.cpp
a:\abc\def\hij.h

Then, open either the header file or the cpp file, you will get the
Code
m_ActiveFilename = "a:\abc\def\hij."

So, a file search with prefix of "a:\abc\def\hij." will show all the tokens in both of the two files.

But this does not work if the header file and implementation file does NOT in the same directory. (As they don't share the same prefix string")

How can we solve this problem???
Title: Re: swap between a header file and a implementation file problem
Post by: Loaden on August 03, 2010, 04:34:56 pm
I solved this problem, I will create a patch based on CC branch. :D
Title: Re: swap between a header file and a implementation file problem
Post by: ollydbg on August 03, 2010, 04:42:45 pm
I solved this problem, I will create a patch based on CC branch. :D
Nice work!!!