News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

New code completion remarks/issues

Started by killerbot, September 15, 2009, 12:24:28 PM

Previous topic - Next topic

MortenMacFly

Quote from: killerbot on September 24, 2009, 08:29:10 AM
YES, I can confirm this works now !!!
I've committed including another very bad parser bug I fixed. It slipped in with the last modification I did before doing the merge... bad boy... SO could your all please try again? Also: I am generally interested in code snippets to test the CC plugin. I am planning to put all of them in a "test" project.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

blueshake

Quotehello,did anyboby notice that codecompletion bar that miss some function in codecompletion.cpp.
see my snap3 .I can confirm that it work at rev 5731 see  the snap4 .
it seems that the codecompletion's member function were not included in this situation.what is going on ?
hello,Morten
is this issue solved?
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?

ollydbg

Quote from: blueshake on September 24, 2009, 02:52:06 PM
Quotehello,did anyboby notice that codecompletion bar that miss some function in codecompletion.cpp.
see my snap3 .I can confirm that it work at rev 5731 see  the snap4 .
it seems that the codecompletion's member function were not included in this situation.what is going on ?
hello,Morten
is this issue solved?
No, the bug you reported in reply #19 is still exist in rev 5817
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.

killerbot

I can confirm my reported issues are still fixed with the latest code in svn.

ollydbg

#34
Quote from: killerbot on September 24, 2009, 03:19:52 PM
I can confirm my reported issues are still fixed with the latest code in svn.
fixed or not?  :?
I tested your example, the bug still exists.


Edit

I can confirm it works!!!
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.

blueshake

I can confirm it work for killerbot's issue.
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?

blueshake

#36
but the issue on reply#19  still exists
the parser stop in the end of wxArrayString GetIncludeDirs(cbProject &project)

the next codes are not parsed.

see the attachment.the CodeCompletion token has no implement file.

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

Jenna

Another issue in some classes/files I can not see/jump to the implementation.
For example cbEditor.
The toolbar does not show any members of cbEditor if I am in cbeditor.cpp, only cbEditorInternalData.

Jump to declaration and jump to implementation is broken for many functions ( I guess the same that are not listed in toolbar and/or symbols browser).

blueshake

The bug followed the routine .If the golbal function followed some kind of class member function,then the class member function will be not parsed.(e.g. cbeditor.cpp)
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?

ollydbg

#39
Quote from: blueshake on September 24, 2009, 03:54:12 PM
The bug followed the routine .If the golbal function followed some kind of class member function,then the class member function will be not parsed.(e.g. cbeditor.cpp)

If I only copy three function implementation from line 517 to line 743 of codecompletion.cpp .


int CodeCompletion::CodeComplete()
{
......
}

bool TestIncludeLine(wxString const &line)
{
......
}

wxArrayString GetIncludeDirs(cbProject &project)
{
......
}




see the screenshot, the parser works quite well.



Both two global functions and one class member function will be recognized correctly.
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.

MortenMacFly

I personally believe it's related to the handling of the const keyword in a function signature. For the classes where it works not here *always* the previous method has a const.
I've extarcted all the patches I applied from the beginning of the refactoring meanwhile and try to reproduce by which step this behaviour was introduced. So far I am at step 2...  so this may take a while... (taking Murphy into account it'll be the last step).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ollydbg

#41
hello all.

I just enabled the parser_thread_output guard, and try to exam the parser_thread log. It seems when parsing codecompletion.cpp, the parser exits after parsing function: GetIncludeDirs.

Here is the log:


......
DoParse() : Loop:m_Str='int ', token='SortCCList'
HandleFunction() : Adding function 'SortCCList': m_Str='int '
HandleFunction() : name='SortCCList', args='(const wxString& first, const wxString& second)', peek='{'
HandleFunction() : Skipped function SortCCList impl. from 440 to 470
HandleFunction() : Add token name='SortCCList', args='(const wxString& first, const wxString& second)', return type='int '
DoParse() : Loop:m_Str='', token='int'
DoParse() : Loop:m_Str='int ', token='CodeCompletion'
DoParse() : Loop:m_Str='int ', token='CodeComplete'
HandleFunction() : Adding function 'CodeComplete': m_Str='int '
HandleFunction() : name='CodeComplete', args='()', peek='{'
HandleFunction() : Skipped function CodeComplete impl. from 473 to 645
HandleFunction() : Add token name='CodeComplete', args='()', return type='int '
DoParse() : Loop:m_Str='', token='bool'
DoParse() : Loop:m_Str='bool ', token='TestIncludeLine'
HandleFunction() : Adding function 'TestIncludeLine': m_Str='bool '
HandleFunction() : name='TestIncludeLine', args='(wxString const &line)', peek='{'
HandleFunction() : Skipped function TestIncludeLine impl. from 648 to 664
HandleFunction() : Add token name='TestIncludeLine', args='(wxString const &line)', return type='bool '
DoParse() : Loop:m_Str='', token='wxArrayString'
DoParse() : Loop:m_Str='wxArrayString ', token='GetIncludeDirs'
HandleFunction() : Adding function 'GetIncludeDirs': m_Str='wxArrayString '
HandleFunction() : name='GetIncludeDirs', args='(cbProject &project)', peek='{'
HandleFunction() : Skipped function GetIncludeDirs impl. from 667 to 2060
HandleFunction() : Add token name='GetIncludeDirs', args='(cbProject &project)', return type='wxArrayString '

************it seems the parser stops here!!!!!!!********************

Reparsing saved files...
Starting batch parsing




Note:


Skipped function GetIncludeDirs impl. from 667 to 2060

Edit:

So, I still believe it is something related to parsing such statement:


....
fullname.Replace(_T("\\"), _T("/"), true);
...


"\\"   and "/" should carefully be tokenized.


Edit2

If you would like to do such test, you'd better delete all the include statement from the codecompletion.cpp, and copy these code to an empty console project. otherwise, too many logs will be  outputs when parsing these header files. :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.

blueshake

But what about cbeditor.cpp.
It seems there is no statement fullname.Replace(_T("\\"), _T("/"), true); in the file.
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?

ollydbg

#43
Quote from: blueshake on September 25, 2009, 07:06:32 AM
But what about cbeditor.cpp.
It seems there is no statement fullname.Replace(_T("\\"), _T("/"), true); in the file.


The same thing happens if you try to parse the cbEditor.cpp, here is the log:


HandleFunction() : Adding function 'IsPreprocessor': m_Str='bool '
HandleFunction() : name='IsPreprocessor', args='(int style)', peek='{'
HandleFunction() : Skipped function IsPreprocessor impl. from 269 to 274
HandleFunction() : Add token name='IsPreprocessor', args='(int style)', return type='bool '
DoParse() : Loop:m_Str='', token='bool'
DoParse() : Loop:m_Str='bool ', token='IsCharacterOrString'
HandleFunction() : Adding function 'IsCharacterOrString': m_Str='bool '
HandleFunction() : name='IsCharacterOrString', args='(int style)', peek='{'
HandleFunction() : Skipped function IsCharacterOrString impl. from 277 to 289
HandleFunction() : Add token name='IsCharacterOrString', args='(int style)', return type='bool '
DoParse() : Loop:m_Str='', token='bool'
DoParse() : Loop:m_Str='bool ', token='IsCharacter'
HandleFunction() : Adding function 'IsCharacter': m_Str='bool '
HandleFunction() : name='IsCharacter', args='(int style)', peek='{'
HandleFunction() : Skipped function IsCharacter impl. from 292 to 304
HandleFunction() : Add token name='IsCharacter', args='(int style)', return type='bool '
DoParse() : Loop:m_Str='', token='void'
DoParse() : Loop:m_Str='void ', token='DoBraceCompletion'
HandleFunction() : Adding function 'DoBraceCompletion': m_Str='void '
HandleFunction() : name='DoBraceCompletion', args='(const wxChar& ch)', peek='{'
HandleFunction() : Skipped function DoBraceCompletion impl. from 307 to 3240
HandleFunction() : Add token name='DoBraceCompletion', args='(const wxChar& ch)', return type='void '
Reparsing saved files...
Starting batch parsing


It seem the parser stops after parsing DoBraceCompletion. note:HandleFunction() : Skipped function DoBraceCompletion impl. from 307 to 3240

It's implementation is list below:


void DoBraceCompletion(const wxChar& ch)
   {
       cbStyledTextCtrl* control = m_pOwner->GetControl();
       int pos = control->GetCurrentPos();
       int style = control->GetStyleAt(pos);
       if ( IsComment(style) || IsPreprocessor(style) )
           return;
       if ( ch == _T('\'') )
       {
           if ( (control->GetCharAt(pos) == ch) && (pos > 1) && (control->GetCharAt(pos-2) != _T('\\')) )
           {
               control->DeleteBack();
               control->GotoPos(pos);
           }
           else
           {
               if ( (control->GetCharAt(pos-2) == _T('\\')) || IsCharacterOrString(style) )
                   return;
               control->AddText(ch);
               control->GotoPos(pos);
           }
           return;
       }
       if ( ch == _T('"') )
       {
           if ( (control->GetCharAt(pos) == ch) && (pos > 1) && (control->GetCharAt(pos-2) != _T('\\')) )
           {
               control->DeleteBack();
               control->GotoPos(pos);
           }
           else
           {
               if ( (control->GetCharAt(pos-2) == _T('\\')) || IsCharacter(style) )
                   return;
               control->AddText(ch);
               control->GotoPos(pos);
           }
           return;
       }
       if ( IsCharacterOrString(style) )
           return;
       const wxString leftBrace(_T("([{"));
       const wxString rightBrace(_T(")]}"));
       int index = leftBrace.find(ch);
       const wxString unWant(_T(");\n\r\t\b "));
       #if wxCHECK_VERSION(2, 9, 0)
       if ((index != wxNOT_FOUND) && (unWant.find(wxUniChar(control->GetCharAt(pos))) != wxNOT_FOUND))
       #else
       if ((index != wxNOT_FOUND) && (unWant.find(control->GetCharAt(pos)) != wxNOT_FOUND))
       #endif
       {
           control->AddText(rightBrace.GetChar(index));
           control->GotoPos(pos);
           if (ch == _T('{'))
           {
                   const wxRegEx reg(_T("^[ \t]*{}[ \t]*"));
                   if (reg.Matches(control->GetCurLine()))
                   {
               control->NewLine();
               control->GotoPos(pos);
                       control->NewLine();
               return;
           }
       }
       }
       else
       {
           index = rightBrace.find(ch);
           if (index != wxNOT_FOUND)
           {
               if (control->GetCharAt(pos) == ch)
               {
                   control->DeleteBack();
                   control->GotoPos(pos);
                   return;
               }
           }
       }
   }

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.

blueshake

#44
@ollydbg
I comment wxArrayString GetIncludeDirs(cbProject &project)
and void CodeCompletion::CodeCompleteIncludes() function implementation.Then the cc works in the latest cc.
And I test the codes in codecompletion.cpp without any comment in svn 5731.Everything work perfectly.
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?