Author Topic: Bug or Feature?  (Read 8566 times)

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Bug or Feature?
« on: May 04, 2010, 08:59:09 am »
Hello all!

I have a question about CC. I'm not sure if this is a bug or feature, but if I have two projects in the workspace, I get suggestion from BOTH projects, regardless of the active project. After a quick look at nativeparser.cpp (and a little help from ollydbg), I found the following:

nativeparser.cpp line 606.

Code
// NOTE: it actually forces reparsing of workspace
void NativeParser::ForceReparseActiveProject()
{
    m_Parser.Clear();
    UpdateClassBrowser();

    ProjectsArray* projects = Manager::Get()->GetProjectManager()->GetProjects();
    for (size_t i = 0; i < projects->GetCount(); ++i)
    {
        AddParser(projects->Item(i), false);
    }
}

Note: the comment:
/ /NOTE: it actually forces reparsing of workspace

Should it just reparse the active project? As in:

Code
void NativeParser::ForceReparseActiveProject()
{
    m_Parser.Clear();
    UpdateClassBrowser();

    AddParser(Manager::Get()->GetProjectManager()->GetActiveProject(), false);
}


Thx,
daniloz

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Bug or Feature?
« Reply #1 on: May 04, 2010, 09:31:38 am »
Note: the comment:
/ /NOTE: it actually forces reparsing of workspace
Should it just reparse the active project?
No. Consider a (very common) setup of a workspace that consists of 1.. n projects where 1..(n-1) are libraries used by the main (n'th) application. In the main application you surely want to have CC for the libraries. That's why we initially implemented it the way it is now. On request of users, btw.!
One possibility I see is to make it configurable. Patches in that direction are welcome.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: Bug or Feature?
« Reply #2 on: May 04, 2010, 09:38:27 am »
Note: the comment:
/ /NOTE: it actually forces reparsing of workspace
Should it just reparse the active project?
No. Consider a (very common) setup of a workspace that consists of 1.. n projects where 1..(n-1) are libraries used by the main (n'th) application. In the main application you surely want to have CC for the libraries. That's why we initially implemented it the way it is now. On request of users, btw.!
One possibility I see is to make it configurable. Patches in that direction are welcome.
I understand and see the utility of it. However, I was expecting that the setting in the symbols tab -> View: "Active project's symbols | All local symbols (workspace) | ..." should also apply to the CC itself. Meaning that if I set it to "Active project" then I get suggestions for the active project only, but if I set to "workspace" then I have all projects...
What do you think?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Bug or Feature?
« Reply #3 on: May 04, 2010, 03:00:02 pm »
@daniloz
Loaden has a patch to let the parser generate one TokensTree per project. I will asked him to publish to the CB forum soon. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Bug or Feature?
« Reply #4 on: May 04, 2010, 03:23:02 pm »
@daniloz
Loaden has a patch to let the parser generate one TokensTree per project. I will asked him to publish to the CB forum soon. :D

That patch is not yet perfect, I will continue to focus on this issue, and try to find a better solution.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Bug or Feature?
« Reply #5 on: May 13, 2010, 03:41:20 pm »
Note: the comment:
/ /NOTE: it actually forces reparsing of workspace
Should it just reparse the active project?
No. Consider a (very common) setup of a workspace that consists of 1.. n projects where 1..(n-1) are libraries used by the main (n'th) application. In the main application you surely want to have CC for the libraries. That's why we initially implemented it the way it is now. On request of users, btw.!
One possibility I see is to make it configurable. Patches in that direction are welcome.
I understand and see the utility of it. However, I was expecting that the setting in the symbols tab -> View: "Active project's symbols | All local symbols (workspace) | ..." should also apply to the CC itself. Meaning that if I set it to "Active project" then I get suggestions for the active project only, but if I set to "workspace" then I have all projects...
What do you think?

Loaden has release a patch to solve your problem, see Let's project using standalone Parser
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.