RFC: code completion string for overload candidates needs a chunk reform.

Francisco Lopes francisco.mailing.lists at oblita.com
Wed Jan 21 11:31:26 PST 2015


Revision 226670 improves parameter completion for C++ considerably, but
there's
still a fundamental piece missing (besides the other non-fundamental
FIXMEs).
This is also a problem that exists prior to the recent additions.

    int foo(int a, int b = 42);

    int main() {
        foo(4, 2);
    }

For the previous code, this is the relevant entries you get for completion:

$ c-index-test -code-completion-at=sample.cpp:4:11 sample.cpp

FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{Placeholder int
a} ↩
  {Optional {Comma , }{Placeholder int b}}{RightParen )} (12)

OverloadCandidate:{ResultType int}{Text foo}{LeftParen (}{Text int a} ↩
  {Comma , }{CurrentParameter int b}{RightParen )} (1)

$ clang -cc1 -fsyntax-only -code-completion-at=sample.cpp:4:11 sample.cpp
-o -

COMPLETION: foo : [#int#]foo(<#int a#>{#, <#int b#>#})
OVERLOAD: [#int#]foo(int a, <#int b#>)

As can be seen, the code building the code completion string for overloads
is
providing less detail compared to the one building completion strings for
the
function declarations in general. There's no information about optionals and
no information about what's a parameter and what's a function identifier,
everything besides ResultType, CurrentParameter and special characters is
classified as Text.

I propose code completion strings for overload candidates to follow the
pattern
already in use for function declarations.

 - return type chunk: ResultType
 - function identifier: TypedText (or Text since we're in parameter
completion context)
 - parameters: Placeholder
 - current parameter: CurrentParameter

This shouldn't be a big commit. Discussion lies more at the changed
functionality.

Since overload candidate results were previously tagged as non implemented,
and were
not widely used, any objections?

Regards,
Francisco Lopes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150121/a1c39d41/attachment.html>


More information about the cfe-commits mailing list