Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

New code completion remarks/issues

<< < (18/54) > >>

ollydbg:
here is the patch to solve this problem. :D


--- Code: ---Index: tokenizer.cpp
===================================================================
--- tokenizer.cpp (revision 5834)
+++ tokenizer.cpp (working copy)
@@ -216,17 +216,22 @@
 
 bool Tokenizer::SkipToCharBreak()
 {
-  if (PreviousChar() != '\\')
-      return true;
-  else
-  {
-      // check for "\\"
-      if (   ((m_TokenIndex - 2) >= 0)
-          && ((m_TokenIndex - 2) <= m_BufferLen)
-          && (m_Buffer.GetChar(m_TokenIndex - 2) == '\\') )
-          return true;
-  }
-  return false;
+    if (PreviousChar() != '\\')
+        return true;
+    else
+    {
+        // check for "\\"
+        unsigned int numBackslash = 2;
+        while(   ((m_TokenIndex - numBackslash) >= 0)
+            && ((m_TokenIndex - numBackslash) <= m_BufferLen)
+            && (m_Buffer.GetChar(m_TokenIndex - numBackslash) == '\\') )
+            ++numBackslash;
+        if(numBackslash%2==1) // number of back slash(include current char ) is even
+            return true;     // eg: "\""
+        else
+            return false;    // eg: "\\""
+    }
+    return false;
 }

--- End code ---


@ marton

I think the function name "SkipToCharBreak" is confusion, because it doesn't really do a skip.

So, I suggest using another name like :  IsRealCharBreak or IsCharBreak or IsEscapeChar

Thanks.

blueshake:
Because my slow Internet,it seems a lot of messages were not caughted. :D
In this threadhttp://forums.codeblocks.org/index.php/topic,10990.msg75079.html#msg75079,the patch I provide is some kind of mistake.So please change it back.I test the codes,it can work under tktypedef,there are so many codes connect with tktypedef,it is risky to do this (apply this patch.)Thanks.

ollydbg:

--- Quote from: blueshake on October 04, 2009, 05:58:58 am ---Because my slow Internet,it seems a lot of messages were not caughted. :D
In this threadhttp://forums.codeblocks.org/index.php/topic,10990.msg75079.html#msg75079,the patch I provide is some kind of mistake.So please change it back.I test the codes,it can work under tktypedef,there are so many codes connect with tktypedef,it is risky to do this (apply this patch.)Thanks.

--- End quote ---

hi, blueshake. Here is the test code


--- Code: ---class sStruct
{
  SomeClass* some_class;
  int some_int;
  void* some_void;
};
typedef class sStruct tStruct;

int main()
{
    tStruct pp;
    pp.
    cout << "Hello world!" << endl;
    return 0;
}

--- End code ---

And In my working copy of trunk, code completion works after "pp.".
Why do you want to reverse your patch?

You mean the patch below should be reversed?

--- Code: ---Index: parserthread.cpp
===================================================================
--- parserthread.cpp (revision 5730)
+++ parserthread.cpp (working copy)


@@ -1707,15 +1737,60 @@
 #if PARSER_DEBUG_OUTPUT
     Manager::Get()->GetLogManager()->DebugLog(F(_("Adding typedef: name='%s', ancestor='%s'"), components.front().c_str(), ancestor.c_str()));
 #endif
-    Token* tdef = DoAddToken(tkTypedef, components.front(), lineNr, 0, 0, args);

+    Token* tdef = DoAddToken(tkClass, components.front(), lineNr, 0, 0, args);

--- End code ---


blueshake:
@ollydbg
The test codes work well under tktypedef now.But it did not work before.Maybe some bugs have been fixeed.The reason I want to change it back to tktypedef is that there are some codes are connected with tktypedef.For example:In the nativeparser.cpp

--- Code: ---    if (local_result.size() == 1)
    {
        int id = *local_result.begin();
        Token* token = tree->at(id);

        if (token->m_TokenKind == tkTypedef)
        {
            std::queue<ParserComponent> type_components;
            BreakUpComponents(parser, token->m_ActualType, type_components);

            while(!components.empty())
            {
                ParserComponent comp = components.front();
                components.pop();
                type_components.push(comp);
            }

    #ifdef DEBUG_CC_AI
            if (s_DebugSmartSense)
            #if wxCHECK_VERSION(2, 9, 0)
                Manager::Get()->GetLogManager()->DebugLog(F(_T("Replacing %s to %s"), token->m_Name.wx_str(), token->m_ActualType.wx_str()));
            #else
                Manager::Get()->GetLogManager()->DebugLog(F(_T("Replacing %s to %s"), token->m_Name.c_str(), token->m_ActualType.c_str()));
            #endif
    #endif
            return FindAIMatches(parser, type_components, result, parentTokenIdx, noPartialMatch, caseSensitive, use_inheritance, kindMask, search_scope);
        }

    }
--- End code ---

I think it is too risky to  change tktypedef to tkclass. :D

blueshake:
Ok, tiny fixed with ReadClsNames in parserthread.
for broken codes below:
--- Quote ---#include <iostream>

using namespace std;
typedef class qq
{
    int x;
    int y;

}xx
int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

--- End quote ---

before : the parser will regard xx, int ,main as class.
now: only the main (refer to visual assist ,this is what it do).So I think it will be a better way to do this.
patch:

--- Code: ---Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 5825)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -1768,7 +1768,7 @@
     Manager::Get()->GetLogManager()->DebugLog(F(_("HandleTypedef() : Adding typedef: name='%s', ancestor='%s'"), components.front().c_str(), ancestor.c_str()));
 #endif
 //    Token* tdef = DoAddToken(tkTypedef, components.front(), lineNr, 0, 0, args);
-    Token* tdef = DoAddToken(tkClass, components.front(), lineNr, 0, 0, args);
+    Token* tdef = DoAddToken(tkTypedef, components.front(), lineNr, 0, 0, args);
     if (tdef)
     {
         if (!is_function_pointer)
@@ -1796,7 +1796,7 @@
                 m_Tokenizer.UngetToken();
                 break;
             }
-        else if (wxIsalpha(current.GetChar(0)))
+        else if (wxIsalpha(current.GetChar(0)) && (m_Tokenizer.PeekToken() == ParserConsts::semicolon || m_Tokenizer.PeekToken() == ParserConsts::comma))
         {
 #if PARSERTHREAD_DEBUG_OUTPUT
             Manager::Get()->GetLogManager()->DebugLog(F(_T("ReadClsNames() : Adding variable '%s' as '%s' to '%s'"), current.c_str(), m_Str.c_str(), (m_pLastParent?m_pLastParent->m_Name.c_str():_T("<no-parent>"))));
@@ -1811,7 +1811,10 @@
             }
 
         }
-        else // unexpected
+        else// unexpected
+        {
+            m_Tokenizer.UngetToken();
             break;
+        }
     }
 }

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version