Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Clang CC

<< < (26/48) > >>

yvesdm3000:
Can you show me where that number is? I tried setting a number on the event but that doesn't get used and doesn't come back in the event that is a result of the ccplugin indicating it has some results.

For what it looks like now, I think I managed to make it work correctly by saving the line/column position where code-completion is requested and when ccplugin is ready, it checks if that position is still valid, if not, drops/cancels the request.

Yves

ollydbg:

--- Quote from: yvesdm3000 on February 23, 2016, 11:26:20 am ---Can you show me where that number is? I tried setting a number on the event but that doesn't get used and doesn't come back in the event that is a result of the ccplugin indicating it has some results.

--- End quote ---
Oh, sorry, this is my idea, not implemented yet, I just put there for discussion. Not sure it is good or bad. :)


--- Quote ---For what it looks like now, I think I managed to make it work correctly by saving the line/column position where code-completion is requested and when ccplugin is ready, it checks if that position is still valid, if not, drops/cancels the request.

Yves

--- End quote ---
Yes, it is also a good choice, if you looked at the GDB's MI interface, it use a number to synchronize a request and a response.

ollydbg:

--- Quote from: ollydbg on February 23, 2016, 09:06:16 am ---
EDIT: the asynchronized request is just my idea.
An asynchronized request:
1, ccmanager call a function in ccplugin, thus a request is send to ccplugin
2, ccplugin return a special value(maybe a number), and ccmanager know it will return the results later.
3, ccplugin can do the dirty work in a worker thread
4, when result is out, ccplugin can send a message or call a sdk function from ccplugin
5, the result is shown.

If there are another request in between those steps, we can cancel some steps and do it again, a request can have a number, so they don't conflict.

--- End quote ---

Hi, yvesdm3000, I think you have already implement this kind of feature.
The code is here:

--- Code: ---std::vector<cbCodeCompletionPlugin::CCToken> ClangCodeCompletion::GetAutocompList(bool isAuto, cbEditor* ed, int& tknStart, int& tknEnd)
{
    // you just use the m_CCOutstandingResults to generate a returned tokens
}

--- End code ---

And in the code:

--- Code: ---void ClangCodeCompletion::OnCodeCompleteFinished( ClangEvent& event )
{
    //CCLogger::Get()->DebugLog( wxT("OnCodeCompleteFinished") );
    if ( event.GetTranslationUnitId() != m_TranslUnitId )
    {
        return;
    }
    if (m_CCOutstanding > 0)
    {
        if ( event.GetLocation() != m_CCOutstandingLoc )
        {
            CCLogger::Get()->DebugLog( wxT("Discard old CodeCompletion request result") );
            return;
        }
        EditorManager* edMgr = Manager::Get()->GetEditorManager();
        cbEditor* ed = edMgr->GetBuiltinActiveEditor();
        if (ed)
        {
            m_CCOutstandingResults = event.GetCodeCompletionResults();
            if ( m_CCOutstandingResults.size() > 0 )
            {
                CodeBlocksEvent evt(cbEVT_COMPLETE_CODE);
                evt.SetInt(1);
                Manager::Get()->ProcessEvent(evt);
                return;
            }
        }
        m_CCOutstanding--;
    }
}

--- End code ---
This event is send from the thread to the plugin, and you manually fire a cbEVT_COMPLETE_CODE.

Pay attachment to the value

--- Code: ---evt.SetInt(1);

--- End code ---
I think in the ccmanager, this int value only have two meanings:
FROM_TIMER or not FROM_TIMER.
I'm not quite sure whether FROM_TIMER means, but we may add another option like "delayed call".
By reading the doxygen docs of this function:

--- Code: ---virtual std::vector<CCToken> GetAutocompList(bool isAuto, cbEditor* ed, int& tknStart, int& tknEnd) = 0;

--- End code ---
I see that the returned value could be
1, an empty vector, in this case, no code suggestion will list
2, a non empty vector, thus a code suggestion list will prompted.
So, maybe we can add another returned value, indicates that the plugin will returned the vector later (asynchronized way).

ollydbg:
A bug report: I think not every source file(cpp or h files) were included in the clanglib.cbp.

yvesdm3000:

--- Quote from: ollydbg on February 23, 2016, 02:59:24 pm ---A bug report: I think not every source file(cpp or h files) were included in the clanglib.cbp.

--- End quote ---

use clanglib-unix.cbp or clanglib-msw_64.cbp

Yves

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version