Commit Graph

13 Commits

Author SHA1 Message Date
Christian Kandeler
dfa24f09ad ClangCodeModel: Show only valid applicable overloads when completing
libclang is smart enough to filter the overloads according to which
arguments have already been entered, so let's make use of that.

Fixes: QTCREATORBUG-650
Change-Id: Ic2711f460c908c6fd9c8efe28c3c63a0ce2d9205
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-17 07:09:37 +00:00
Christian Kandeler
7938320291 TextEditor: Introduce shortcut for forcing a function hint proposal
... and support it in the ClangCodeModel.
This allows users to get function signature(s) displayed regardless of
where exactly the cursor is on the function call.

Fixes: QTCREATORBUG-19394
Change-Id: I033e8774db93680bfc3ee52610b817e0ef8ccc76
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-11 10:10:08 +00:00
Nikolai Kosjar
2aa067f28e Clang: Fix adding snippets after opening brace
The regression was introduced by

    commit 82d6d20acb
    Clang: Do not show completions after comma in initializer list

This fixes ClangCodeCompletionTest::testCompleteGlobals().

Change-Id: Ic126f1e3eaed158196268e3682ff32bc02deb7b9
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-10 07:56:48 +00:00
Nikolai Kosjar
bc6c65396f Clang: Fix providing snippets for another case
We have to indicate snippet addition for the PassThroughToLibClang case.

This completes

    commit d946ff5403
    Clang: Fix adding completion snippets after {

Change-Id: Ib543c415d4fdcc99d8bbf4815930f3d8481bc810
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-11-27 07:07:18 +00:00
Nikolai Kosjar
d946ff5403 Clang: Fix adding completion snippets after {
...e.g. as in "void f() {".

The criteria whether to change snippets got invalidated with

    commit 8d0391a4f9
    Clang: Treat brace initialization as constructor completion

as the completion operator might be T_LBRACE now instead of T_EOF_SYMBOL
for normal completions.

This fixes the plugin test ClangCodeCompletionTest::testCompleteGlobals.

Add also unit tests.

Change-Id: I85cf522b9b307359c5c3e25198dd228cbb68ded0
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-25 12:13:57 +00:00
Ivan Donchevskii
8b6a16c95b Clang: Fix completion after '{'
Follow-up fix for 8d0391a4f9.

Do not complete after '{' coming not after an identifier.
Take constructor completions only for '{' and function
completions only for '('. Filter constructor completions by
class/struct type.

Task-number: QTCREATORBUG-21004
Change-Id: I7ae2d6bee23cf907648c42b93eb12742942833f6
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-30 13:36:52 +00:00
Ivan Donchevskii
8d0391a4f9 Clang: Treat brace initialization as constructor completion
Try to complete constructor after left brace with fallback
to normal completion.

Task-number: QTCREATORBUG-20957
Change-Id: I6c33790a3ee1e623a3d8abe9a44cfd821b6f3106
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-21 10:40:04 +00:00
Nikolai Kosjar
7cbc7af022 Clang: Fix completion after qualification (::)
...and maybe other cases.

Since

    Clang: fix findStartOfName handling
    commit 82d0650b11

the proposal's base position was calculated wrong. As a result, an early
return triggert in CodeAssistantPrivate::displayProposal (call to
newProposal->hasItemsToPropose(prefix, reason)) and no completions were
displayed.

Fix by ensuring that the added code from the mentioned commit is only
called when needed, namely only for function expressions.

Task-number: QTCREATORBUG-19083
Change-Id: I8f23c9b7186f9d81159939c8b3ef475a09bbe760
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-10-19 07:43:21 +00:00
Ivan Donchevskii
d809e3fb8f Clang: send function name position for completion
... to reuse this position in backend (instead of
searching the function start again)

Change-Id: I02818dce4fc37ed6e7ecfb533191dbfe60610204
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-08 07:37:06 +00:00
Ivan Donchevskii
82d0650b11 Clang: fix findStartOfName handling
... of templates and qualified names

Change-Id: Ic8c2dec35cb74484f474c0c608857e7cf48c7468
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-05 14:16:04 +00:00
Nikolai Kosjar
64ec695566 Clang: Show function signature hint for constructors and functors
For "foo(|" [1] we requested a completion from libclang with the cursor
position just before "foo" and then filtered the function declarations
for functions matching the name "foo". This worked fine for ordinary
functions, but obviously not for constructors and functors.

Recent versions of libclang support proper function call completion with
XCursor_OverloadCandidate, so make use of that.

[1] '|' represents the cursor position

Task-number: QTCREATORBUG-14882
Task-number: QTCREATORBUG-14884
Change-Id: I9d31b3960ccff6a8b9440dbcb7ff9f5ca9f61266
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-05-11 11:54:09 +00:00
Nikolai Kosjar
bc9afe3bbb Clang: Tests: Fix test names in ClangCompletionContextAnalyzer
Change-Id: I5a1b322957edb30cd4fe5a50deb50255da18cf8d
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-04 10:18:24 +00:00
Marco Bubke
47c01daeb2 UnitTest: Cleanup
Improve naming and introduce googletest.h.

Change-Id: I445c13db4c23d6dd5682ce0db3b83055cc6b8a89
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-09-19 15:17:54 +00:00