Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Several improvements to Code Completion plugin
Huki:
Two short patches:
1) A fix for tilde operator: make sure if it's really a destructor function, or just a variable with the bitwise NOT operation.
--- Code: ---Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 9271)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -249,8 +249,9 @@
if (!word.IsEmpty())
{
NameUnderCursor.Clear();
- if (GetLastNonWhitespaceChar(control, start) == _T('~'))
- NameUnderCursor << _T('~');
+ //FIX(huki), don't prepend '~' to search term (could be bitwise operator)
+ //if (GetLastNonWhitespaceChar(control, start) == _T('~'))
+ // NameUnderCursor << _T('~');
NameUnderCursor << word;
ReturnValue = true;
IsInclude = false;
@@ -2182,8 +2233,9 @@
const int startPos = editor->GetControl()->WordStartPosition(pos, true);
const int endPos = editor->GetControl()->WordEndPosition(pos, true);
wxString target;
+ bool isDestructor = false; //NOTE(huki), don't prepend '~' in cases of bitwise operator: eg: flag &= ~bits; and use "go to decl" on 'bits'.
if (CodeCompletionHelper::GetLastNonWhitespaceChar(editor->GetControl(), startPos) == _T('~'))
- target << _T('~');
+ isDestructor = true; //target << _T('~');
target << editor->GetControl()->GetTextRange(startPos, endPos);
if (target.IsEmpty())
return;
@@ -2201,7 +2253,7 @@
CC_LOCKER_TRACK_TT_MTX_LOCK(s_TokenTreeMutex)
// special handle destructor function
- if (target[0] == _T('~'))
+ if (isDestructor) //if (target[0] == _T('~'))
{
TokenIdxSet tmp = result;
result.clear();
@@ -2211,7 +2263,7 @@
const Token* token = tree->at(*it);
if (token && token->m_TokenKind == tkClass)
{
- token = tree->at(tree->TokenExists(target, token->m_Index, tkDestructor));
+ token = tree->at(tree->TokenExists(_T("~") + target, token->m_Index, tkDestructor));
if (token)
result.insert(token->m_Index);
}
--- End code ---
2) "Go to implementation" fails on constructor declaration. Upon "go to impl", the old code assumes it's a constructor only if the ':' prefix is found. This means user can't go to the ctor implementation from the class declaration for example. i.e.,
--- Code: ---class CodeCompletion
{
[...]
/** Constructor */
CodeCompletion(); <-- Use "go to implementation" on this line
[...]
}
--- End code ---
Fix:
--- Code: ---Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 9271)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -2232,8 +2284,9 @@
}
if (isClassOrConstructor)
{
- const bool isConstructor = CodeCompletionHelper::GetNextNonWhitespaceChar(editor->GetControl(), endPos) == _T('(')
- && CodeCompletionHelper::GetLastNonWhitespaceChar(editor->GetControl(), startPos) == _T(':');
+ //NOTE(huki), Assume ctor if isImpl (user may want to go to ctor implementation from the class declaration).
+ const bool isConstructor = CodeCompletionHelper::GetNextNonWhitespaceChar(editor->GetControl(), endPos) == _T('(')
+ && (isImpl || CodeCompletionHelper::GetLastNonWhitespaceChar(editor->GetControl(), startPos) == _T(':'));
for (TokenIdxSet::const_iterator it = result.begin(); it != result.end();)
{
const Token* token = tree->at(*it);
--- End code ---
ollydbg:
--- Quote from: Huki on March 01, 2014, 07:24:47 pm ---...
Thanks for the commit.. just one question about this change in Parser::OnAllThreadsDone()
--- Code: ---Index: src/plugins/codecompletion/parser/parser.cpp
===================================================================
--- src/plugins/codecompletion/parser/parser.cpp (revision 9664)
+++ src/plugins/codecompletion/parser/parser.cpp (revision 9665)
@@ -931,9 +888,7 @@
// Do next task
if ( !m_PoolTask.empty()
- || !m_BatchParseFiles.empty()
- || !m_PriorityHeaders.empty()
- || !m_PredefinedMacros.IsEmpty() )
+ || !m_BatchParseFiles.empty() )
{
TRACE(_T("Parser::OnAllThreadsDone(): Still some tasks left, starting m_BatchTimer."));
m_BatchTimer.Start(ParserCommon::PARSER_BATCHPARSE_TIMER_RUN_IMMEDIATELY, wxTIMER_ONE_SHOT);
--- End code ---
Was the "|| !m_PredefinedMacros.IsEmpty()" removed on purpose?
--- End quote ---
Oh, it is a bug, fixed in trunk now, thanks.
MortenMacFly:
--- Quote from: Huki on March 01, 2014, 07:45:17 pm ---2) "Go to implementation" fails on constructor declaration. Upon "go to impl", the old code assumes it's a constructor only if the ':' prefix is found. This means user can't go to the ctor implementation from the class declaration for example. i.e.,
[...]
--- End quote ---
I think I recall a patch floating around that deals with this already...
@ollydbg: Was it yours? It introduced a special method to handle constructors ... somewhere ... ???
ollydbg:
--- Quote from: MortenMacFly on March 02, 2014, 07:30:49 am ---
--- Quote from: Huki on March 01, 2014, 07:45:17 pm ---2) "Go to implementation" fails on constructor declaration. Upon "go to impl", the old code assumes it's a constructor only if the ':' prefix is found. This means user can't go to the ctor implementation from the class declaration for example. i.e.,
[...]
--- End quote ---
I think I recall a patch floating around that deals with this already...
@ollydbg: Was it yours? It introduced a special method to handle constructors ... somewhere ... ???
--- End quote ---
Yes, I have one, I just search our forum for several minutes, and finally found one: Re: Find Declaration of constructor doesn't work.
MortenMacFly:
--- Quote from: ollydbg on March 02, 2014, 03:06:02 pm ---Yes, I have one, I just search our forum for several minutes, and finally found one: Re: Find Declaration of constructor doesn't work.
--- End quote ---
Yes, thats the one I recall. Well - if Hukis patch provides the same results I would vote for that instead, because it looks a bit simpler.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version