Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: Loaden on January 06, 2010, 10:39:41 am

Title: Please let CC to support the global namepace
Post by: Loaden on January 06, 2010, 10:39:41 am
Code
#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    ::Mess // HERE,no-work. if not use global namespace, it's work fine.
    return 0;
}
I try to add a rule, and adding this rules, and CB not start now.
Code
				<::>
<![CDATA[]]>
</::>
Title: Re: Please let CC to support the global namepace
Post by: blueshake on January 17, 2010, 08:02:23 am
Patch for it. :D
Code
Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 6089)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -1638,9 +1638,9 @@
             }
             Manager::Get()->GetLogManager()->DebugLog(F(_T("BreakUpComponents() Found component: '%s' (%s)"), tok.wx_str(), tokenTypeString.wx_str()));
         }
+        if (tok.Length() != 0 || tokenType == pttSearchText)
+            components.push(pc);
 
-        components.push(pc);
-
         if (tokenType == pttSearchText)
             break;
     }


see the screen shot.
welcome to test it.

[attachment deleted by admin]
Title: Re: Please let CC to support the global namepace
Post by: Loaden on January 17, 2010, 09:23:53 am
Yes, it works well Thank you very much!
But there is a small problem, see the picture prompts.


[attachment deleted by admin]
Title: Re: Please let CC to support the global namepace
Post by: Loaden on January 17, 2010, 09:29:35 am
All other tests are good.

[attachment deleted by admin]
Title: Re: Please let CC to support the global namepace
Post by: blueshake on January 17, 2010, 09:56:47 am
ok,I will continue to improve it.
Title: Re: Please let CC to support the global namepace
Post by: MortenMacFly on January 17, 2010, 02:48:52 pm
Patch for it. :D
[...]
welcome to test it.
Nice one. Can you do me a favor (for the future) and comment such changes? It's not very clear in the first place what the if statement actually means. Thanks! :-)
Title: Re: Please let CC to support the global namepace
Post by: MortenMacFly on January 17, 2010, 02:55:01 pm
I try to add a rule, and adding this rules, and CB not start now.
Code
				<::>
<![CDATA[]]>
</::>
You do know how often "::" appears in C++ code (e.g. MyClass::MyMethod)?! ;-)
Title: Re: Please let CC to support the global namepace
Post by: blueshake on January 17, 2010, 02:57:14 pm
well.

it mean nothing if the tokenType  is not pttSearchText.

for example:

for global codecompletion,such codes:

::abc

when we type these codes,the search will break the texts(::abc) into two compesents.

one is "" ,type is pttNameSpace
another is "abc" ,type is pttSearchText.

Title: Re: Please let CC to support the global namepace
Post by: blueshake on January 18, 2010, 02:48:08 am
continue my comment.

so for pttNameSpace type ,if its text(tok) is empty.we need to eat this component.that is why the statement  tok.Length() != 0 in the if condition.
but for pttSearchText type ,we can not do this.because for such search codes(ss:: ),so we need another statement tokenType == pttSearchText in the if condition too.
Title: Re: Please let CC to support the global namepace
Post by: ollydbg on January 18, 2010, 02:55:35 am
continue my comment.

so for pttNameSpace type ,if its text(tok) is empty.we need to eat this component.that is why the statement  tok.Length() != 0 in the if condition.
but for pttSearchText type ,we can do this.because for such search codes(ss::),so we need another statement tokenType == pttSearchText in the if condition too.
So, you mean: if we breakUP this statement"::abc".
We should result only One ParserComponent. right?
Title: Re: Please let CC to support the global namepace
Post by: blueshake on January 18, 2010, 03:10:09 am
yes,only abc should be keeped.so the cc will work like global search.
Title: Re: Please let CC to support the global namepace
Post by: blueshake on January 18, 2010, 04:20:51 am
@Loaden

can you try this patch and give me feedback?

Is  this issue still there?
 
Quote
But there is a small problem, see the picture prompts.

patch:
Code
Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 6089)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -1638,9 +1638,9 @@
             }
             Manager::Get()->GetLogManager()->DebugLog(F(_T("BreakUpComponents() Found component: '%s' (%s)"), tok.wx_str(), tokenTypeString.wx_str()));
         }
+        if (!tok.IsEmpty() || (tokenType == pttSearchText && components.size() != 0))
+            components.push(pc);
 
-        components.push(pc);
-
         if (tokenType == pttSearchText)
             break;
     }
Title: Re: Please let CC to support the global namepace
Post by: Loaden on January 18, 2010, 05:32:36 am
@Loaden

can you try this patch and give me feedback?

Is  this issue still there?
 
Quote
But there is a small problem, see the picture prompts.

patch:
Code
Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 6089)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -1638,9 +1638,9 @@
             }
             Manager::Get()->GetLogManager()->DebugLog(F(_T("BreakUpComponents() Found component: '%s' (%s)"), tok.wx_str(), tokenTypeString.wx_str()));
         }
+        if (!tok.IsEmpty() || (tokenType == pttSearchText && components.size() != 0))
+            components.push(pc);
 
-        components.push(pc);
-
         if (tokenType == pttSearchText)
             break;
     }
It's OK now! perfect!

[attachment deleted by admin]
Title: Re: Please let CC to support the global namepace
Post by: blueshake on May 01, 2010, 06:15:57 am
@Loaden

can you try this patch and give me feedback?

Is  this issue still there?
 
Quote
But there is a small problem, see the picture prompts.

patch:
Code
Index: src/plugins/codecompletion/nativeparser.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser.cpp (revision 6089)
+++ src/plugins/codecompletion/nativeparser.cpp (working copy)
@@ -1638,9 +1638,9 @@
             }
             Manager::Get()->GetLogManager()->DebugLog(F(_T("BreakUpComponents() Found component: '%s' (%s)"), tok.wx_str(), tokenTypeString.wx_str()));
         }
+        if (!tok.IsEmpty() || (tokenType == pttSearchText && components.size() != 0))
+            components.push(pc);
 
-        components.push(pc);
-
         if (tokenType == pttSearchText)
             break;
     }




@morten

seems you don't apply this patch correctly,so in current cc, when you type "(" ,cc will give a lot of wrong tips.can you check this??
Title: Re: Please let CC to support the global namepace
Post by: MortenMacFly on May 01, 2010, 06:55:03 am
seems you don't apply this patch correctly,so in current cc, when you type "(" ,cc will give a lot of wrong tips.can you check this??
Work fine here...?! What exactly do you mean? Remember that this is just for global namespace. IIRC we had discussed this. So that's why it is as it is now.
Title: Re: Please let CC to support the global namepace
Post by: blueshake on May 01, 2010, 07:54:37 am
please check out the nativeparser.cpp file. in about line 1656
Code
        if (tok.Length() != 0 || tokenType == pttSearchText)

but in my above patch , it is
Code
if (!tok.IsEmpty() || (tokenType == pttSearchText && components.size() != 0))


if you apply the patch I provided in this thread.http://forums.codeblocks.org/index.php/topic,12096.msg82256.html#msg82256 (http://forums.codeblocks.org/index.php/topic,12096.msg82256.html#msg82256)

when you type "(" , you will get what I mean.
Title: Re: Please let CC to support the global namepace
Post by: Loaden on May 01, 2010, 02:33:37 pm
please check out the nativeparser.cpp file. in about line 1656
Code
        if (tok.Length() != 0 || tokenType == pttSearchText)

but in my above patch , it is
Code
if (!tok.IsEmpty() || (tokenType == pttSearchText && components.size() != 0))


if you apply the patch I provided in this thread.http://forums.codeblocks.org/index.php/topic,12096.msg82256.html#msg82256 (http://forums.codeblocks.org/index.php/topic,12096.msg82256.html#msg82256)

when you type "(" , you will get what I mean.

I apply the patch, and test it.
I can confirm this.