Author Topic: Please let CC to support the global namepace  (Read 20855 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Please let CC to support the global namepace
« 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[]]>
</::>

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Please let CC to support the global namepace
« Reply #1 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]
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Please let CC to support the global namepace
« Reply #2 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]

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Please let CC to support the global namepace
« Reply #3 on: January 17, 2010, 09:29:35 am »
All other tests are good.

[attachment deleted by admin]

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Please let CC to support the global namepace
« Reply #4 on: January 17, 2010, 09:56:47 am »
ok,I will continue to improve it.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Please let CC to support the global namepace
« Reply #5 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! :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Please let CC to support the global namepace
« Reply #6 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)?! ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Please let CC to support the global namepace
« Reply #7 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.

Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Please let CC to support the global namepace
« Reply #8 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.
« Last Edit: January 18, 2010, 03:12:03 am by blueshake »
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Please let CC to support the global namepace
« Reply #9 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?
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 blueshake

  • Regular
  • ***
  • Posts: 458
Re: Please let CC to support the global namepace
« Reply #10 on: January 18, 2010, 03:10:09 am »
yes,only abc should be keeped.so the cc will work like global search.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Please let CC to support the global namepace
« Reply #11 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;
     }
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Please let CC to support the global namepace
« Reply #12 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]

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Please let CC to support the global namepace
« Reply #13 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??
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Please let CC to support the global namepace
« Reply #14 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Please let CC to support the global namepace
« Reply #15 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

when you type "(" , you will get what I mean.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Please let CC to support the global namepace
« Reply #16 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

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

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