Commit Graph

57 Commits

Author SHA1 Message Date
Christian Stenger
50b9e601b0 LanguageClient: Fix coverity warnings
Coverity-Id: 1569380
Change-Id: I925ef9f154f1d4c39d7631a7a94f37be4735aa8c
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-11-21 08:46:16 +00:00
David Schulz
b960fb4481 Editor: centrally emit filesChangedInternally after refactorings
...instead of relying on the surrounding code of the refactoring to emit the signal.
This also ensures that the signal is only emitted for files that are not opened inside
a TextEditor.

Change-Id: I6223362864014c691962d895b864f9f44c36e035
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-11-16 12:05:13 +00:00
David Schulz
cb8d79bb2f LanguageClient: check correct provider for various goto targets
Change-Id: Ie0acf800fad46cc11f7bb5b5134fc5b70beeaddd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-10-26 13:36:32 +00:00
Christian Kandeler
2ad3520e5a CppEditor/LanguageClient: Do not rename in generated files by default
Fixes: QTCREATORBUG-29778
Change-Id: I4e56b6bda4e22c71995ab19ac6469ea88d22ee11
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-10-25 11:49:01 +00:00
David Schulz
6adaa850e8 LSP: rename Create/Rename/DeleteFile classes
Since they clash with default windows functions and cause issues with
PCH build.

Change-Id: Ice0339c7dad14b40e172c885ffb71d923469614a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-09 12:30:08 +00:00
David Schulz
ac5ab71db8 LSP: add resource operations to the protocol implementation
This allows the language server to request file creation, renaming, or
deletion.

Fixes: QTCREATORBUG-29542
Change-Id: I31ab3c0b36f87d3b797b54ff4261cab85a322e2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-10-09 09:33:54 +00:00
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
David Schulz
e6b8791fa9 LanguageClient: correctly cancel running rename request
When requesting rename results while we have not received the response
to the previous rename request, we have to cancel that previous request
otherwise we end up with duplicated replace operations that potentially
can invalidate the document.

Task-number: QTCREATORBUG-29389
Change-Id: I3be425b8306c18b64fca7bb71bf65c32ae50fed1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-08-22 08:48:46 +00:00
Christian Stenger
b17c83b548 LanguageClient: Silence soft assert
The reported path may be OS specific and can contain
backslashes on Windows.

Change-Id: I93d990c7fec84ae335d57a0671c12dcac3d2f939
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-08-21 13:06:38 +00:00
Eike Ziller
33449bc880 Add full stops to various error messages
Change-Id: Ic4e07c5063a2e42af643faa4a5acb8445b12d6a1
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-06-14 06:09:54 +00:00
David Schulz
3f2832289d Utils: move TextPosition/Range to textutils
Change-Id: Id94a7a96f3b0f978e94850d67eb4b8fba6c18fe2
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-05-10 09:32:39 +00:00
Jarek Kobus
c879aeb565 SearchResultItem: Introduce SearchResultItems
And reuse it.

Change-Id: Ia052297340f2bf2478fbfdb2427b45e30bd9d067
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-08 06:41:41 +00:00
Jarek Kobus
8b3aa900da Utils: Move SearchResultItem/Color into Utils
It's going to be reused inside FileSearch.

Change-Id: I8993d7158ff31c311c2283d32bc43465a8946a52
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>
2023-05-08 06:41:27 +00:00
Eike Ziller
2bc37de42b Merge remote-tracking branch 'origin/10.0'
Conflicts:
	src/plugins/python/pipsupport.cpp
	src/plugins/qtsupport/exampleslistmodel.cpp
	src/plugins/qtsupport/examplesparser.cpp
	tests/auto/examples/tst_examples.cpp

Change-Id: I00273622423fa99d41621969f6ecbbdaa0e18664
2023-04-13 15:59:08 +02:00
David Schulz
4d688c932b Clangd: do not modify the default replacement string
Fixes: QTCREATORBUG-28321
Fixes: QTCREATORBUG-28910
Change-Id: I4cfaf5ea3916a0ecbf0b0bae4d0c231513671c73
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-04-04 08:55:15 +00:00
hjk
3e7d93c788 ProjectExplorer: Move some not-fully-session related bits
... out of SessionManager.

The idea is to later move SessionManager into the Core plugin,
which both is sensible conceptually and also prerequisite to
merge the Bookmark plugin into TextEditor plugin.

Currently, only the interface is split, as the load/save
implemetations are non-mechanical to disentangle.

Change-Id: I31631db3094ea192825a2ccaa6add6188662940b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-03-01 09:26:50 +00:00
Christian Kandeler
0d909c353c Designer: Update C++ code model on an object name change in designer
We try to locate the old symbol name in the generated ui header and
rename the symbol in the background.

Task-number: QTCREATORBUG-1179
Change-Id: Iaf68e3922cd728cbc87d0dc97125e34b8bdaa6be
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-01-27 10:02:52 +00:00
hjk
77054c2fa3 LanguageClient: Tr::tr
Change-Id: Idbd7c5cdadba4f269b2033df91db0e05bb5281d5
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-01-20 07:56:04 +00:00
Christian Kandeler
7b5c5b774f LanguageClient: Fix renaming with pre-set replacement symbol
If a caller passes in a fixed new symbol name, it must not be overwritten
with one derived from the old symbol name.
The problem can be verified with the "convert to camel case" quickfix.

Change-Id: I3d3aca692cb8e73535e1ef657608fd13d18ee5df
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>
2023-01-19 09:04:51 +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
5eeef19743 LanguageClient: resend rename request automatically on changes
Instead of asking the user to trigger the search again button before
being able to trigger the replace operation.

Change-Id: Ie2f0674255249b27d9435fc9df344e3f21bb886a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-12-16 09:12:01 +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
6d8f6ab395 LanguageClient: robustify renaming symbols
Guard against using a symbol support from a deleted client. Additionally
cancel active replace operations and provide a sensible error message.

Change-Id: I92ca0038fa5f6acbb8369a48c4e8051adfadb30e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-12-08 14:27:29 +00:00
David Schulz
fd17724597 LanguageClient: use reported rename placeholder
Using the reported range to create a usable placeholder if the
cursor ('|') is placed on the end of an identifier like in:

int global|;

Change-Id: I2ebacf3b9b54cff8f8887526479792374f67c881
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-21 11:47:52 +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
Christian Kandeler
55a5216e25 LanguageClient: Inform document manager about renames
So that interested partied can react accordingly.

Change-Id: I0233413aa960b83965428671cebeb591d5ca12b9
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-06 10:00:47 +00:00
Christian Kandeler
c46e5cef2d LanguageClient: Offer to rename matching files along with symbols
Like we already do in CppEditor and ClangCodeModel.

Change-Id: I9cd292950e40c499d99cc561fbf0ad99af477803
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-05 12:59:55 +00:00
Christian Kandeler
718086dea8 LanguageClient: Allow to pre-set the new symbol name
... when renaming.
There are contexts which provide the new name in advance.

Change-Id: I4bda689405060c343c0654d0aca274f10ee22752
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-10-05 09:03:11 +00:00
Christian Kandeler
eccbfc9459 LanguageClient: Allow to not pre-select non-project files for renaming
In alignment with what we already do in CppEditor/ClangCodeModel.

Change-Id: Ic68eca1879ed06887d3c5e39a09982bdd8c61065
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-04 13:11:43 +00:00
David Schulz
4f9a5ea896 LanguageClient: Inform user of failed prepareRename request
Also instantiate the search result window if we get an error and use it
to display errors.

Change-Id: I49dcdcc5ad2ace64391f8d2d849995b046032957
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-09-30 11:59:52 +00:00
Christian Kandeler
5c0cafa68e Core: Allow to pass a reason for a failed search
... and make use of it in the LanguageClient.

Change-Id: I7e47a7419c7168c5e26709ae225e4887d4c5089b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-09-28 15:42:40 +00:00
David Schulz
1ee370df50 LanguageClient: check capabilities before find usage
Change-Id: I421c2f93c90e6b0b8198fcff5707e8a47e8022f2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-23 10:51:11 +00:00
Christian Kandeler
712311b20c LanguageClient: Optionally use a different default replacement string
... when renaming symbols.
Otherwise, the server might return an empty list of results, as renaming
a symbol to itself is a no-op.

Change-Id: I9ca808c4032458c9a2eec262feadd28212938c23
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-23 08:39:57 +00:00
Christian Kandeler
c2937f609e LanguageClient: Do not cancel search on empty result list
... for a rename request.
Instead, simply finish the search normally, leading to a "no matches
found" message rather than the misleading "search canceled".
But do cancel the search on an actual error.

Change-Id: I10401466bb4d81d53d26b8dc08bfed91db86cd5a
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-21 07:19:04 +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
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
Christian Kandeler
5693c518bc Utils: Rename ProcessLinkCallback to something less clumsy
Change-Id: Icce4995f4aa886524dc3eedb7cf9ba72adbe8783
Reviewed-by: hjk <hjk@qt.io>
2022-06-03 13:23:28 +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
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
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
David Schulz
4452f71201 LanguageClient: avoid optional::value
Potentially throws std::bad_optional_access. Use operator* and
operator-> instead.

Change-Id: Idefa137da53f3663ea88961f1105b93402ec4777
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-02-24 12:04:38 +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
d52e7b9398 LanguageClient: Make sure to run callback in all code paths
... when receiving a reply for textDocument/definition.

Change-Id: I08f3a22f7c39a33b7b84539125a76d0c0d625692
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-01 11:40:38 +00:00
David Schulz
356bfcc9fd Utils: filepathify Link
Change-Id: Ie62500bde139158e776f9698ee0ea00c2a113f93
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-25 17:32:18 +00:00
David Schulz
8b7a90ac51 Utils: filepathify TextFileFormat
Change-Id: I6a4e2d38b0bbdec661a4a492901d9182a9f2e502
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-18 12:35:49 +00:00
David Schulz
f8ca730121 LanguageClient: Use Utils::FilePath to get file content
Change-Id: Iddb2eb5c02f3e6674f1f71bb61fb1f13dec22794
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-18 12:35:43 +00:00
Christian Kandeler
4890902abf LanguageClient: Allow for custom symbol search result handling
Change-Id: If19ce24b39820afbfd48c48493e07709f4b3633e
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-03 11:07:08 +00:00