Currently i found some strange behaviors using the new CC Branch of Code::Blocks:
1) if i enter while () and then press "." it will be autocompleted as while ().while
2) if i enter "ret" and then press "CTRL-SPACE" (for autocompletion) it shows me: return ,SHORT ,short_f.....
(see attachment)
[attachment deleted by admin]
I can confirm the first issue.
But, if there's no space between "while" and "(", then it has no error tips.
For the second issue, in my Chinese system Windows XP, ctrl + space will do a input method switch, so, I cant reproduce it. Continuing enter "retu" will give the right tip "return".
Edit
After change the short cut to "ALT +/", I can't reproduce the second issue. It can give the correct tip list with the prefix I entered.
[attachment deleted by admin]
This not only happened in the new CC Branch of Code::Blocks,but also in normal version.
I found all the keywords had this problem. and the keywords will show twice .for example .
when you type cla and the codecompletion tip will show two class.
Quote from: blueshake on August 09, 2009, 10:37:06 AM
I found all the keywords had this problem. and the keywords will show twice .for example .
when you type cla and the codecompletion tip will show two class.
Really? But I have only one "class" in the tip list.
[attachment deleted by admin]
That is right.I download the svn 5716 Nightly builds.and it still exist ,it is strange .
see the attachment .
[attachment deleted by admin]
That's strange. My local copy was using "trunk + cc_branch + my own patch" , so...
QuoteCurrently i found some strange behaviors using the new CC Branch of Code::Blocks:
1) if i enter
Code:
while ()
and then press "." it will be autocompleted as
Code:
while ().while
this problem can be solved by this patch.
Index: nativeparser.cpp
===================================================================
--- nativeparser.cpp (revision 5744)
+++ nativeparser.cpp (working copy)
@@ -1214,8 +1214,8 @@
case '(': --nest; break;
}
}
- if ((x > 0) && (wxIsalnum(line.GetChar(x - 1)) || line.GetChar(x - 1) == '_'))
- --x;
+ //if ((x > 0) && (wxIsalnum(line.GetChar(x - 1)) || line.GetChar(x - 1) == '_'))
+ // --x;
}
}
}
Can you explain a little about this modify on the function:
unsigned int NativeParser::FindCCTokenStart(const wxString& line)
{
......
return x;
}
Thanks!
The function is list below:
unsigned int NativeParser::FindCCTokenStart(const wxString& line)
{
int x = line.Length() - 1;
int nest = 0;
bool repeat = true;
while (repeat)
{
repeat = false;
while ((x >= 0) && (wxIsalnum(line.GetChar(x)) || line.GetChar(x) == '_'))
--x;
if ( (x > 0) &&
( (line.GetChar(x) == '>' && line.GetChar(x - 1) == '-') ||
(line.GetChar(x) == ':' && line.GetChar(x - 1) == ':') ) )
{
x -= 2;
repeat = true;
}
else if ((x >= 0) && (line.GetChar(x) == '.'))
{
--x;
repeat = true;
}
if (repeat)
{
// now we 're just before the "." or "->" or "::"
// skip any whitespace
while ((x >= 0) && (line.GetChar(x) == ' ' || line.GetChar(x) == '\t'))
--x;
// check for function/array/cast ()
if ((x >= 0) && (line.GetChar(x) == ')' || line.GetChar(x) == ']'))
{
++nest;
while (--x >= 0 && nest != 0)
{
#if wxCHECK_VERSION(2, 9, 0)
switch (line.GetChar(x).GetValue())
#else
switch (line.GetChar(x))
#endif
{
case ']':
case ')': ++nest; break;
case '[':
case '(': --nest; break;
}
}
if ((x > 0) && (wxIsalnum(line.GetChar(x - 1)) || line.GetChar(x - 1) == '_'))
--x;
}
}
}
++x;
if (x < 0)
x = 0;
while (line.GetChar(x) == ' ' || line.GetChar(x) == '\t')
++x;
//Manager::Get()->GetLogManager()->DebugLog("Starting at %d \"%s\"", x, line.Mid(x).c_str());
return x;
}
I think we need to "skip any whitespace" after we find the "[" in the following line
while ().
That is what I think is right :D:
while (--x >= 0 && nest != 0)
{
#if wxCHECK_VERSION(2, 9, 0)
switch (line.GetChar(x).GetValue())
#else
switch (line.GetChar(x))
#endif
{
case ']':
case ')': ++nest; break;
case '[':
case '(': --nest; break;
}
}
//***************ADD code here:
// skip any whitespace
while ((x >= 0) && (line.GetChar(x) == ' ' || line.GetChar(x) == '\t'))
--x;
//**************
......
so should we add the codes
while ((x >= 0) && (line.GetChar(x) == ' ' || line.GetChar(x) == '\t'))
--x;
to the function or others?
Both of you got me irritated by now... So I am simply looking forward to a new patch... ;-)
Step into the CC plugin when I enter the "." after
while ()
I find that the "BreakUpComponents" function will give the components as "while".
See the screenshot
(http://i683.photobucket.com/albums/vv194/ollydbg_cb/components.png)
So, the code-completion related code will firstly search the global token trees, and the Keywords list, finally, it find one match "while".
So, the wrong call tip displayed.
I think the expect result that BreakUpcomponents return should be *empty* instead of a "while".
i think the problem can be solved by this patch too.
which one is better, still need to further discussed.
Index: nativeparser.cpp
===================================================================
--- nativeparser.cpp (revision 5744)
+++ nativeparser.cpp (working copy)
@@ -1248,21 +1247,20 @@
++startAt;
}
}
-
-// Manager::Get()->GetLogManager()->DebugLog(_T("at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str());
- while ((startAt < line.Length()) && (wxIsalnum(line.GetChar(startAt)) || line.GetChar(startAt) == '_'))
+ //Manager::Get()->GetLogManager()->DebugLog(F(_T("at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str()));
+ while ((startAt < line.Length()) && (wxIsalnum(line.GetChar(startAt)) || line.GetChar(startAt) == '_' || line.GetChar(startAt) == ' ' || line.GetChar(startAt) == '\t'))
{
res << line.GetChar(startAt);
++startAt;
}
-
+ res.Trim();
while ((nest > 0) && (startAt < line.Length()))
{
if (line.GetChar(startAt) == ')')
--nest;
++startAt;
}
- //Manager::Get()->GetLogManager()->DebugLog("Done nest: at %d (%c): res=%s", startAt, line.GetChar(startAt), res.c_str());
+ //Manager::Get()->GetLogManager()->DebugLog(F(_T("Done nest: at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str()));
if ((startAt < line.Length()) && (line.GetChar(startAt) == '(' || line.GetChar(startAt) == '['))
{
Quote from: blueshake on August 27, 2009, 05:44:42 AM
Index: nativeparser.cpp
===================================================================
--- nativeparser.cpp (revision 5744)
+++ nativeparser.cpp (working copy)
@@ -1248,21 +1247,20 @@
++startAt;
}
}
-
-// Manager::Get()->GetLogManager()->DebugLog(_T("at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str());
- while ((startAt < line.Length()) && (wxIsalnum(line.GetChar(startAt)) || line.GetChar(startAt) == '_'))
+ //Manager::Get()->GetLogManager()->DebugLog(F(_T("at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str()));
+ while ((startAt < line.Length()) && (wxIsalnum(line.GetChar(startAt)) || line.GetChar(startAt) == '_' || line.GetChar(startAt) == ' ' || line.GetChar(startAt) == '\t'))
{
res << line.GetChar(startAt);
++startAt;
}
-
+ res.Trim();
while ((nest > 0) && (startAt < line.Length()))
{
if (line.GetChar(startAt) == ')')
--nest;
++startAt;
}
- //Manager::Get()->GetLogManager()->DebugLog("Done nest: at %d (%c): res=%s", startAt, line.GetChar(startAt), res.c_str());
+ //Manager::Get()->GetLogManager()->DebugLog(F(_T("Done nest: at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str()));
if ((startAt < line.Length()) && (line.GetChar(startAt) == '(' || line.GetChar(startAt) == '['))
{
...so is this the only thing to apply and the other two modifications are obsolete?
for me ,the two patch both work fine.
now , I need to find which one is much better.just need some time.
wxString NativeParser::GetCCToken(wxString& line, ParserTokenType& tokenType)
{
// line contains a string on the following form:
// " char* mychar = SomeNamespace::m_SomeVar.SomeMeth"
// first we locate the first non-space char starting from the *end*:
//
// " char* mychar = SomeNamespace::m_SomeVar.SomeMeth"
// ^
// then we remove everything before it.
// after it, what we do here, is (by this example) return "SomeNamespace"
// *and* modify line to become:
// m_SomeVar.SomeMeth
// so that if we 're called again with the (modified) line,
// we 'll return "m_SomeVar" and modify line (again) to become:
// SomeMeth
// and so on and so forth until we return an empty string...
// NOTE: if we find () args or [] arrays in our way, we skip them (done in GetNextCCToken)...
The last comment says:
// NOTE: if we find () args or [] arrays in our way, we skip them (done in GetNextCCToken)...
So, it is better to change the function "GetNextCCToken" I think.
@ollydbg
would you agree to apply the second patch?
Quote from: blueshake on August 27, 2009, 09:57:21 AM
@ollydbg
would you agree to apply the second patch?
Yes, I personally prefer the second patch just do the Trim() function.