Menu

#491 Bug C++ Code Completion Methods with Parameters of C++ Template Classes with 2+ Template Arguments

Undefined
fixed
ollydbg
Bug_Report
2020-09-26
2017-03-16
Joe Paul
No

I just noticed this. Very minor bug. The code completion interprets the comma separating C++ template classes with 2 template arguments in a parameter type as the separator for the next argument in the pop up for method code completion.

I had typed in the following when code completion produced the attached screenshot.

boost::regex_search(argv[1], res,

1 Attachments

Discussion

  • ollydbg

    ollydbg - 2017-03-17

    Thanks for the report, it looks like we should count the "<" and ">" level in parsing the agruments.

     
    • Aaron Sami Abassi

      This bug affects procedures as well as methods, just FYI as that's likely expected.

       
  • Teodor Petrov

    Teodor Petrov - 2017-09-02
    • labels: CodeCompletion, code completion, bug, c++, template class parameters --> CodeCompletion, code completion, c++
     
  • ollydbg

    ollydbg - 2018-10-27

    I think this bug is related to the function below:

    int NativeParser::GetCallTips(wxArrayString& items, int& typedCommas, cbEditor* ed, int pos)
    {
        items.Clear();
        typedCommas = 0;
        int commas = 0;
    
        if (!ed || !m_Parser->Done())
        {
            items.Add(wxT("Parsing at the moment..."));
            return wxSCI_INVALID_POSITION;
        }
    
        TRACE(_T("NativeParser::GetCallTips()"));
    
        ccSearchData searchData = { ed->GetControl(), ed->GetFilename() };
        if (pos == wxNOT_FOUND)
            pos = searchData.control->GetCurrentPos();
        int nest = 0;
        while (--pos > 0)
        {
            const int style = searchData.control->GetStyleAt(pos);
            if (   searchData.control->IsString(style)
                || searchData.control->IsCharacter(style)
                || searchData.control->IsComment(style) )
            {
                continue;
            }
    
            const wxChar ch = searchData.control->GetCharAt(pos);
            if (ch == _T(';'))
                return wxSCI_INVALID_POSITION;
            else if (ch == _T(','))
            {
                if (nest == 0)
                    ++commas;
            }
            else if (ch == _T(')'))
                --nest;
            else if (ch == _T('('))
            {
                ++nest;
                if (nest > 0)
                    break;
            }
        }// while
    
        // strip un-wanted
        while (--pos > 0)
        {
            if (   searchData.control->GetCharAt(pos) <= _T(' ')
                || searchData.control->IsComment(searchData.control->GetStyleAt(pos)) )
            {
                continue;
            }
            break;
        }
    
        const int start = searchData.control->WordStartPosition(pos, true);
        const int end = searchData.control->WordEndPosition(pos, true);
        const wxString target = searchData.control->GetTextRange(start, end);
        TRACE(_T("Sending \"%s\" for call-tip"), target.wx_str());
        if (target.IsEmpty())
            return wxSCI_INVALID_POSITION;
    
        TokenIdxSet result;
        MarkItemsByAI(result, true, false, true, end);
    
        ComputeCallTip(m_Parser->GetTokenTree(), result, items);
    
        typedCommas = commas;
        TRACE(_T("NativeParser::GetCallTips(): typedCommas=%d"), typedCommas);
        items.Sort();
        return end;
    }
    

    We should consider the "<" and ">" level when counting how many function arguments we have already typed.

     
  • ollydbg

    ollydbg - 2018-11-01

    To reproduce this bug, I can simple have such code

    void f(int a, map<int,float> b);
    
    f(1,);
    

    When you hit the comma after the "1", you will see the wrong call tip height.

     
  • ollydbg

    ollydbg - 2018-11-04
     
  • ollydbg

    ollydbg - 2018-11-04

    The error is in the function body, not the one I mentioned before.

    void NativeParserBase::GetCallTipHighlight(const wxString& calltip,
                                               int*            start,
                                               int*            end,
                                               int             typedCommas)
    {
    
     
  • ollydbg

    ollydbg - 2018-11-04
    • status: open --> fixed
    • assigned_to: ollydbg
     
  • ollydbg

    ollydbg - 2018-11-04

    Fixed in the trunk now(Committed r11509). Thanks for the report.

     
  • Teodor Petrov

    Teodor Petrov - 2020-09-26
    • labels: CodeCompletion, code completion, c++ --> CodeCompletion
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.