Author Topic: new cc search implemention  (Read 15478 times)

Offline blueshake

  • Regular
  • ***
  • Posts: 459
new cc search implemention
« on: February 28, 2010, 08:02:56 am »
hi,all

after a week's work,I finally finish this patch.it is the most complicated patch I had made.

as we know,the current cc use FindAIMatch function to get the matched tokens.people complain its low efficiency.

that is true because  it use recursive calls.and I found it is hard to understand ,not mention to maintain it.at least for me,it is so.

so I rewrite FindAIMatch function.of course ,I abandon recursive calls.


I am not going to explain the whole search process, just started from what I changed.


1.first I use GenerateResultSet  to get the tokens from search scope set.it is the same story as before.but a little different here.
I directly get the matched search text from the tree and then eliminate those which are not under the search scope set.

2.ResolveAutualType

this function is used to resolve the function/variable's actual type.

3.ResolveExpression

just the name said,it is used to resolve the expression. it is used to replace the FindAIMatch function.

if you want to ask what is the biggest different?

here is the answer.try the complained thing.you can see how fast it is. :lol:
Code
string::append.append.append.append.append.append.

patch for 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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: new cc search implemention
« Reply #1 on: February 28, 2010, 12:05:59 pm »
There is a typo? ResolveAutualType , should be ResolveActualType maybe?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: new cc search implemention
« Reply #2 on: February 28, 2010, 12:11:50 pm »
There is a typo? ResolveAutualType , should be ResolveActualType maybe?


you are right. :D :D :D
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: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: new cc search implemention
« Reply #3 on: March 01, 2010, 07:10:16 am »
I have just applied in my local copy, and it works quite well.
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: 459
Re: new cc search implemention
« Reply #4 on: March 03, 2010, 01:43:13 am »
Another update.

-make the search work fine for "this"  now.

-better handle for operator overload(show or not)

e.g.

class::----------here we may want to show operator overload.

variable.--------here we do not want to show.




[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 blueshake

  • Regular
  • ***
  • Posts: 459
Re: new cc search implemention
« Reply #5 on: March 03, 2010, 01:50:31 am »
see the screen shot.

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: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: new cc search implemention
« Reply #6 on: March 03, 2010, 01:55:48 am »
Nice work, I will test it soon!!!
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: 459
Re: new cc search implemention
« Reply #7 on: March 03, 2010, 03:32:04 am »
BTW:The following messages are not relatived to current topic.but I put it here.just for reminder.

in this thread.http://forums.codeblocks.org/index.php/topic,11227.0.html


if you want to the function mentioned in the above thread,you need to use the following patch.
Code
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 6185)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -562,9 +562,9 @@
             wxArrayInt already_registered;
             std::set< wxString, std::less<wxString> > unique_strings; // check against this before inserting a new string in the list
             TokensTree* tokens = parser->GetTokens();
+            m_SearchItem.clear();
             for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
             {
-                m_SearchItem.clear();
                 Token* token = tokens->at(*it);
                 if (!token || token->m_Name.IsEmpty())
                     continue;


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: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: new cc search implemention
« Reply #8 on: March 03, 2010, 03:48:38 am »
BTW:The following messages are not relatived to current topic.but I put it here.just for reminder.

in this thread.http://forums.codeblocks.org/index.php/topic,11227.0.html

Ok, tested and works quite well.
Let me give a simple explanation.

For such code:
Code
string aaaa;
aaaa.app

with autocompletion, you will get here, caret moved behind "append":
Code
string aaaa;
aaaa.append|

Now, this this patch, you will get additional parenthesis added, so, you get caret in the "()".
Code
string aaaa;
aaaa.append(|)
« Last Edit: March 03, 2010, 04:15:15 am by ollydbg »
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: 459
Re: new cc search implemention
« Reply #9 on: March 03, 2010, 07:37:29 am »
Ok,here comes another patch.


for better function args tip.
when we type ","  this patch can show the tip now.quite simple here.
 :D
Code
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 6185)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -2049,7 +2049,8 @@
                 ++m_ActiveCalltipsNest;
             ShowCallTip();
         }
-
+        else if (ch == _T(','))
+            ShowCallTip();
         // end calltip
         else if (ch == _T(')'))
         {
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: 9694
Re: new cc search implemention
« Reply #10 on: March 03, 2010, 07:44:48 am »
Now, this this patch, you will get additional parenthesis added, so, you get caret in the "()".
Code
string aaaa;
aaaa.append(|)
Such magic shall always be configurable. By experience I'd say that 70% of the CC users will ask how to turn that off.
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 JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: new cc search implemention
« Reply #11 on: March 03, 2010, 08:22:10 am »
whoaa so much code completion coding this is emotional, I have to compile the latest nightly to test all this goodies xD
Men i wish I could be programming in c++ again now Im all php, as3 xD