Commit Graph

223 Commits

Author SHA1 Message Date
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
David Schulz
bbb06a72ec LanguageClient: reapply semantic highlight after font changed
Change-Id: I609e26b7f85744fdffb8399e0d651691b7c39900
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-08-10 06:20:20 +00:00
David Schulz
a8a3cd4f91 LanguageClient: directly update document highlights on changes
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>
2021-07-12 05:05:52 +00:00
Christian Kandeler
4d3ed0fa93 LanguageClient: Do not send document updates when canceling a request
Change-Id: Ied675bb0eca353fd5ffe26540d99bafb6a874c0d
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-09 11:24:13 +00:00
Christian Kandeler
68846a7729 ClangCodeModel: Provide highlighting via clangd
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>
2021-07-05 07:39:06 +00:00
Christian Kandeler
c0a44be27b ClangCodeModel: Provide outline via clangd
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>
2021-07-01 08:36:20 +00:00
David Schulz
922f9b159d LanguageClient: fix diagnostic document revision check
We track the document revision in the client nowadays.

Change-Id: Ia55bc7cd5eaf100fb19953ca71e8de8f43ae3266
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-06-29 04:49:50 +00:00
Christian Kandeler
7bf52b0c0d ClangCodeModel: Provide diagnostics via clangd
Change-Id: Ib45a62ebe200c2b56a1bb1a66f8a92103e60d092
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 13:22:36 +00:00
David Schulz
e13c2b7403 MimeDatabase: add FilePath convenience function
Change-Id: I59c825490b3b5c49f3c177584ea4cc885c4f920b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-23 12:03:28 +00:00
David Schulz
439bb9c4ae LanguageClient: manually track document version
Using the document revision causes issues for some servers.

Task-number: QTCREATORBUG-25766
Change-Id: Ic858e19c6fe39e57c9d3124913887aafee0a3cd0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-15 13:01:05 +00:00
David Schulz
d729835c24 LanguageClient: add snippet parsing
Task-number: QTCREATORBUG-22406
Change-Id: I5b3a65984f1b4a9198bcbfec24aaa920dcb6dbf1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-10 11:46:37 +00:00
David Schulz
dc0b2c8b47 LanguageClient: clear running progress when resetting client
Otherwise we will have dangling progress bars after a crashed server was
restarted.

Change-Id: I889d201d7cf196623978638db67397203a8f4564
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-03 07:32:38 +00:00
David Schulz
9fb4db55be LanguageClient: set the capability for hierarchical symbols
Amends 696dedefa1

Change-Id: Id066ec6ea530b3bc50c4ca71dbfeb59d7520f7ac
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-06-01 11:46:43 +00:00
David Schulz
55208afac4 LanguageClient: clear open documents on client reset
Change-Id: I5a14578a029f8336556a8ff1de8b6827822aaaf5
Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2021-05-18 11:34:31 +00:00
hjk
c23cdd9262 Utils: Merge {synchronous,qtc}process.{h,cpp} file pairs
Mechanical to prepare merging the actual classes.
Adapting #includes.

Change-Id: I77a2c28129287778bc870c30cb890cd26bc2e62b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-10 09:47:51 +00:00
Christian Kandeler
b4e8d32189 LanguageClient: Allow to look up the document for a given file path
Change-Id: I565ce07b28008edbc9d40178069b078ff3530744
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-03 07:37:41 +00:00
Christian Kandeler
248ebb494d LanguageClient: Expose server information
Server name and version are potentially interesting information.

Change-Id: I4fc9a2556d7fd8285fe0024cf0f83baf95112e65
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-03 07:23:24 +00:00
David Schulz
1d7e05e6a9 LanguageClient: remove unneeded document actions blocker
Change-Id: Id1f07dbf83fcf7d75aaba6d860fb1556761bbd4b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-04-27 08:38:16 +00:00
Christian Kandeler
91b6c58518 LanguageClient: Add signal to inform about WorkDoneProgressEnd
... and make use of it in the clangd client to be able tell when
background indexing has finished.

Change-Id: I0f3c6f9646fd66ababd08c12b2f347da5f1a3729
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-27 07:37:25 +00:00
Christian Kandeler
90a07eca28 LanguageClient: Add the possibility to override progress messages
... and make use of it in the clangd client.
We want the progress bar for background indexing to have a better title
than the plain (and non-translated) "indexing" that the clangd server
sends.

Change-Id: Ib75eac370e7c22f0c5bd477f4a4c423283b27e1f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-26 08:13:21 +00:00
Christian Kandeler
ecafdb7543 ClangCodeModel: Add experimental clangd support
If the user has enabled clangd (default is off), we start up one instance
per project when it is opened/changed (including build config switches),
and trigger background indexing.
So far, the index is used to provide results for locators and "Find
Usages".
Per-document functionality such as semantic highlighting and completion
is still provided by libclang.

Change-Id: I12532fca1b9c6278baab560e7238cba6189cde9f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-22 07:32:58 +00:00
David Schulz
f1bb3b6811 LSP: add semantic tokens
Change-Id: Ia6865ec6991ec62ae9f0dc2dfa692f1f27318ed1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-21 11:33:56 +00:00
David Schulz
d66b410adb LanguageClient: do not auto-assign documents to all clients
Only assign documents to a client if the client was started by a
setting. Programatically started clients should handle assigned
documents manually.

Change-Id: I192c4c011a48e0406f267d3cab3c860f740ddad7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-04-20 11:44:12 +00:00
Eike Ziller
2800f3b51f Merge remote-tracking branch 'origin/4.15'
Change-Id: I0afcf51d354ffd73a8f2956a7f78b1e4f032677b
2021-04-09 12:42:03 +02:00
David Schulz
86679c130b LanguageClient: update dynamic capabilities just once
Change-Id: I7149f581e55a25672dce44abc751912e02271135
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-09 07:48:57 +00:00
David Schulz
ae85170b66 LanguageClient: untrack request on cancel
Now we search for the key twice in the hash, but the hash shouldn't get
to big and the lookup doesn't happen very often.

Change-Id: I4751a8203321bb4c1ea5092b89593971d736e034
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-07 06:17:05 +00:00
David Schulz
f13d402b31 LanguageClient: prevent multiple TextEditorWidget connections
Change-Id: I97c7cb00bad898cc5f698bd3dcee23e44acfa9e2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-07 06:16:38 +00:00
David Schulz
1e8879ee72 LanguageClient: track document highlight request based on widgets
We can have multiple widgets per document, so we can have multiple
different cursors for the same document. Tracking document highlights
per widget prevents cancelling a potentially valid request for another
text cursor of another widget.

Change-Id: I800d9be5b44b327351252ab90305b8882efa87bb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-07 06:16:33 +00:00