Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: Loaden on April 19, 2010, 03:50:41 pm

Title: Patch for calltip, support preprocessor
Post by: Loaden 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]
Title: Re: Patch for calltip, support preprocessor
Post by: ollydbg on April 19, 2010, 04:04:05 pm
Nice!! A lot of works by you in these days.
Many patches to improve Codeblocks.
Title: Re: Patch for calltip, support preprocessor
Post by: Loaden 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);