Author Topic: Code Completion failure  (Read 6333 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Code Completion failure
« on: May 11, 2013, 10:54:13 pm »
CC fails often, too often, but always hard to pinpoint/reproduce issues.

I think however I stumbled upon one.

CB was open with 1 project which had been parsed. Outside CB I created a new project and then dragged and dropped the cbp file into the Projects tab within CB ==> in the Code::Blocks log tab, no sign to be found that it would be parsed, guessing it was not parsed.

Code
NativeParser::CreateParser(): Finish creating a new parser for project 'Asio4-Dns'
NativeParser::OnParserEnd(): Project 'Asio4-Dns' parsing stage done!
Opening /home/killerbot/Projects/Boost/Asio/Asio5-Buffers/Project/Asio5-Buffers.cbp  //<===== just load, no parsing
Done.

Then I click right click on the project and choose "Reparse project" ==> again no parsing traces to be found in the CB log tab.

Then I closed the first project (in this case the Asio4) and then we see parsing happening on the Asio5. ==> new entries in the log :
Code
NativeParser::DeleteParser(): Deleting parser for project 'Asio4-Dns'!
NativeParser::CreateParser(): Finish creating a new parser for project 'Asio5-Buffers'
NativeParser::OnParserEnd(): Project 'Asio5-Buffers' parsing stage done!

Note : clicking reparse project does show traces now in the log.

Extra info : Use one parser for the whole workspace
NOte : Concurrently parsing threads is on 1 (unable to change it, so what's the purpose ?)
« Last Edit: May 11, 2013, 11:05:16 pm by killerbot »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Code Completion failure
« Reply #1 on: May 11, 2013, 11:12:47 pm »
Similar issues after enabling CC (if it was disabled formerly).

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6079
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion failure
« Reply #2 on: May 13, 2013, 04:56:49 pm »
If you set one parser for the workspace, it means only one parser instance will be created for all the projects, so in you case, I think no "new parser created log message" is by design, but the new added project should still be parsed, so this may be a bug. About the concurrent parthread number, because wxString is not thread safe, so this number is forsed to be one.

jens' reported bug is another bug, CC should start parse on already opened projects if it(the plugin itself) was enabled.

I will test you issue tomorrow morning, it is midnight here.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6079
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion failure
« Reply #3 on: May 14, 2013, 08:35:49 am »
Code
Index: nativeparser.cpp
===================================================================
--- nativeparser.cpp (revision 9094)
+++ nativeparser.cpp (working copy)
@@ -558,13 +558,15 @@
         return nullptr;
     }
 
-    // Easy case for "one parser per workspace" that has already been created:
+    // In the case of "one parser per workspace", the project is not include in the common parser
+    // we need to insert it, in other cases, a new Parser instance is needed
+    ParserBase* parser;
     if (m_ParserPerWorkspace && !m_ParsedProjects.empty())
-        return m_ParserList.begin()->second;
+        parser = m_ParserList.begin()->second; // reuse the common parser
+    else
+        parser = new Parser(this, project);    // create a new Parser instance
 
     TRACE(_T("NativeParser::CreateParser(): Calling DoFullParsing()"));
-
-    ParserBase* parser = new Parser(this, project);
     if ( !DoFullParsing(project, parser) )
     {
         CCLogger::Get()->DebugLog(_T("NativeParser::CreateParser(): Full parsing failed!"));
This patch should fix the problem reported by killerbot, please test and give some feedback.

The reason is: when you have a.cbp already opened, and in one_parser_for_whole_workspace mode, when you drag/drop another b.cbp, the CC did not run the "DoFullParsing" for the b.cbp but just return the common parser by "return m_ParserList.begin()->second;".
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.