Commit Graph

253 Commits

Author SHA1 Message Date
David Schulz
887db6b419 LSP: implement call hierarchy
Fixes: QTCREATORBUG-11660
Change-Id: I006872ba598a807f1f9f16d134fe9ce4fe5dd09d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-11 09:49:01 +00:00
Marcus Tillmanns
bf9e2110e6 LSP: Use localSource
This change allows the LSP to find a local version of a source
file even if the server is running on a remote device.

Change-Id: I274cb327ad958ac3c4486859da666702758b7d42
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-01-10 07:03:13 +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
Eike Ziller
3f4c3a3db4 Merge remote-tracking branch 'origin/9.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/texteditor/texteditor.cpp

Change-Id: I9c8f1331be3f5442f1fd28aeb0a9bc07128629d1
2022-12-20 11:05:01 +01:00
David Schulz
c8e1201236 LanguageClient: Do not send out invalid errors
An error is expected to contain an error message so add one that misses
one. Additionally assert when trying to set an error to a response that
is invalid (does not contain message or code.)

Fixes: QTCREATORBUG-28598
Fixes: QTCREATORBUG-27856
Change-Id: I0631433d847610531758d297a93a5c7cdfdc6c1d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-12-16 07:05:55 +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
David Schulz
3754ce184d LanguageClient: remove refactoring markers when deactivating document
Fixes: QTCREATORBUG-28182
Change-Id: Iab52862ecc205c65d8fbdac34b5f9bc78766e33b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-19 12:01:59 +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
01b07c0563 LanguageClient: deactivate documents on client shutdown
Change-Id: I0a3aa89b1390f3cb7d5816bb85d9fd538fb3f90b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-10-14 09:08:11 +00:00
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +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
David Schulz
b88ba1b7a6 TextEditor: add optional action mask for find usage
Change-Id: If8187b226d176c292d0d90aed870f78d9d3d2730
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-23 11:39:07 +00:00
David Schulz
1c05237820 LanguageClient: prevent accessing freed data on shutdown
Change-Id: I0d6e7abd653acb2ab7409a9cd5e58a2df3b1f259
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-22 10:07:53 +00:00
David Schulz
aeb5f90d71 LanguageClient: postpone outline update until documents are opened
Skip the outline update in the initialize callback since no documents
are opened at that point in time and
LanguageClientOutlineWidgetFactory::supportsEditor will always return
false. The update will be triggered in
Client::activateDocument instead.

Change-Id: Ib26115c2344f7a424c31ce09b751a1d711a93aae
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-09-08 04:56:32 +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
Aaron Barany
8276bd265b LanguageClient: Adjust restart limits
Changed restart timer to 2 minutes and max restarts to 5 for restarting
language client after it exits unexpectedly. This avoids disabling the
language client with clangd 14 in situations where it's likely to crash
during normal editing.

Change-Id: I333bb9d67ed1dbba2b52a1cd916f5d1cf3c0b60b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-02 10:09:48 +00:00
Eike Ziller
04e50438eb Utils: Remove Utils::optional
Since we are now requiring macOS 10.14 we can remove our local
implementation of optional and use std::optional for macOS too.

Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2022-09-01 06:58:04 +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
David Schulz
60f5275edf Client: rerequest document highlight if server is unreachable
Makes sure the highlight is properly updated and prevents assert in
Client::sendMessage.

Change-Id: Ie7ad54c34272867e17f6e20654f27e2fd8711fdc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-08-24 07:53:21 +00:00
Marco Bubke
84c1d6572b Utils: Remove variant.h
Since we are now requiring macOS 10.14 we can remove our local copy of
std::variant and use for macOS std::variant too.

Change-Id: I589d03b35fc56878b7392ffa7047a439e588fe43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-23 09:51:43 +00:00
David Schulz
8031460734 LanguageClient: avoid creating a QTextDocument for every contents change
clone the document when it is opened and adjust it after each contents
change

Change-Id: I4fd511a3b142b1875f1da7d241ab5cddf49322e8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-22 04:38:08 +00:00
Eike Ziller
64247bf571 Merge remote-tracking branch 'origin/8.0'
Reverts/comments out parts of 45f93a817a,
which needs to be resolved in a follow-up commit.

 Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
	src/plugins/clangcodemodel/clangmodelmanagersupport.cpp
	src/plugins/cmakeprojectmanager/cmakesettingspage.cpp
	src/plugins/python/pythoneditor.cpp
	src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
	src/plugins/scxmleditor/common/colorsettings.cpp

Change-Id: I7f0f7b7120e75a9fc3a8886bc57c17345cbb501b
2022-08-19 12:48:27 +02:00
David Schulz
dc2cd9db94 LanguageClient: correctly disconnect documents changed signal on reset
connect calls to a lambda can not be disconnected with the
sender->disconnect(receiver);
syntax, so save the connection in a QMetaObject::Connection and use this
to disconnect the signal.

Fixes: QTCREATORBUG-27596
Change-Id: I69f5d990aab4e85d768e2101f0157a7dee3c1fa1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-18 11:58:57 +00:00
Christian Kandeler
bd00cc8bf8 LanguageClient: Introduce timeout for restart counter
While it makes sense to stop trying to restart a continuously crashing
server, the restart counter should be reset regularly, as it's not
critical if the server restarts "once in a while" during a longer
programming session.

Change-Id: Ia2efca28ae4a4dba72da947d9eb776e3909d0cb3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-08-11 14:12:35 +00:00
Christian Kandeler
9c963ce8ae LanguageClient: Do not clear shadow documents on reset
We need to preserve this information. Instead, clear only the list of
reverse document dependencies.

Change-Id: I5589d5e3eff613706ea5f2029df1f90eacbbbb4e
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-08-10 11:14:56 +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
David Schulz
80aa0fe1fd LanguageClient: prevent updating closed document
Remove the closed document from the container that tracks document
modifications to prevent accessing a deleted document.

Change-Id: Iafba8ad3ce054761017a8feca28fdc4c8b379ef6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-01 11:35:20 +00:00
David Schulz
9dc1fb3381 LanguageClient: allow aborting hover handler on unreachable clients
Change-Id: I1163144de7d37d3e270e31f2bf523ba812a937a5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-07-04 07:17:41 +00:00
David Schulz
37400e9084 LanguageClient: do not accumulate response handler
Change-Id: Icf297ddf09bb64aea1d50fb24efa231df01eaed1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-07-04 07:09:44 +00:00
Leena Miettinen
14965f5792 UI text: Fix grammar errors and capitalization issues
Change-Id: Iefb1075cc0b14eb8c0e99b6c96c31a91c2b079f0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-06-28 13:54:10 +00:00
hjk
a9245bf186 LanguageClient: Use more FilePath
Change-Id: Ia4ffec1fd2c6bd8dc2cce40efa49e3b4a4634f15
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-06-15 06:20:22 +00:00
David Schulz
ed22ef7854 Python: globalize Python language server settings
Change-Id: I84fcee6462064f0c788492fcfa12a77379af2bd7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-06-10 12:40:43 +00:00
David Schulz
b72f41c7f0 LanguageClient: prevent nullptr access
Change-Id: Ib9838e6912f2f82e4fc9f69f505e2dc9a4c297eb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-06-03 09:41:01 +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
4ab935349f LanguageClient: disable diagnostics after document changes
Calculating new diagnostics after a document change can take a while.
The old ClangCodeModel disabled diagnostics (changed the color to gray)
that were reported before the last document change after some time.
Adapt this behavior to Clangd and other LSP based codemodels.

Change-Id: I0589ba0d0c023f6e7ea3e97fc5b45eb156ddcd37
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-01 10:12:59 +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
29f8db31ff LanguageClient: fix semantic highlight after a server reset
Change-Id: I3a389ec82032d21e2eb932ae8d0e8d5678575427
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-20 11:24:09 +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
Christian Kandeler
5d615e916f LanguageClient: Improve refactoring markers
Clicking the lightbulb should bring up a menu if and only if there is
more than one possible action for this location.
Amends 089e1edcbf.

Change-Id: I45348ed4fbf9b3f32e19bbe17f0c2c030ecd24ed
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-18 11:39:00 +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
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
f562ebf239 Mimetypes: Make implementation switchable between new and old
- configure with QTC_USE_NEW_MIMEDATABASE to switch to the new one in
  utils/mimetypes2/
- added utils/mimeutils.h header for the Qt Creator specific static
  wrappers, that also includes the "public" headers for MimeType et al
  from the new or old implementation, depending on configuration
- change all utils/mimetypes/ includes to utils/mimeutils.h
- move the implementation for the wrappers to
  utils/mimetypes(2)/mimeutils.cpp
- also move the MimeDatabase declaration in the "old" implementation
  back to utils/mimetypes/mimedatabase.h

Change-Id: Ie8de229c035d6cd9a5e4739dc0fa78d9c17228e3
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-02-25 07:19:58 +00:00