User forums > General (but related to Code::Blocks)
Code completion problems in 7966?
zabzonk:
After having no code completion problems for ages, I'm experiencing some after installing the latest nightly. This is from my project CSVfix at http://code.google.com/p/csvfix/
int ExcludeCommand :: Execute( ALib::CommandLine & cmd ) {
ProcessFlags( cmd );
....
Here, code completion on the "cmd" parameter works just fine. But if I move down in the source about 30 lines to:
void ExcludeCommand :: ProcessFlags( const ALib::CommandLine & cmd ) {
string es = cmd.GetValue( FLAG_IF, "" );
....
code completion on the "cmd" parameter no longer works (though completion on things like "this" does). Note the parameters of both functions are of the same type, though the one that doesn't work is const, and the first (working) function calls the second (non-working) one. I am experiencing similar problems with other classes.
This is quite old code, which compiles perfectly well, and I think did code-complete before (though I can't be 100% sure of that).
Any ideas?
Edit: I have tried making the second function non-const WRT the "cmd" parameter (in both the header and the implementation file), and if I do that code completion in that function starts working. If I revert to the const parameter, it stops working. Also, should have said Win7, 64-bit.
ollydbg:
Ok, I can confirm this, here is the test code:
--- Code: ---namespace ALib
{
class CommandLine
{
int a;
int b;
};
};
void ExcludeCommand :: ProcessFlags( const ALib::CommandLine & cmd ) {
cmd;
}
void ExcludeCommand :: ProcessFlags1( ALib::CommandLine & cmd ) {
cmd;
}
--- End code ---
When I hit the "." (dot) after "cmd", It only works in the second function body.
Enable the smart debug, I see:
--- Code: ---MarkItemsByAI_1()
ParseUsingNamespace() Parse file scope for "using namespace"
BreakUpComponents() Breaking up 'ALib'
BreakUpComponents() Found component: 'ALib' (SearchText)
BreakUpComponents() Adding component: 'ALib'.
ParseUsingNamespace() Found ALib
ParseFunctionArguments() Parse function arguments
FindCurrentFunctionStart() Looking for tokens in 'E:\code\cb\test_code\mortenr2012-01-15\main.cpp'
FindCurrentFunctionStart() Found 4 results
FindCurrentFunctionStart() Current function: 'void ExcludeCommand::ProcessFlags(const ALib::CommandLine& cmd)' (at line 11)
FindCurrentFunctionStart() Namespace='ExcludeCommand::', proc='ProcessFlags' (returning 166)
BreakUpComponents() Breaking up 'ExcludeCommand'
BreakUpComponents() Found component: 'ExcludeCommand' (SearchText)
BreakUpComponents() Adding component: 'ExcludeCommand'.
FindAIMatches() ----- FindAIMatches - enter -----
FindAIMatches() Search for ExcludeCommand, isLast = 1
GenerateResultSet() search 'ExcludeCommand', parent='Global namespace (id:0, type:(null)), isPrefix=0'
FindAIMatches() Looping 1 results
FindAIMatches() Match: 'ExcludeCommand' (ID='497') : type=''
FindAIMatches() ----- FindAIMatches - leave -----
GenerateResultSet() search 'ProcessFlags', parent='ExcludeCommand (id:497, type:class), isPrefix=0'
ParseFunctionArguments() + Function match: ProcessFlags
ParseFunctionArguments() Parsing arguments: "const ALib::CommandLine& cmd;"
ParseLocalBlock() Parse local block
FindCurrentFunctionStart() Looking for tokens in 'E:\code\cb\test_code\mortenr2012-01-15\main.cpp'
FindCurrentFunctionStart() Found 4 results
FindCurrentFunctionStart() Current function: 'void ExcludeCommand::ProcessFlags(const ALib::CommandLine& cmd)' (at line 11)
FindCurrentFunctionStart() Namespace='ExcludeCommand::', proc='ProcessFlags' (returning 166)
ParseLocalBlock() Block:
cmd.;
ParseLocalBlock() Local tokens:
+ constCommandLine & ExcludeCommand::ProcessFlags::cmd Parent = ProcessFlags
AI() =========================================================
AI() Doing AI for 'cmd.':
FindCurrentFunctionStart() Looking for tokens in 'E:\code\cb\test_code\mortenr2012-01-15\main.cpp'
FindCurrentFunctionStart() Found 4 results
FindCurrentFunctionStart() Current function: 'void ExcludeCommand::ProcessFlags(const ALib::CommandLine& cmd)' (at line 11)
FindCurrentFunctionStart() Namespace='ExcludeCommand::', proc='ProcessFlags' (returning 166)
BreakUpComponents() Breaking up 'ExcludeCommand'
BreakUpComponents() Found component: 'ExcludeCommand' (SearchText)
BreakUpComponents() Adding component: 'ExcludeCommand'.
FindAIMatches() ----- FindAIMatches - enter -----
FindAIMatches() Search for ExcludeCommand, isLast = 1
GenerateResultSet() search 'ExcludeCommand', parent='Global namespace (id:0, type:(null)), isPrefix=0'
FindAIMatches() Looping 1 results
FindAIMatches() Match: 'ExcludeCommand' (ID='497') : type=''
FindAIMatches() ----- FindAIMatches - leave -----
GenerateResultSet() search 'ProcessFlags', parent='ExcludeCommand (id:497, type:class), isPrefix=0'
AI() Adding search namespace: ExcludeCommand
BreakUpComponents() Breaking up 'cmd.'
BreakUpComponents() Found component: 'cmd' (Class)
BreakUpComponents() Adding component: 'cmd'.
BreakUpComponents() Found component: '' (SearchText)
BreakUpComponents() Adding component: ''.
ResolveExpression() search scope is 4 result.
search scope: -1
search scope: 492
search scope: 494
search scope: 497
ResolveExpression() Looping 1 result.
ResolvExpression() Match:'cmd(ID=498) : type='ALib::constCommandLine'
BreakUpComponents() Breaking up 'ALib::constCommandLine'
BreakUpComponents() Found component: 'ALib' (Namespace)
BreakUpComponents() Adding component: 'ALib'.
BreakUpComponents() Found component: 'constCommandLine' (SearchText)
BreakUpComponents() Adding component: 'constCommandLine'.
ResolveExpression() search scope is 0 result.
ResolveExpression() Looping 0 result.
AI() AI leave, returned 0 results
0 results
--- End code ---
See, there is a wrong string "constCommandLine".
This bug also happens in the tip window when the mouse hover the "cmd".
ollydbg:
Ok, after debug for some time, I found that this problem happened at:
--- Code: --- else if (peek==ParserConsts::dcolon)
{
if ( m_Str.IsEmpty()
|| m_Str.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_const)
|| m_Str.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_volatile) ) // what else?!
m_EncounteredTypeNamespaces.push(token); // it's a type's namespace
else
m_EncounteredNamespaces.push(token);
m_Tokenizer.GetToken(); // eat ::
}
--- End code ---
When parsing the argument string:
--- Code: ---const ALib::CommandLine & cmd
--- End code ---
The "stack" variable "m_Str" is originally "const ", and after that, it becomes "const", the last space is removed.
And later, the CommandLine is added, and "m_Str" becomes "constCommandLine".
ollydbg:
This is the patch to fix this issue:
--- Code: ---Index: E:/code/cb/cb_trunk/src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- E:/code/cb/cb_trunk/src/plugins/codecompletion/parser/parserthread.cpp (revision 7991)
+++ E:/code/cb/cb_trunk/src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -1058,7 +1058,12 @@
if ( m_Str.IsEmpty()
|| m_Str.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_const)
|| m_Str.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_volatile) ) // what else?!
+ {
+ if (!m_Str.IsEmpty())
+ m_Str << _T(" ");
m_EncounteredTypeNamespaces.push(token); // it's a type's namespace
+ }
+
else
m_EncounteredNamespaces.push(token);
m_Tokenizer.GetToken(); // eat ::
--- End code ---
But I'm not satisfied with the logic on changing m_Str. Any ideas?
MortenMacFly:
--- Quote from: ollydbg on May 21, 2012, 05:35:01 am ---But I'm not satisfied with the logic on changing m_Str. Any ideas?
--- End quote ---
I think the issue is that the space is removed. Where and why does that happen?
Navigation
[0] Message Index
[#] Next page
Go to full version