Commit Graph

250 Commits

Author SHA1 Message Date
David Schulz
d73fbbcb97 LanguageClient: send exit notification after failed shutdown
Despite receiving an error in the shutdown response continue to exit the
server. Otherwise we end up with an unusable client.

Change-Id: Iacff38699cb4e5bcc5610eba1654047bf7f8ce80
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-02-22 13:12:44 +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
David Schulz
ad9365d8fd LanguageClient: Do not assert on opening the same document twice
Just silently ignore a second open. This is now consistent with
LanguageClientManager::openDocumentWithClient that also supports calling
it multiple times with the same document client combination.

Change-Id: I6e8eaf312805cd4e82070209b414d63433158360
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-02-22 11:31:23 +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
Christian Stenger
282c3d0dab LanguageClient: Do not send initializing request twice
Amends dc268e3157.

Change-Id: I6ca81ec336f09c02b26f47b5e00bebbc54882ed6
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-16 13:07:59 +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
c9cd00f2ce Python: add lsp configuration widget
Change-Id: I688981293e3bbbee64fc2d714146fcdfa8126458
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-02-09 09:03:30 +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
97e81d35df LanguageClient: always send the full list of workspaces at startup
Change-Id: I74203b7bc71982b0e6e347b004d48531a07069dc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-02-04 11:42:35 +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
Eike Ziller
d422b408e0 Merge remote-tracking branch 'origin/6.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri

Change-Id: I32991a77e52831dd2e24cf4a51ec252998c2d743
2021-12-09 12:04:32 +01:00
Joni Poikelin
41fe7eec65 LanguageClient: fix textDocument/didChange
Fixes: QTCREATORBUG-26651
Change-Id: I640558bc321112f8dd568a4cefc306eb209af7b0
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-03 13:07:52 +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
333374e6a9 LanguageClient: move remove project connection to client
Change-Id: I63ff089c7b72a4f72ddf65548dc8df1cc6763ff9
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-12-01 05:39:08 +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
David Schulz
d2ff57309b Client: make sure to reset project for client
Change-Id: I23860ee07c4f5793ce3247f46e8d925eae2b2bea
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-10 12:50:07 +00:00
David Schulz
a0fba57508 LanguageClient: remove unused variable
Change-Id: I0910a0b75fe727c40c0249437895eb9d3566f7a2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-11-10 10:41:08 +00:00
David Schulz
426fde79d6 LanguageClient: support semanticTokens/refresh
Fixes: QTCREATORBUG-26499
Change-Id: Icd5879609bb856797fa223394357a1f15554d2cf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-11-03 07:46:50 +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
David Schulz
7df00776d1 LSP: Add support for activeParameter of SignatureInformation
Task-number: QTCREATORBUG-26346
Change-Id: Ieab18f08e4f1b9fa6cacfae0a18310af4bc35165
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-30 11:37:29 +00:00
Christian Kandeler
901a96231c ClangCodeModel: Cache clangd's AST
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>
2021-09-28 11:34:25 +00:00
David Schulz
e7f6abc084 LanguageClient: remove codeassist proposal handler
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>
2021-09-28 09:50:46 +00:00
Christian Kandeler
c47312a836 LanguageClient: Pass out a mutable Project object
Callers can have legitimate reasons to use it in a non-const manner.

Change-Id: Id91a4708dd95845661b291ce7cc9ee1581bdade8
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-24 08:41:18 +00:00
Christian Kandeler
bcfe229f8b ClangCodeModel: Get document symbols immediately
... when doing a decl/def switch via clangd.
The delay is fine for e.g. populating the outline, but shouldn't be used
when dealing with explicit user requests.

Change-Id: I0350ed6daf8220ec3b702a3876fbf0f726da8a67
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-16 09:09:27 +00:00
Christian Kandeler
1206ac03cc LanguageClient: Do not update semantic tokens on every document update
Due to the potential cost of the re-highlighting procedure, we'd like to
delay the semantic tokens update request to a time where the new token
information won't get invalidated right away due to further document
changes. While the document updates in principle have such a delay
already, it is often "sabotaged", for instance due to auto-completion
requests which require the server to know the current document contents
right away.
Therefore, we request new semantic tokens along with a document update
only if it's the "regular" delayed one, and otherwise add an additional
delay.

Change-Id: I074647d1cdfdbcc6aa5fc5ec2a2d5ae6ccd493ba
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-15 09:12:18 +00:00
Christian Kandeler
30cbda2b2d LanguageClient: Improve use of Client::m_documentsToUpdate
In particular, calling keys() and then take() for all the keys is
wasteful (and obscures what's going on).

Change-Id: Ic66803cf3579a39c23c32f1fc65e2c9399dcc583
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-14 12:50:22 +00:00
Christian Kandeler
268f4ac406 LanguageClient: Merge adjacent change events
This saves a lot of data going over the wire.

Change-Id: Iac1220c72797643ba09bf90b02f7b5155cda4b0f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-14 10:05:10 +00:00
Christian Kandeler
719f51445e ClangCodeModel: Use dedicated completion assist provider for clangd
The pure LSP-based implementation is too inflexible with regards to
activation characters.

Change-Id: I386a60b80f59e1b48254d55c2a47f1a1ffe1f97f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-14 09:11:33 +00:00
Eike Ziller
3d4d7c7e14 Merge remote-tracking branch 'origin/5.0'
Conflicts:
	src/plugins/clangtools/clangtoolssettings.cpp
	src/plugins/clangtools/executableinfo.cpp
	src/plugins/clangtools/executableinfo.h

Change-Id: Id8caf63e3e594792467d3447870086bd2d8f73b9
2021-09-13 17:03:55 +02:00
David Schulz
c1dff744a0 LanguageClient: Increment document version on every content change
Prevents applying results from outdated documents. Specifically
notifications and codeactions for documents that have been cleared on
the contents change handler but get a result before sending the actual
did change notification.

Change-Id: I640088d7cb2464dd4edd832319314bb04eab1df3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-07 10:24:43 +00:00
Christian Kandeler
847a03786c LanguageClient: Re-highlight also on empty deltas
This is needed for e.g. ClangdClient, which may need to update even if
the highlighting delta from the server is empty.

Task-number: QTCREATORBUG-26183
Change-Id: I38398c9563fa7a6a1906c5cb57fd1cbcd444cbd9
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-07 09:12:13 +00:00
David Schulz
a111a68442 LanguageClient: stop documentHighlights timer on document changes
If the position was changed right before the document was edited the
timer might still be running.

Change-Id: Ieaa4de5cc10f25e6d58afaf9525417e11a34d1db
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-02 08:21:04 +00:00
Christian Stenger
752b967952 LanguageClient: Fix possible crash
If a restart for a client has been staged for restart the
shutdown of QC may coincide with the start of the client which
leads to a crash on exit. Correctly track clients that never
successfully started to clean them up on manager destruction.

Change-Id: I639a76318d1665653fbcd37841fcaf407f3d3a83
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-08-30 12:23:05 +00:00
Christian Kandeler
e0e8fda580 ClangCodeModel: Use clangd for completion and function hint
Change-Id: I80160f3a40da18ac178682afe6caba5e5af6e3eb
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-08-23 09:06:31 +00:00
Eike Ziller
94d352ab28 Merge remote-tracking branch 'origin/5.0'
Conflicts:
	src/plugins/autotest/testresultdelegate.cpp

Change-Id: If172206f231fc2a9f4a672cd2e6eaeaea4988c96
2021-08-18 16:14:24 +02:00
David Schulz
9539aff27d LanguageClient: Do not send will save notification by default
Change-Id: I4fb9bda0bf0b8401c9d92be3b5525be1c44a0eb8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-08-18 09:23:25 +00:00
Eike Ziller
ab606faad2 Merge remote-tracking branch 'origin/5.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/android/createandroidmanifestwizard.cpp

Change-Id: Ibd06a254f52c2c96d8c6ddd6b1d27483fcc29a17
2021-08-16 10:51:50 +02:00
David Schulz
67a86b72b7 LanguageClient: do not send empty responses
Even if we do not have to provide any data just send a null as the
result so the server nows that the request did not fail.

Fixes: QTCREATORBUG-26116
Change-Id: I9b965389bb197cdd81d0d3ffbac05f289cabda40
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-08-16 07:48:34 +00:00
David Schulz
fdd3b03ba9 clangd: add setting for document update timeout
Change-Id: I4fae2cdff022f6f29566c0316a8ade51d3482466
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-08-16 07:48:22 +00:00
David Schulz
e88b4ebce8 clangd: open documents just once
Opening a document in the language client while the server is still
initializing will postpone the opening after the server is fully
initialized. So if a document was scheduled for opening by
ClangModelManagerSupport::onEditorOpened while clangd is still
initializing, skip the superfluous opening in the ClangdClient
initialize callback. Clangd seems to have issues if files are opened
twice, resulting in strange diagnostics after editing the file. This is
reproducible for me when starting Qt Creator with a session that
contains open files.

Change-Id: I200d5c8afb685403f0435e0553f5a475f75e8ea2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-08-11 14:55:44 +00:00
David Schulz
dc87947cb3 ClangD: skip automatic code action request
.. after receiving diagnostics since the code actions are already
inlined into the diagnostics.

Change-Id: I11ed1270344ff5119dd111503d173eef2f340c1d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-08-11 10:34:17 +00:00
David Schulz
30981f5ba2 LanguageClient: fix typo
Change-Id: Icb04ed3f444b443ea97febeadd2766bb62fdbb85
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-08-10 06:20:27 +00:00