Author Topic: Patch for calltip, support preprocessor  (Read 6918 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Patch for calltip, support preprocessor
« on: April 19, 2010, 03:50:41 pm »
Code
Index: src/plugins/codecompletion/nativeparser.cpp

===================================================================

--- src/plugins/codecompletion/nativeparser.cpp (revision 6203)

+++ src/plugins/codecompletion/nativeparser.cpp (working copy)

@@ -1033,7 +1033,7 @@

         }
         if (!end)
             break;
-        lineText.Remove(end);
+        lineText.Remove(end).Trim(false);
 //        Manager::Get()->GetLogManager()->DebugLog(_T("Sending \"%s\" for call-tip"), lineText.c_str());
 
         TokensTree* tokens = m_Parser.GetTokens();
@@ -1048,8 +1048,14 @@

         ParseLocalBlock(ed);
 
         m_GettingCalltips = true;
+
+        Token* tk = tokens->at(tokens->TokenExists(lineText, -1, tkPreprocessor));
+        if (tk != NULL)
+            lineText = tk->m_Type;
+
         if (!AI(result, ed, lineText, true, true, &search_scope))
             break;
+
         for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
         {
             Token* token = tokens->at(*it);


[attachment deleted by admin]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Patch for calltip, support preprocessor
« Reply #1 on: April 19, 2010, 04:04:05 pm »
Nice!! A lot of works by you in these days.
Many patches to improve Codeblocks.
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: Patch for calltip, support preprocessor
« Reply #2 on: April 20, 2010, 07:10:32 am »
Here are little modify for support global namespace.
Code
Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 6203)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -1033,7 +1033,9 @@
         }
         if (!end)
             break;
-        lineText.Remove(end);
+        lineText.Remove(end).Trim(false);
+        if (lineText.StartsWith(_T("::")))
+            lineText = lineText.Right(lineText.Length() - 2);
 //        Manager::Get()->GetLogManager()->DebugLog(_T("Sending \"%s\" for call-tip"), lineText.c_str());
 
         TokensTree* tokens = m_Parser.GetTokens();
@@ -1048,8 +1050,14 @@
         ParseLocalBlock(ed);
 
         m_GettingCalltips = true;
+
+        Token* tk = tokens->at(tokens->TokenExists(lineText, -1, tkPreprocessor));
+        if (tk != NULL)
+            lineText = tk->m_Type;
+
         if (!AI(result, ed, lineText, true, true, &search_scope))
             break;
+
         for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
         {
             Token* token = tokens->at(*it);