Commit Graph

131 Commits

Author SHA1 Message Date
David Schulz
80633a59aa LanguageClient: support additional goto targets in symbol support
Allow to follow to the symbol definition as well as to the type
definition for the symbol under the cursor position.

Change-Id: I8ff50b33a1e739f81b0832b1b28ffc525e1f7177
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-09-29 09:10:14 +00:00
Christian Kandeler
0a058bb657 CppEditor: Consider symbol occurrences in comments
... when renaming.
For local renaming, we consider only function parameters.

Task-number: QTCREATORBUG-12051
Change-Id: I7948d69f11b97663c9bd747ae6241a82dd9bdd82
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-09-01 11:42:17 +00:00
David Schulz
a137f2b23d LanguageClient: cancel find link at requests on rerequest
This avoids triggering the callback if we already requested a find link
at for a different position. Additionally we also cancel the request if
the document changes or the cursor moves inbetween requesting the link
and receiving the response.

Change-Id: Iffc7b08012a649397e7ca7dfc99d314a1bbf19f7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-08-28 05:58:24 +00:00
Christian Kandeler
20cb9b6e69 ClangCodeModel: Do not call FilePath::exists() on random strings
Fixes: QTCREATORBUG-29356
Change-Id: I6f4d89a6823829a7ecf16200786621321fea61a5
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-07-04 08:36:40 +00:00
Christian Kandeler
f0a1591035 ClangCodeModel: Adapt to new "inactiveRegions" notification in clangd
See https://reviews.llvm.org/D143974.

Change-Id: Iff6cc39f7c567feee1953fde1ca96a9aefec75d4
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-06-08 11:06:15 +00:00
David Schulz
bc9e90f8b6 LanguageClient: add projects filter function
Can be used to filter projects get reported to the language client on
server startup and when a project gets opened.

Change-Id: I8cfbc45ecb5251fcaecf2c331a9f1eff966c8db1
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-05-24 08:50:44 +00:00
Jarek Kobus
2839d019b8 LanguageClient: Use Q_DISABLE_COPY_MOVE
Change-Id: Iee54086810442b64cb8b7aa68a48341909481787
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-24 05:38:02 +00:00
Christian Kandeler
cc52478a93 LanguageClient: Export LanguageClientOutlineItem
To enable more customizations by specialized clients.

Change-Id: I0ad92e248e931389c3fa239df424df8883e1d86e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-02-07 12:01:31 +00:00
David Schulz
9938fffe06 LanguageClient: close and reopen renamed documents
That is the way accoarding to https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_didRename

Change-Id: Ibed1873ac85eb2e9074481537a34f959a55a6f71
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-23 14:01:20 +00:00
David Schulz
15cf2ecf25 LanguageClient: Export ProgressManager
Change-Id: I737b7097878aacf9d1cf5b72af05b1471ab36891
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-17 13:22:21 +00:00
David Schulz
3677932266 ClangCodeModel: reuse Id for restarted clients
This is needed to keep annotations hidden after the restart of clangd if
the user disabled them in the text mark tooltip.

Change-Id: I69a668f2ba71f1dda83eca74a064af7ec1f92e77
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-12 14:45:12 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
David Schulz
2d0456f085 LSP: Support remote LSP file paths
Change-Id: If3cf1b8d675ef091427dbcd703c7d14b384a1b3a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-12-15 09:49:48 +00:00
Eike Ziller
638e73e4f8 Clangd indexing: Hide cancel button, open settings on click
Since we cannot reasonably "cancel" indexing, hide the cancel button
from the progress indicator.
Open the Clangd settings page when clicking on the progress indicator
instead.

Fixes: QTCREATORBUG-27744
Change-Id: I625464e7f7456bcf7f01ce7e52f6bd6b53e3d8b2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-19 06:24:54 +00:00
David Schulz
54feec93e3 LanguageClient: correctly initialize editors of opened documents
Change-Id: I2dee2093c0bdb97a204e89bf0db526ae405b8e78
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-23 11:39:10 +00:00
Christian Kandeler
2fc5dba1c3 ClangCodeModel: Implement per-session mode for clangd
Fixes: QTCREATORBUG-26526
Change-Id: If9e018475b4e2f0557d9bf64ad9a7921c9dd6046
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-05 09:07:13 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Christian Kandeler
321fae46f6 LanguageClient: Support limit parameter for completion request
... and make use of it in the ClangCodeModel tests.

Change-Id: Ib2186273aec1db9b354892c2e1c4ebd82e3c1c96
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-08-04 12:05:18 +00:00
Christian Kandeler
5f9c30cacf ClangCodeModel: Do not make clangd open all ui headers
This amends 01ceb3a3cb, where we failed to
consider the case of projects with lots of UI headers, which cause
excessive memory use by clangd with our current simplistic approach.
Instead, we now only open ui headers that are used by currently open
documents.
Note that this approach will fail for indirect includes via header files,
but people who do that do not deserve happiness.

Change-Id: I1ef2add701e0f13dc0da79267d3c1367c1b496cc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-08-02 09:13:25 +00:00
Christian Kandeler
01ceb3a3cb ClangCodeModel: Switch to LSP-based UI header approach
Generating ui headers in a well-known path and then including that one
in the compilation database does not work in the presence of multiple ui
files with the same name.
As it turns out, we don't have to generate any files at all; instead, we
pass the file contents directly to clangd, which then uses them when
parsing includes of the respective header.
User-visible behavior change apart from the abovementioned bug fix:
Tooltips and "follow symbol" on the include directive now always use the
actual location of the header provided by the build system.

Fixes: QTCREATORBUG-27584
Change-Id: I6b13e12cb3a365199567b0bc824d12b373117697
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-06-02 11:29:14 +00:00
David Schulz
7c86d1a195 LanguageClient: pimpl Client and cleanup includes
Change-Id: I653861e29baeaddcbcd21a5e738be6bd85514617
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-23 11:58:09 +00:00
Christian Kandeler
2c24dc03ac LanguageClient: Request semantic tokens right away on document save
There's a good argument to be made that a doument save should bypass the
usual waiting period for requesting new semantic tokens.

Fixes: QTCREATORBUG-27403
Change-Id: I8355147116bccdcbcd4f6689b4d9c7a282d324be
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-23 08:31:53 +00:00
David Schulz
a493970e05 LanguageServerProtocol: remove IContent
Do not pretend to support multiple message types, while no other
messages are actually implemented by us or even known to exist in the
wild.

Change-Id: I49ee2118b2e10f265ac641c195df8a9e5c97951c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-20 06:35:47 +00:00
David Schulz
0422233af4 LanguageClient: Move the interface out of the gui thread
Change-Id: Iec34f5a0ca3f7f8e2306d3c8a50c2155b5b96807
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-19 09:49:42 +00:00
David Schulz
0b6bc0d187 LanguageClient: Move the BaseMessage to JsonRpcMessage conversion
... to the client interface. JsonRpcMessages are the only messages used
so far and no other types of messages are currently used by any of the
supported Language Servers. If a client is going to need special message
parsing it can still implement a specialized client interface and
overwrite parseCurrentMessage. This is the preparation to move receiving
and parsing data passed to and from the language server out of the GUI
thread.

Change-Id: Ibd4cd95daab7efff947273ca9e7d457de0286f47
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-17 04:31:06 +00:00
David Schulz
6006ec8180 Coco: Add coco hoverHandler if diagnostics are visible
Change-Id: Id0a72fe0fc8a79e30e87fc7a0632eeb41338e73c
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-05-16 07:39:06 +00:00
David Schulz
ccf3e1d5c4 LanguageClient: set the client info in initialize params
Change-Id: If7be38a9bd8f7bae0d2a4263a5a6bf7d2c7e34a9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-05-06 11:50:19 +00:00
David Schulz
42fc527fec LSP: Simplify content parsing
JsonRpcMessageHandler::toJsonObject can be expensive for huge
json objects like the clangd ast responses for big c++ files. Avoid
calling this function in Request::responseHandler. We already generate a
JsonRpcMessage in JsonRpcMessageHandler::parseContent to get the id of
the response so pass this around.

While at it also pass around references instead of pointers to simplify
the memory handling of generated messages.

Change-Id: I9a3c7e85428fc064d1ea1197d897739725265192
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-04-14 12:59:49 +00:00
David Schulz
e437cf7a71 LanguageClient: export DiagnosticManager
Change-Id: I60b3e6b14bf364da60fb8b3de6d5d5cc1cd2e634
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-04-01 10:44:39 +00:00
David Schulz
9d1fe1df14 Python: ensure opened file is inside a workspace
The Python language server seems to dislike files that are not part of a
workspace resulting in very long lookup times for specific symbols.

Fixes: QTCREATORBUG-26230
Fixes: QTCREATORBUG-24704
Fixes: QTCREATORBUG-24140
Change-Id: Iceb7a2b3d57aea6554225a74587f619e530e10c9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-03-21 09:08:19 +00:00
Eike Ziller
cd8c4ced81 Merge remote-tracking branch 'origin/7.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri

Change-Id: Ic02df53b880d0861d9d9ea0df3e0d381ae99f350
2022-03-11 09:50:48 +01:00
Christian Kandeler
9735049e2c ClangCodeModel: Suppress "Unknown argument" error
Unknown compiler flags are an unsuppressable error in clang.
But we do not want to maintain a blacklist of unsupported GCC and MSVC
options or a whitelist of supported clang options, as both would
constantly go out of date.
As clangd seems to work fine despite the error message, we simply filter
out this type of diagnostic.

Fixes: QTCREATORBUG-27113
Change-Id: Ib32601831eded60daf80eb0ca5cf01bbd71493fa
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-03-02 12:59:54 +00:00
Eike Ziller
8259df00d0 Merge remote-tracking branch 'origin/7.0'
Conflicts:
	src/plugins/mcusupport/mcupackage.cpp
	src/plugins/mcusupport/mcusupportoptions.cpp
	src/plugins/mcusupport/mcusupportoptions.h
	src/plugins/mcusupport/mcusupportoptionspage.cpp
	src/plugins/mcusupport/mcusupportplugin.cpp
	src/plugins/mcusupport/mcusupportsdk.cpp

Change-Id: Ib423e9f23877176f01b188104b0a179ed32c4770
2022-02-22 14:06:41 +01:00
David Schulz
05e102fbac LanguageClient: forcefully delete client after timeout
If the client does not react within 20 seconds on the shutdown or exit
message delete the client.

Task-number: QTCREATORBUG-27064
Change-Id: I9680242e471989ea820c4e28d28c500c27a20bb7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-02-22 12:17:08 +00:00
Christian Kandeler
15280d7127 ClangCodeModel: Request clangd quickfix for -Wswitch warning
This way, a warning about missing switch cases will be accompanied by a
matching code action, which allows the user to fix it right away by
clicking on the lightbulb.
Requires clangd >= 15; see https://reviews.llvm.org/D118976.

Change-Id: I11e82264c41e4154f979d28a5e44e72c8158595b
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-17 12:38:49 +00:00
Eike Ziller
49ecd64b9c Merge remote-tracking branch 'origin/7.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/docker/dockerdevice.cpp
	src/plugins/mcusupport/mcupackage.cpp
	src/plugins/mcusupport/mcupackage.h
	src/plugins/mcusupport/mcusupportoptions.cpp
	src/plugins/mcusupport/mcusupportoptions.h
	src/plugins/mcusupport/mcusupportoptionspage.cpp
	src/plugins/mcusupport/mcusupportsdk.cpp
	src/plugins/mcusupport/mcusupportsdk.h

Change-Id: I8c8f5953a21729ba9178dbc44ed613eed131a0c8
2022-02-16 10:59:04 +01:00
David Schulz
dc268e3157 LanguageClient: log exit notification
Add a private function that logs and sends a basemessage without
checking the current server state and use it for server init,
sendContent and exit.

Change-Id: I6532dfb36ef5bf4d036bb71dbfab4ab29497fc9a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-02-15 13:37:52 +00:00
David Schulz
5b307634c3 LanguageClient: fix race condition on client shutdown
If a document is closed between removing a closing client from the
tracked clients in the LanguageClientManager and the actual destruction
of that client we might derefernce an already desctructed document in
resetAssistProvider.

Connect the document closed signal in the client instead of the manager
so Client::closeDocument gets called even if it is not tracked in the
manager anymore.

Fixes: QTCREATORBUG-26534
Change-Id: I7187730600eeb1df54355065eb9cb703a605139e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-02-14 09:03:51 +00:00
David Schulz
a992a3440b LanguageClient: add send configuration helper
Change-Id: If078a0354b86ca3dba5fceec94ce266424fe0c99
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-02-04 11:42:51 +00:00
David Schulz
348652dc26 LanguageClient: move document symbol support check to client
Used there to prevent requesting document symbols from server that do
not support these requests.

Change-Id: Icca64c41415ba7098c769854823431fb05e5ce1d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-02-04 11:41:14 +00:00
Christian Kandeler
92156cc1d6 LanguageClient: Indent code coming from the server
... if the client implementation requests it.
The server is not necessarily aware of our indentation style, so we
might have to apply it to the newly inserted code.

Change-Id: I43518575c7124568da42be3b04a28d7f352f6dc2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-03 14:30:19 +00:00
Christian Kandeler
8b63dfccc6 ClangCodeModel: Make clangd refactoring actions available
Introduce an assist processor that merges our built-in quickfixes with
refactoring actions from clangd ("tweaks").
For now, we make it clear which ones are coming from clangd, and we do
not filter duplicate functionality. In the future, we might want to
disable redundant built-in actions if clangd is enabled for the
respective file.

Change-Id: I04842132798c8635dfddf8cfc98cc7a6313fac09
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-01 11:02:53 +00:00
David Schulz
c926db336b LanguageClient: always delay document highlight request
The request for highlights of the symbol under the cursor takes a
considerable amount of time on some servers (at least python). Postpone
those requests a bit so that more important requests can be handled
before.

Change-Id: I35776076a4ee9c0c9b7646e960d3d965506154d3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-01-17 10:23:03 +00:00
Christian Kandeler
825c9ea64f ClangCodeModel: Work around clangd cursor issue
If the cursor is right before the "." in a member access expression,
clangd interprets it as belonging to the member instead of the base
expression, which leads to unexpected behavior.
Work around this by sending a cursor position one to the left of the
real one to clangd in such cases.

Change-Id: I429ee9189760ccb02d231acfcb94ab6cfde3cd8d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-12-03 11:17:17 +00:00
David Schulz
6aa2c58842 LanguageClient: remove semantic highlighting proposal
The semantichighlighting proposal from
https://github.com/microsoft/vscode-languageserver-node/pull/367
was replaced with semantic tokens in the final protocol version 3.16.

This reverts 307f1d8e6e

Task-number: QTCREATORBUG-26624
Change-Id: I635f0b4763a197edabf9edf8d9041143dcf531e3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-29 09:57:45 +00:00
David Schulz
f16a473b3b LanguageClient: make sure to send a response to a request
Restructure the message handling in the client, so if we get a message
with an id always send a response to the server either with the result
or with an error. Also make sure to not send responses to unreachable
server.

Change-Id: Ie74128069c1678af60871896d5dce45c08e71b05
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-19 10:32:11 +00:00
Christian Kandeler
78562d4925 LanguageClient: Allow clients to provide extra tabs for inspector
Change-Id: I530eca50393289dbf85fb0088d2a62c2729d28b2
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-17 13:43:29 +00:00
Jarek Kobus
c13d828c99 Remove unneeded includes of QProcess
Change-Id: I017e020c8b2a53d6f4a2422a0a0856044e768247
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2021-11-03 08:13:18 +00:00
David Schulz
33cfb7ebfc LanguageClient: add a human readable version of client state
Change-Id: I650e4b4932f32ad86505e9be2fc85eef6bcd6edd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-01 10:22:11 +00:00
Christian Kandeler
40f863b9cf LanguageClient: Allow to log to console rather than message window
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>
2021-10-15 09:26:37 +00:00