Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
New code completion remarks/issues
blueshake:
--- Quote from: ollydbg on October 04, 2009, 01:40:17 pm ---@blueshake
That's something related in the nativeparser.cpp, and the code you cited. I will exam that. :D
--- End quote ---
Nice to hear that.Thanks. :D
ollydbg:
I can only understand a little about the FindAIMatches() function.
For example, your test code:
--- Code: ---typedef unsigned int wwwww;
wwww|
--- End code ---
You will see in the symbol tree, the "wwwww" is a global "typedef". which is quite different if your code is like below:
--- Code: ---typedef class qq
{
int x;
int y;
}eeee;
--- End code ---
then, "eeee" in the symbol tree is of type "class".
The piece of code in FindAIMatches()
--- Code: ---if (local_result.size() == 1)
{
int id = *local_result.begin();
Token* token = tree->at(id);
if (token->m_TokenKind == tkTypedef)
{
std::queue<ParserComponent> type_components;
BreakUpComponents(parser, token->m_ActualType, type_components);
while(!components.empty())
{
ParserComponent comp = components.front();
components.pop();
type_components.push(comp);
}
#if DEBUG_CC_AI
if (s_DebugSmartSense)
#if wxCHECK_VERSION(2, 9, 0)
Manager::Get()->GetLogManager()->DebugLog(F(_T("Replacing %s to %s"), token->m_Name.wx_str(), token->m_ActualType.wx_str()));
#else
Manager::Get()->GetLogManager()->DebugLog(F(_T("Replacing %s to %s"), token->m_Name.c_str(), token->m_ActualType.c_str()));
#endif
#endif
return FindAIMatches(parser, type_components, result, parentTokenIdx, noPartialMatch, caseSensitive, use_inheritance, kindMask, search_scope);
}
}
--- End code ---
this means, when you only get one match in the current context, then for example, you are entering
--- Code: ---www
--- End code ---
This time, the only matched string is "wwwww" will be replace with "unsigned int" and the total line will be reparsed. (which means the FindAIMatches will be called iteratively).
:D
But I think at this test code, this typedef replacement is useless. I can't find a test case that this replacement is meaningful. :(
Can someone explain more about this? Thanks.
MortenMacFly:
Guys, I am a bit lost and trying to catch up with all the posts. Am I rioght, that these two patches have to be applied together?
Patch 1:
--- Quote from: ollydbg on October 04, 2009, 02:32:12 am ---
--- Code: ---Index: tokenizer.cpp
===================================================================
--- tokenizer.cpp (revision 5834)
+++ tokenizer.cpp (working copy)
@@ -216,17 +216,22 @@
bool Tokenizer::SkipToCharBreak()
{
- if (PreviousChar() != '\\')
- return true;
- else
- {
- // check for "\\"
- if ( ((m_TokenIndex - 2) >= 0)
- && ((m_TokenIndex - 2) <= m_BufferLen)
- && (m_Buffer.GetChar(m_TokenIndex - 2) == '\\') )
- return true;
- }
- return false;
+ if (PreviousChar() != '\\')
+ return true;
+ else
+ {
+ // check for "\\"
+ unsigned int numBackslash = 2;
+ while( ((m_TokenIndex - numBackslash) >= 0)
+ && ((m_TokenIndex - numBackslash) <= m_BufferLen)
+ && (m_Buffer.GetChar(m_TokenIndex - numBackslash) == '\\') )
+ ++numBackslash;
+ if(numBackslash%2==1) // number of back slash(include current char ) is even
+ return true; // eg: "\""
+ else
+ return false; // eg: "\\""
+ }
+ return false;
}
--- End code ---
--- End quote ---
Patch 2:
--- Quote from: blueshake on October 04, 2009, 07:27:19 am ---
--- Code: ---Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 5825)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -1768,7 +1768,7 @@
Manager::Get()->GetLogManager()->DebugLog(F(_("HandleTypedef() : Adding typedef: name='%s', ancestor='%s'"), components.front().c_str(), ancestor.c_str()));
#endif
// Token* tdef = DoAddToken(tkTypedef, components.front(), lineNr, 0, 0, args);
- Token* tdef = DoAddToken(tkClass, components.front(), lineNr, 0, 0, args);
+ Token* tdef = DoAddToken(tkTypedef, components.front(), lineNr, 0, 0, args);
if (tdef)
{
if (!is_function_pointer)
@@ -1796,7 +1796,7 @@
m_Tokenizer.UngetToken();
break;
}
- else if (wxIsalpha(current.GetChar(0)))
+ else if (wxIsalpha(current.GetChar(0)) && (m_Tokenizer.PeekToken() == ParserConsts::semicolon || m_Tokenizer.PeekToken() == ParserConsts::comma))
{
#if PARSERTHREAD_DEBUG_OUTPUT
Manager::Get()->GetLogManager()->DebugLog(F(_T("ReadClsNames() : Adding variable '%s' as '%s' to '%s'"), current.c_str(), m_Str.c_str(), (m_pLastParent?m_pLastParent->m_Name.c_str():_T("<no-parent>"))));
@@ -1811,7 +1811,10 @@
}
}
- else // unexpected
+ else// unexpected
+ {
+ m_Tokenizer.UngetToken();
break;
+ }
}
}
--- End code ---
--- End quote ---
???
--- Quote from: ollydbg on October 04, 2009, 02:32:12 am ---I think the function name "SkipToCharBreak" is confusion, because it doesn't really do a skip.
So, I suggest using another name like : IsRealCharBreak or IsCharBreak or IsEscapeChar
--- End quote ---
That's right and probably was a typo. I'll change that certainly.
ollydbg:
@MortenMacFly
Yes, the two patches can both be applied.
But, blueshake's patch of changing the code :
--- Code: ---- Token* tdef = DoAddToken(tkClass, components.front(), lineNr, 0, 0, args);
+ Token* tdef = DoAddToken(tkTypedef, components.front(), lineNr, 0, 0, args);
--- End code ---
should be reconsidered, because a small bug he states in this post:
http://forums.codeblocks.org/index.php/topic,11187.msg76788.html#msg76788
blueshake:
hello,another bad news.
It seems some bugs hide in the codecompletion.In the file codecompletion.cpp,in this place:
--- Code: --- // Remove duplicate items
for (size_t i=0; i<items.Count()-1; i++)
if (items.Item(i)==items.Item(i+1))
items.RemoveAt(i);
Manager::ge|
--- End code ---
when you type Mana,yes,the suggestion show,then you type ::,yes work again,but when you type ge,the issue come out,the suggestion list flash again,and not show.what is going on here,the suggestion list is try to show,but cancle by something.
Note:
I just use the latest cc,change nothing.
Edit:
--- Code: ---Manager::Get()->|
--- End code ---
And in the "|" position, the cc not work.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version