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>
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>
... 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>
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>
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>
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>
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>
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>
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>
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>
Callers can have legitimate reasons to use it in a non-const manner.
Change-Id: Id91a4708dd95845661b291ce7cc9ee1581bdade8
Reviewed-by: David Schulz <david.schulz@qt.io>
... 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>
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>
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>
The pure LSP-based implementation is too inflexible with regards to
activation characters.
Change-Id: I386a60b80f59e1b48254d55c2a47f1a1ffe1f97f
Reviewed-by: David Schulz <david.schulz@qt.io>
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>
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>
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>
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>
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>
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>
.. after receiving diagnostics since the code actions are already
inlined into the diagnostics.
Change-Id: I11ed1270344ff5119dd111503d173eef2f340c1d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
If the document highlights are requested after a timeout the document
might have changed again inbetween leading to another document change
notification that gets send to the server.
Change-Id: I476e833c55e1bed96c9bd49ee2f17915ee3536a2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Note that we lose the highlighting for virtual function calls. We need
to amend clangd to add the respective information to its semantic tokens
message.
Also, Qt properties are no longer highlighted as class members. We'll
investigate how to best restore this feature.
Change-Id: I403712aada3d7a8e1c7b7c1277f43f7f64f8450b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Note that we used to encode the information about symbol visibility and
static-ness in the icons, which we can't do anymore, because clangd does
not provide this information.
On the upside, this change likely fixes a ton of bugs, as our own outline
was rather "quirky".
Change-Id: I099f11ec4e3c6f52cd461fb43080bbdde3bed5e5
Reviewed-by: David Schulz <david.schulz@qt.io>
We track the document revision in the client nowadays.
Change-Id: Ia55bc7cd5eaf100fb19953ca71e8de8f43ae3266
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>