User forums > Help
Code Completion problem with some wx classes
Huki:
--- Quote from: ollydbg on April 11, 2015, 04:06:18 pm ---I just debugged into the function SkipToOneOfChars(ParserConsts::commaclbrace), I see that the "}" is already eat in this function. When up to the caller "void ParserThread::HandleEnum()", we will eat another token after "}", and finally the code after that will be eat, and the body of class AAA is totally skipped.
--- End quote ---
Yes, we can see from:
--- Code: (cpp) --- if (token == ParserConsts::comma || token == ParserConsts::clbrace)
{
m_Tokenizer.UngetToken();
peek = token;
break;
}
--- End code ---
that UngetToken() is used if we already skipped comma or clbrace. We can do the same thing after SkipToOneOfChars().
This patch should fix it:
--- Code: (diff) ---diff --git a/src/plugins/codecompletion/parser/parserthread.cpp b/src/plugins/codecompletion/parser/parserthread.cpp
index d882063..d35010c 100644
--- a/src/plugins/codecompletion/parser/parserthread.cpp
+++ b/src/plugins/codecompletion/parser/parserthread.cpp
@@ -2655,6 +2655,7 @@ bool ParserThread::CalcEnumExpression(Token* tokenParent, long& result, wxString
if (token == ParserConsts::dcolon)
{
peek = SkipToOneOfChars(ParserConsts::commaclbrace);
+ m_Tokenizer.UngetToken();
exp.Clear();
break;
}
@@ -2671,6 +2672,7 @@ bool ParserThread::CalcEnumExpression(Token* tokenParent, long& result, wxString
else
{
peek = SkipToOneOfChars(ParserConsts::commaclbrace);
+ m_Tokenizer.UngetToken();
exp.Clear();
break;
}
--- End code ---
Edit: Applied syntax highlighting for diff.
ollydbg:
--- Quote from: Huki on April 11, 2015, 08:08:21 pm ---
--- Quote from: ollydbg on April 11, 2015, 04:06:18 pm ---I just debugged into the function SkipToOneOfChars(ParserConsts::commaclbrace), I see that the "}" is already eat in this function. When up to the caller "void ParserThread::HandleEnum()", we will eat another token after "}", and finally the code after that will be eat, and the body of class AAA is totally skipped.
--- End quote ---
Yes, we can see from:
--- Code: (cpp) --- if (token == ParserConsts::comma || token == ParserConsts::clbrace)
{
m_Tokenizer.UngetToken();
peek = token;
break;
}
--- End code ---
that UngetToken() is used if we already skipped comma or clbrace. We can do the same thing after SkipToOneOfChars().
This patch should fix it:
...
--- End quote ---
Yes, it fix the bug, thanks. Also the Op's issue is fixed by this patch.
My idea is that: is it better to check some thing in this code:
--- Code: (cpp) --- if (peek == ParserConsts::comma || peek == ParserConsts::clbrace)
{
// this "if", avoids non-valid enumerators
// like a comma (if no enumerators follow)
if ( wxIsalpha(token.GetChar(0))
|| (token.GetChar(0) == ParserConsts::underscore_chr) )
{
wxString args;
if (updateValue)
args << enumValue++;
Token* lastParent = m_LastParent;
m_LastParent = newEnum;
Token* enumerator = DoAddToken(tkEnumerator, token, m_Tokenizer.GetLineNumber(), 0, 0, args);
enumerator->m_Scope = isEnumClass ? tsPrivate : tsPublic;
m_LastParent = lastParent;
}
// add check here
// if (peek == ParserConsts::clbrace)
// break?
}
--- End code ---
I don't test it yet, but just read and modify the source code.
MortenMacFly:
...minor off-topic note: You can also enable syntax highlighting for patches (diff) using the "diff" code tag extension instead of cpp or text. (I believe there are roughly 200 formats supported... so chances are good we have one for our needs.)
I've edited Hukis post accordingly.
Quiss:
I've build r10218 in trunk and it works like a charm. Thanks for your efforts.
Navigation
[0] Message Index
[*] Previous page
Go to full version