Author Topic: New code completion remarks/issues  (Read 211983 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #150 on: October 07, 2009, 10:05:18 am »
I just find a small bug.
When I first only the TESTING workplace, and only the symbol tree. When I double click on the tree item, no jumping was taken.

After I toggle or switch the editor page several times, the jumping works.

So, it seems the "First jump mechanism" was some problem.
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 code completion remarks/issues
« Reply #151 on: October 07, 2009, 10:16:52 am »
Maybe the parse has not been finished yet. :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 code completion remarks/issues
« Reply #152 on: October 07, 2009, 10:17:24 am »
For the right valuetip on typedef.
patch:
Code
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 5852)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -1765,6 +1765,7 @@
         {
             tdef->m_AncestorsString = ancestor;
             tdef->m_ActualType = ancestor;
+            tdef->m_Type = ancestor;
         }
         else
             tdef->m_ActualType = ancestor + args;

Yes, it works on the test code below:

Code
#include <iostream>
#include <iostream>
using namespace std;
std::vector<string> ssss;
#define  xxxxxxxxx 12e
typedef class qq
{
    int x;
    int y;
}eeee;
typedef unsigned int wwwwwwwww;
www!
int main()
{

    cout << "Hello world!" << endl;
    return 0;
}

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 code completion remarks/issues
« Reply #153 on: October 07, 2009, 01:35:04 pm »
test codes:
Code
#include <iostream>

using namespace std;
struct qq
{
    int x;
    int y;
};
typedef qq (*ptr)(int a, int b);
ptr pp;
pp(3,3). --------not work.
int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

Edit:
relative with these codes:
Code
        if (token.GetChar(0) == '(')
        {
            // function pointer (probably)
            is_function_pointer = true;
            if (peek.GetChar(0) == '(')
            {
                // typedef void (*dMessageFunction)(int errnum, const char *msg, va_list ap);
                // typedef void (MyClass::*Function)(int);

                // remove parentheses and keep everything after the dereferencing symbol
                token.RemoveLast();
                int pos = token.Find('*', true);
                if (pos != wxNOT_FOUND)
                {
                    typ << _T('(') << token.Mid(1, pos) << _T(')');
                    token.Remove(0, pos + 1);
                }
                else
                {
                    typ = _T("(*)");
                    token.Remove(0, 1); // remove opening parenthesis
                }
                args = peek;
                components.push(token);
            }
            else
            {
                // typedef void dMessageFunction (int errnum, const char *msg, va_list ap);

                typ = _T("(*)");
                // last component is already the name and this is the args
                args = token;
            }
            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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #154 on: October 07, 2009, 02:07:49 pm »
typedef qq (*ptr)(int a, int b);
ptr pp;
pp(3,3). --------not work.

But it seems the parser get the right token type. You can open the CC debug tool dialog.
see here:


and


So, I think the AI function in nativeparser.cpp has a bug to expand the "ptr".
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 code completion remarks/issues
« Reply #155 on: October 08, 2009, 04:17:14 am »
Dear ollydbg,
I think the actualtype should be qq,and the type should be qq(*), and the ancestor should be qq too,
for codes:
Code
typedef qq (*ptr)(int a, int b);
can be treat as
Code
typedef qq ptr;
and this maybe can fix the bug.
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 code completion remarks/issues
« Reply #156 on: October 08, 2009, 04:25:52 am »
Dear ollydbg,
I think the actualtype should be qq,and the type should be qq(*), and the ancestor should be qq too,
for codes:
Code
typedef qq (*ptr)(int a, int b);
can be treat as
Code
typedef qq ptr;
and this maybe can fix the bug.
Good idea, I will try it :D.
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 code completion remarks/issues
« Reply #157 on: October 08, 2009, 10:23:15 am »
Do some modification on value tip.
patch:
Code
Index: src/plugins/codecompletion/parser/token.cpp
===================================================================
--- src/plugins/codecompletion/parser/token.cpp (revision 5852)
+++ src/plugins/codecompletion/parser/token.cpp (working copy)
@@ -126,15 +126,42 @@
 
 wxString Token::DisplayName() const
 {
-//    wxString result(_T(""));
-//    wxString parentname = GetParentName();
-//    if (!parentname.IsEmpty())
-//        result << parentname << _T("::");
-    wxString result = GetNamespace();
-    result << m_Name << m_Args;
-    if (!m_Type.IsEmpty())
-        result << _T(" : ") << m_Type;
-    return result;
+    wxString result;
+    if (m_TokenKind == tkClass)
+    {
+        result << _T("class ") << m_Name << _T(" {...}");
+        return result;
+    }
+    else if (m_TokenKind == tkNamespace)
+    {
+        result << _T("namespace ") << m_Name << _T(" {...}");
+        return result;
+    }
+    else if (m_TokenKind == tkEnum)
+    {
+        return result << _T("enum ") << m_Name << _T(" {...}");
+    }
+    else if (m_TokenKind == tkTypedef)
+    {
+        result << _T("typedef") ;
+        if (!m_Type.IsEmpty())
+            result << _T(" ") << m_Type;
+        result << _T(" ") << m_Name;
+        return result;
+    }
+    else if (m_TokenKind == tkPreprocessor)
+    {
+        result << _T("#define ") << m_Name << m_Args;
+        if(!m_Type.IsEmpty())
+            result << _T(" ") << m_Type;
+            return result;
+    }
+    else
+    {
+        if (!m_Type.IsEmpty())
+            result << m_Type << _T(" ");
+        return result << GetNamespace() << m_Name << m_Args;
+    }
 }
 
 Token* Token::GetParentToken()

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

  • Almost regular
  • **
  • Posts: 150
Re: New code completion remarks/issues
« Reply #158 on: October 09, 2009, 03:33:59 am »
Hi,

In SVN 5840, code completion can pop up function paramter.
But SVN 5853, it's not.

What happen  ? or do I  some error thing  ? :(

Code

int bbbbb(int cccccc)
{
                  //can't pop up cccccc
}


Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #159 on: October 09, 2009, 03:53:22 am »
Hi,

In SVN 5840, code completion can pop up function paramter.
But SVN 5853, it's not.

What happen  ? or do I  some error thing  ? :(

Code

int bbbbb(int cccccc)
{
                  //can't pop up cccccc
}


I can confirm this bug.
In the function body, if you enter cccc, then, there is no suggestion list "cccccc".

Need time to find the bug.

By the way, the code in nativeparser.cpp, such as

Code
// Start an Artificial Intelligence (!) sequence to gather all the matching tokens..
// The actual AI is in FindAIMatches() below...
size_t NativeParser::AI(TokenIdxSet& result,
                        cbEditor* editor,
                        Parser* parser,
                        const wxString& lineText,
                        bool noPartialMatch,
                        bool caseSensitive,
                        TokenIdxSet* search_scope,
                        int caretPos)

is really hard to read and understand for me. :( :(
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #160 on: October 09, 2009, 04:30:01 am »
I just write a simple test code:

Code
void zfunction(int abcdefg){
ab|         <---
;

};

Then I debug the CC under CB.

In codecompletion.cpp function int CodeCompletion::CodeComplete(), before line 602, the items was add correctly( which means "abcdefg" was correctly added to the suggestion list wxstring array ).

But finally, there is not suggestion list output... :( I don't know why...)

Edit: line 639 and line 640 of codecompletion.cpp, this function run to an early exit.
Code
            if (items.GetCount() == 0)
                return -2;
[/s]

Edit
It seems the match result size is always "0"...

Also, I always meet the "gdb.exe" crash when debugging(TDM-MinGW + GDB 6.8, "evaluate the express under cursor" was checked. )  I think this problem is caused by the "mouse hovers on a complex statement", then the gdb can't evaluate the statement, so ,it crashes. )

Any more comments? Thanks.






« Last Edit: October 09, 2009, 06:11:50 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 code completion remarks/issues
« Reply #161 on: October 09, 2009, 07:23:11 am »
Dear ollydbg:
The function tokens search followed the below steps:
1.serach the function name the line stayed.
2.parse the function arguments and stored tokens in pTempTreepTree ,marked with temp.
3.parse the fucntion body and stored tokens in pTempTreepTree,marked with temp.
I guess we should check whether tokens(e.g. ccccc) is in the pTempTree, and make sure the pTempTree is searched.
should compare with last svn version,I guess it caused by the recent fixed.
« Last Edit: October 12, 2009, 10:39:53 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 blueshake

  • Regular
  • ***
  • Posts: 459
Re: New code completion remarks/issues
« Reply #162 on: October 09, 2009, 07:30:16 am »
I can confirm it work in svn 5852.
see my screen shot.

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

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #163 on: October 09, 2009, 07:33:56 am »
Dear ollydbg:
The function tokens search followed the below steps:
1.serach the function name the line stayed.
2.parse the function arguments and stored tokens in pTempTree.
3.parse the fucntion body and stored tokens in pTempTree.
I guess we should check whether tokens(e.g. ccccc) in the pTempTree, and make sure the pTempTree is searched.
should compare with last svn version,I guess it caused by the recent fixed.

Thanks, but in which function takes these steps? I'm examining right now.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New code completion remarks/issues
« Reply #164 on: October 09, 2009, 07:35:48 am »
I can confirm it work in svn 5852.
see my screen shot.

Oh, this is a good catch, I was looking at the changes in nativeparser.cpp.
Now, it seems the bug is in other source files, because the newest nativeparser.cpp is rev 5849.

Wait:

It failed in rev 5852 of my working copy.
« Last Edit: October 09, 2009, 07:40: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.