We have some additional handling with the completion items that might
interfere with the snippets.
Change-Id: I86405ec67af189d01c8a4dfa468f56035e6e69c4
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This can now happen due to the newly implemented refresh support.
Change-Id: If64feede84b044140f7ec04e317289d3f493aa53
Reviewed-by: David Schulz <david.schulz@qt.io>
... for textDocument/references. The --limit-results option was recently
split up; we have to set --limit-references as well now.
Change-Id: I979aa21a11a08e829b6e843c0c135098aac7d3f5
Reviewed-by: David Schulz <david.schulz@qt.io>
... when following symbols with clangd.
The textdocument/implementation request is expensive, so we'd like to
make sure we only run it if we are sure that we're really dealing with a
virtual function. We re-use the information gathered during highlighting
for this purpose.
Change-Id: Id92a9a92fe2ac7fd5acf903a9ade711223ee401b
Reviewed-by: David Schulz <david.schulz@qt.io>
... and make use of it in the built-in code model and with clangd.
Task-number: QTCREATORBUG-16580
Change-Id: I8c331f56aa1bbf91c9f768be82a779a72f40c4c7
Reviewed-by: David Schulz <david.schulz@qt.io>
... when doing "find usages".
The symbol info request follows typedefs, which will result in confusing
search window contents. So do the symbol info request only if the cursor
is not on a normal identifier.
Change-Id: I0d3bd8bfd47879c59e6656a4da73344406c97a21
Reviewed-by: David Schulz <david.schulz@qt.io>
... with clangd.
This required rewriting getAstPath(), because the previous
implementation did not do the necessary backtracking and could therefore
miss the AST branch containing the node fully matching the input range.
Task-number: QTCREATORBUG-22381
Change-Id: Id5caf2a401b920c0e76f742bec97b5ca6977b4df
Reviewed-by: David Schulz <david.schulz@qt.io>
... by default.
This feature often doesn't do what you'd want it to, so we make it opt-
in.
Change-Id: I631eae9c154ddcb0e8feeac44c5d5c0265706a67
Reviewed-by: David Schulz <david.schulz@qt.io>
... when highlighting with clangd. This can happen due to macro
invocations or unusually placed includes.
Task-number: QTCREATORBUG-26396
Change-Id: I471faee13c62fa511bdedfdd5b864327e858f6b8
Reviewed-by: David Schulz <david.schulz@qt.io>
And make use of that in ClangdClient.
When I get a slowdown while typing, it is usually accompanied by the
clangd message "Request cancelled because the document was modified"
occurring in the message window, often many times in a row. I'd like to
find out whether writing to the message window itself is a contributing
factor to the slowdown.
Change-Id: Iff7c459af0aed27d22366b9aade573f51eb5dbc7
Reviewed-by: David Schulz <david.schulz@qt.io>
Namely, do not duplicate parts of the to-be-completed item (including
parentheses) that already exist at the cursor position.
The code is taken from ClangAssistProposalItem; I had left it off in the
original implementation, because I mistakenly assumed that clangd would
handle this situation itself.
Change-Id: I216f5d507a54db90cd23af2fadb26060dbc4a735
Reviewed-by: David Schulz <david.schulz@qt.io>
Some AST nodes have no range, triggering crashes in QStringView::mid().
Rather than checking all callers, we just use a safe variant.
Change-Id: I3c8d388693f9161249f201ecd4e8bad933463960
Reviewed-by: David Schulz <david.schulz@qt.io>
Profiling has shown that this function is a hotspot. Luckily, it can be
easily sped up by taking advantage of the fact that the AST nodes are
(mostly) sorted by range, allowing us to employ a binary search when
looking for a given range.
Change-Id: I950c150543ff68b975d36c6fb652d366b93ea3b2
Reviewed-by: David Schulz <david.schulz@qt.io>
The question which concrete AST node corresponds to a given cursor
position is surprisingly difficult to answer, and clangd already has a lot
of code for this. Therefore, we always refer to clangd to get a concrete
node, even if we already have the full AST.
Change-Id: I5d1528d776ee459a53b8e650a616ea7019ec59bf
Reviewed-by: David Schulz <david.schulz@qt.io>
Semantic highlighter objects are owned by their respective documents, so
we can run into destruction issues when keeping them by value.
Fixes: QTCREATORBUG-26364
Change-Id: Idc128d685ccdd25989dd9389d352453ccc935fa9
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This speeds up semantic highlighting considerably.
Change-Id: I1dca2c8d6b9e41ac2895a53b795466a3249f79bc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
... with clangd.
- Turn function with lots of lambdas into a class.
- Traverse the AST without repeatedly modifying a list in a tight loop.
Change-Id: I46668a4df672c00cbd7b1a562ae94a6db4cbd2fc
Reviewed-by: David Schulz <david.schulz@qt.io>
Annoyingly, LLVM does not complete preprocessor directives in disabled
code, so that we would not offer e.g. "#endif" after "#if 0" (but we
would offer it after "#if 1").
Fixing it would require messing with the clang libs (rather than just
clangd), so let's just keep using our existing code, which seems to work
fine.
Change-Id: I9dabf9a2a8f3a2f68e88a11b62c3df3b5e64a55c
Reviewed-by: David Schulz <david.schulz@qt.io>
allowing to overwrite apply and get rid of the apply helper in the
LanguageClient completion provider and processor.
Change-Id: I066fe10b116d638bd1b7a81d4488840bec5f0b63
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Since we use the AST in several contexts, it can easily happen that we
need to consult it more than once for the same document revision.
Therefore, it makes sense to cache the AST to prevent redundant requests
for potentially large amounts of data.
Change-Id: I33100e0052ee21bb46e91848d3d2e8a0a96bb860
Reviewed-by: David Schulz <david.schulz@qt.io>
The behavior is now the same as when using libclang. Namely:
- The whole block is grayed out, rather than just symbols
having a gray background.
- Ifdefed-out blocks no longer mess with the brace depth.
Change-Id: I8b5f3a788430edcd9dd79249323c26a5ee5d68ed
Reviewed-by: David Schulz <david.schulz@qt.io>
Removes noise from the interface. Using specialized clangd processors
that redirect the proposals for testing purposes is an overall cleaner
solution.
Change-Id: Ia4f3d4720765f0533c5530a2a5c7db3cc971e0be
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
It's not worth the extra effort to restrict the identifier <-> file name
check to data types: There is hardly any possibility for a completely
false positive, as local variables do not pass through this code path.
Change-Id: Ia92549c8c6723e520789a2ad820a2606620d4efe
Reviewed-by: David Schulz <david.schulz@qt.io>
I don't see any explicit sorting of the references in clangd, so let's
continue to not rely on that.
Change-Id: I65269af4995ab851e49f52686a10cc96697fbe64
Reviewed-by: David Schulz <david.schulz@qt.io>
We have our own dedicated clang-tidy support, so let's not confuse
users.
Change-Id: I69a32de3ac96ad2c51d70c82a9eb62f811e65460
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Using LanguageClientManager::openDocumentWithClient function to assign a
document to a specific server. This function also takes care of
deactivating the document for the old client and opens it if necessary
in the new client.
Fixes: QTCREATORBUG-26205
Change-Id: Idbff154a62d12c432a2cb10d547f78a537e63a3c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
... for the context of the code assist instead of using a callback from
the text editor.
Change-Id: I636b1b267a944895d4ff732e3c0a8811332ec14f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
In the expression x.f(), x was wrongly categorized as an output
parameter if f was a static function.
Change-Id: I9167f98916963cdaa4b5ac6ead2c86fab43ad02e
Reviewed-by: David Schulz <david.schulz@qt.io>
clangd 14 will tag non-const reference parameters for us (https://
reviews.llvm.org/D108320), so let's make use of that at least as a
shortcut.
Change-Id: I0162b5d7b9fecc3e6ce0338e896980cd5b363ceb
Reviewed-by: David Schulz <david.schulz@qt.io>