While hunting the bug: Re: The 01 September 2015 build (10474) is out., I see this issue.
I create a simple cctest project(ccc_read_parenthese.cpp), and paste such code:
class AAA { int* f1(wxCommandEvent & event); float& f2(wxCommandEvent & event); };
You see the log:
000002. -----------I-n-t-e-r-i-m--L-o-g----------- 000003. InitTokenizer() : m_Filename='F:\cb_sf_git\trunk\src\plugins\codecompletion\testing\ccc_read_parenthese.cpp', m_FileSize=94. 000004. Init() : m_Filename='F:\cb_sf_git\trunk\src\plugins\codecompletion\testing\ccc_read_parenthese.cpp' 000005. F:\cb_sf_git\trunk\src\plugins\codecompletion\testing\ccc_read_parenthese.cpp 000006. Parse() : Parsing 'F:\cb_sf_git\trunk\src\plugins\codecompletion\testing\ccc_read_parenthese.cpp' 000007. DoParse() : Loop:m_Str='', token='class' 000008. HandleClass() : Found class 'AAA', next='{' 000009. DoAddToken() : Created token='AAA', file_idx=1, line=1, ticket=259 000010. GetTokenBaseType() : Searching within m_Str='' 000011. GetTokenBaseType() : Compensated m_Str='' 000012. GetTokenBaseType() : Returning '' 000013. DoAddToken() : Prepending '' 000014. DoAddToken() : Added/updated token 'AAA' (0), kind 'class', type '', actual ''. Parent is (-1) 000015. DoParse() : Loop:m_Str='', token='int' 000016. DoParse() : Loop:m_Str='int ', token='*' 000017. DoParse() : Loop:m_Str='int ', token='f1' 000018. HandleFunction() : Adding function 'f1': m_Str='int ' 000019. HandleFunction() : name='f1', args='(wxCommandEvent& event)', peek=';' 000020. HandleFunction() : !(Ctor/Dtor) 'f1', m_Str='int ', localParent='<none>' 000021. HandleFunction() : Adding function 'f1', ': m_Str='int ', enc_ns='nil'. 000022. HandleFunction() : Add token name='f1', args='(wxCommandEvent& event)', return type='int ' 000023. GetBaseArgs() : args='(wxCommandEvent& event)'. 000024. GetBaseArgs() : baseArgs='(wxCommandEvent&)'. 000025. DoAddToken() : Created token='f1', file_idx=1, line=3, ticket=260 000026. GetTokenBaseType() : Searching within m_Str='int' 000027. GetTokenBaseType() : Compensated m_Str='int' 000028. GetTokenBaseType() : Found 'int' 000029. DoAddToken() : Prepending '' 000030. DoAddToken() : Added/updated token 'f1' (1), kind 'function', type 'int*', actual 'int'. Parent is AAA (0) 000031. DoParse() : Loop:m_Str='', token=';' 000032. DoParse() : Loop:m_Str='', token='float' 000033. DoParse() : Loop:m_Str='float ', token='&' 000034. DoParse() : Loop:m_Str='float & ', token='f2' 000035. HandleFunction() : Adding function 'f2': m_Str='float & ' 000036. HandleFunction() : name='f2', args='(wxCommandEvent& event)', peek=';' 000037. HandleFunction() : !(Ctor/Dtor) 'f2', m_Str='float & ', localParent='<none>' 000038. HandleFunction() : Adding function 'f2', ': m_Str='float & ', enc_ns='nil'. 000039. HandleFunction() : Add token name='f2', args='(wxCommandEvent& event)', return type='float & ' 000040. GetBaseArgs() : args='(wxCommandEvent& event)'. 000041. GetBaseArgs() : baseArgs='(wxCommandEvent&)'. 000042. DoAddToken() : Created token='f2', file_idx=1, line=4, ticket=261 000043. GetTokenBaseType() : Searching within m_Str='float &' 000044. GetTokenBaseType() : Compensated m_Str='float &' 000045. GetTokenBaseType() : Found 'float' 000046. DoAddToken() : Prepending '' 000047. DoAddToken() : Added/updated token 'f2' (2), kind 'function', type 'float &', actual 'float'. Parent is AAA (0) 000048. DoParse() : Loop:m_Str='', token=';' 000049. DoParse() : Loop:m_Str='', token='}'
You see the m_Str are different
Diff:
Well, I see that in the DoParse(), only * is handled, but not &, so this patch should fix the issue:
src/plugins/codecompletion/parser/parserthread.cpp | 1 +
1 file changed, 1 insertion(+)
Fixed in rev10483
I see no test added to the test suite. Can you add one?
Well, the file(ccc_read_parenthese.cpp) I used for testing has no "test case for code suggestion list", I just run it under GDB to see whether it works OK.
Our cctest frame can only test whether the suggestion list is correct or not, but the internal parsing logic is not tested yet.
Some idea: maybe, we can add hook to DoAddToken() function, and see whether an expected Token is added correctly, but it is hard for a large file, because it may have thousands of Tokens.