Author Topic: Disable the "reparsing while typing" when batching parsing is running  (Read 6637 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5720
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Hi, all.

I just do a simple patch, that is: when the batch parsing is running, we can disable the "reparse while parse" options.

Code
Index: codecompletion.cpp
===================================================================
--- codecompletion.cpp (revision 6117)
+++ codecompletion.cpp (working copy)
@@ -556,7 +556,8 @@
             ed->GetControl()->ClearRegisteredImages();
 
             bool caseSens = parser ? parser->Options().caseSensitive : false;
-            wxArrayString items; items.Alloc(result.size());
+            wxArrayString items;
+            items.Alloc(result.size());
             int pos   = ed->GetControl()->GetCurrentPos();
             int start = ed->GetControl()->WordStartPosition(pos, true);
             wxArrayInt already_registered;
@@ -1591,6 +1592,30 @@
         if (!Manager::Get()->GetConfigManager(_T("code_completion"))->ReadBool(_T("eval_tooltip"), true))
             return;
 
+
+        // Check the debugger is running...at this time, don't show cc tips
+        bool debuggerRunning = false;
+        PluginsArray arr = Manager::Get()->GetPluginManager()->GetOffersFor(ptDebugger);
+        if (arr.GetCount())
+        {
+            for(size_t i=0;i<arr.GetCount();i++)
+            {
+                cbDebuggerPlugin* debugger = (cbDebuggerPlugin*)arr[i];
+                if (!debugger)
+                    continue; //kinda scary if this isn't a debugger? perhaps this should be a logged error??
+                if (debugger->IsRunning())
+                {
+                    debuggerRunning=true;
+                    break;
+                }
+            }
+        }
+        if(debuggerRunning)
+        {
+            Manager::Get()->GetLogManager()->DebugLog(F(_T("debugger is running, skip.CC tips..")));
+            return;
+        }
+
         EditorBase* base = event.GetEditor();
         cbEditor* ed = base && base->IsBuiltinEditor() ? static_cast<cbEditor*>(base) : 0;
         if (!ed || ed->IsContextMenuOpened())
@@ -2112,7 +2137,15 @@
         && (   (event.GetModificationType() & wxSCI_MOD_INSERTTEXT)
             || (event.GetModificationType() & wxSCI_MOD_DELETETEXT) ) )
     {
-        m_NeedReparse = true;
+        if (parser->Done())
+        {
+            m_NeedReparse = true;
+
+        }
+        else
+        {
+            Manager::Get()->GetLogManager()->DebugLog(_T("Reparsing disabled because Batch parsing is still running") + editor->GetFilename());
+        }
     }
     if (control->GetCurrentLine() != m_CurrentLine)
     {

Ok, the patch include another functionality that try to solve the "tip conflict between the CC and GDB". Though morten is not agree about this :D. But in logic, because the tip of GDB is always slowser than tip of CC, so it works well as expect (When debugging, the debug tip value is always shown).

Comments are welcome!!!
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.