Commit Graph

1332 Commits

Author SHA1 Message Date
David Schulz
967b1d237b ClangCodeModel: remove ClangdTextMark safety net
Since all text mark created by the diagnostic manager get deleted
properly on destruction now, there is no need to react on the client
destruction in ClangdTextMark.

Task-number: QTCREATORBUG-26585
Change-Id: Ifb9b8546c8f0d94debdcf2c8de6081e4e731cfab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-02-25 05:34:30 +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
Eike Ziller
41538832c3 Merge remote-tracking branch 'origin/7.0'
Conflicts:
	src/libs/utils/qtcprocess.cpp
	src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp
	src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp

Change-Id: Id0c31719e46d1c44770ea89663eee321a0517ff4
2022-02-24 11:42:57 +01:00
Eike Ziller
fff5944e65 Fix lupdate issues
When updating translations with
cmake --build . --target ts_de
(or other language ID)

- Qualifying with unknown namespace/class ::PluginSpecPrivate
- <class> lacks Q_OBJECT macro

Change-Id: Ic42d8dffea935e6b10e59223bdedb9a8a4dcf446
Reviewed-by: hjk <hjk@qt.io>
2022-02-23 16:53:00 +00:00
Christian Kandeler
cf90264971 ClangCodeModel: Fix more false output arguments with clangd
For some reason, we never checked the actual matching AST node for
const-ness.

Change-Id: Icb58ba169d82e1ec02c9ff8d17f0170f0a78f99d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-23 10:54:32 +00:00
Christian Kandeler
7b82b55b73 ClangCodeModel: Don't highlight streaming operator args as outputs
... with clangd.
As with operator++ etc, it's immediately obvious to a developer which
arguments are modified.

Change-Id: Ia2b15d5eef7848b7ed284f8d544f039fe2927292
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-23 10:53:52 +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
Christian Kandeler
022510f1e6 ClangCodeModel: Mention project name in clangd indexing message
This will help avoid confusion in case of multi-project sessions.
We also shorten the message a bit so it won't be cut off in the progress
bar before the project name.

Change-Id: I0e5885f89a976b14f758f9be77e7669f199cd887
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-18 13:39:31 +00:00
David Schulz
4f69996190 ClangCodeModel: iterate over documents instead of editors
Makes sure to handle each document just once since we can have multiple
editors for the same document.

Change-Id: I0d26a9931086d9b6be0c9c93b01f4485716d75e3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-02-18 13:35:05 +00:00
Christian Kandeler
5866f78049 ClangCodeModel: Fix libclang tests
We must make sure clangd doesn't get in the way.

Change-Id: Ica053cce6928920b39602c7c467b5d16f8232fe6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-02-18 12:40:44 +00:00
Christian Kandeler
8ad7ab2d2a ClangCodeModel: Use project-specific clangd client, if possible
If we open a file that does not belong to a currently open project, there
is a good chance that the current project's parse context is a better fit
for the file than the fallback client's.

Fixes: QTCREATORBUG-26697
Change-Id: I6c17e275b047602c51364f3203b3f0a3e74a49fc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-18 11:37:34 +00:00
Christian Kandeler
a08e0f7a9d ClangCodeModel: Differentiate between clangd debug output log levels
Depending on the kind of highlighting issue we want to debug, we may or
may not be interested in the actual tokens.

Change-Id: I412126d3e97949a31f1dd5f339dc09072f28be64
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-18 08:55:54 +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 Kandeler
4cd18fb3a4 ClangCodeModel: Factor out clangd compilation db update
We want to re-use that code.

Change-Id: I9b9201b63ef4c375c24efa402c80769634287714
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-17 08:10:31 +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
Christian Kandeler
dad534005e ClangCodeModel: Do not set C_ENUMERATION for enum declarations
... when highlighting with clangd.
This value is only meant for enum values, not types.

Task-number: QTCREATORBUG-27059
Change-Id: I7bb68f5deb6bb215ee3c23d995207019850a7bfc
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-15 13:58:51 +00:00
Christian Kandeler
6414f22be7 ClangCodeModel: Fix highlighting of literals with clangd
Some literals are keywords.

Task-number: QTCREATORBUG-27059
Change-Id: I6315bfd4e4179990e55bc046084fdf0a4e3f9e8e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-15 13:58:36 +00:00
Christian Kandeler
a189a74dea ClangCodeModel: Fix erroneous highlighting with clangd
In certain cases, members being initialized were highlighted as output
parameters.

Task-number: QTCREATORBUG-27059
Change-Id: I0de8aee5e4db735251a314b14af04459e6ac772c
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-15 13:58:17 +00:00
Christian Kandeler
03340f1fdf ClangCodeModel: Fix flaky clangd test
Signals emitted for the fallback client got in the way.

Change-Id: I29a7fe5221a1f489eff91c772f9a6bb0fff7c4f1
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-15 10:39:03 +00:00
Christian Kandeler
e5f8fe311d ClangCodeModel: Remove fallback code for clangd < 13
Amends 4dfdbf91f6.

Change-Id: Ie8657329380e83aeb76503e360afa5ebf0e60fbb
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-14 09:29:34 +00:00
Eike Ziller
45b5341cd9 Merge remote-tracking branch 'origin/7.0'
Change-Id: Iab67dffe64bee391bd921ed8832bb17b36ec861b
2022-02-14 09:58:04 +01:00
Christian Kandeler
81218043d0 ClangCodeModel: Fix mis-highlighting of lambda calls
Calls to lambdas without arguments that are declared as const variables
were erroneously displayed as output arguments.

Change-Id: Ibd914431a34157606694f85d8e00c0dd1db1a618
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-14 08:43:18 +00:00
Eike Ziller
fcb8d3b2a4 Merge remote-tracking branch 'origin/7.0'
Conflicts:
	src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp

Change-Id: Icda34067bb89d066a3e7eb47f8cca1d62dc3ae0d
2022-02-11 11:20:13 +01:00
Christian Kandeler
7123a41c1e ClangCodeModel: Improve ifdef'ed out code handling with clangd
- Made code more self-documenting.
- Added more comments.
- Added debug output.
- Rewrote ugly redundant code checking for #ifdef & friends.
- For consistency, emit update about ifdef'ed code only
  if we also report the other highlighting results.

Change-Id: Idd3cbd3c169343bcaf6b6b19330130378ac6c5d0
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-11 10:11:25 +00:00
Christian Kandeler
ce27886eeb ClangCodeModel: Fix dot-to-arrow completion with extra characters
We failed to overwrite existing characters that match the completion if
clangd also changes "." to "->" at the same time.
Note that it still doesn't work as expected if the cursor is after the
dot and before the extra character. I'm not sure yet how to fix that.

Fixes: QTCREATORBUG-27034
Change-Id: I852145fc41f34ab60d9e944783e822bc9505453b
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-11 09:43:48 +00:00
Alessandro Portale
26bf18e1fe Core: Turn LocatorFilterEntry ofn ILocatorFilter::accept to const &
In ILocatorFilter::accept and all the overrides.

Change-Id: I27cd6babb66d91aad57e85572a1cdc77aef4fd79
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-02-11 07:35:30 +00:00
Christian Kandeler
6ede8b3bc0 ClangCodeModel: Support parse contexts with clangd
Fixes: QTCREATORBUG-27009
Change-Id: I177db0658d545211b940623cae071db91e82ddb4
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-10 12:58:30 +00:00
Christian Kandeler
14ee4654c1 ClangCodeModel: Fix detection of #ifdef'ed out blocks with clangd
We were erroneously merging adjacent disabled blocks.

Change-Id: I9f8f588c0362d488a24c044910474815b94efd59
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-02-10 10:59:23 +00:00
Christian Kandeler
64fee150ef ClangCodeModel: Consider whitespace in preprocessor directives
... when highlighting with clangd. That is, treat "# ifdef" the same as
"#ifdef".

Fixes: QTCREATORBUG-27021
Change-Id: Ic57ed42e09f95611dd85ca3c112e23b52a3f91fc
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-10 08:09:49 +00:00
Christian Stenger
bafea94402 Clangd: Fix possible crash in inspector
When fast switching between clients listed inside the inspector
the message response for memory usage may arrive after the model
has been destroyed.

Change-Id: I0503bb334cf21b0919316f0ac2e731472f3433bd
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-10 05:52:51 +00:00
Eike Ziller
68fd73713b Merge remote-tracking branch 'origin/7.0'
Change-Id: I967615c66a11bb4823a6b403ca59e63dd1971032
2022-02-07 16:34:41 +01:00
Christian Kandeler
9185875677 ClangCodeModel: Adapt tests to recent clangd regression
Change-Id: Ic48e1b9b85804f605edb5a2edab18f93dd7dec7d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-07 13:28:26 +00:00
Christian Kandeler
cfc7890416 ClangCodeModel: Create a clangd config file, if none exists yet
There are some clangd settings that can only be provided via a config file
(i.e. neither via the command line nor via LSP extensions).
In addition, clangd is very picky about that file's location; in
particular, we cannot put it at the "pseudo project root" where our
generated compilation database resides.
Therefore, we have to go with a user config file (as we don't want to
write into any project source directories). If there already is such a
file, we don't do anything, based on the assumption that the user is
familiar with clangd and has already configured it to their liking.
Otherwise, we create the file, including a special marker that tells us
it was generated by us and can safely be overwritten.
The set of options we set is currently quite small, but we expect it to
grow in the future.

Change-Id: I1605bf7b0edecc844f3e7cdd1d7dddda7af33956
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-04 14:23:46 +00:00
Christian Kandeler
0e7de92319 ClangCodeModel: Retrieve all kinds of clangd tweaks
Contrary to our expectation, the "quickfix" tweaks are not part of the
inline code actions after all.
User-observable effect: "Populate switch" becomes available.
Amends 8b63dfccc6.

Change-Id: I4f7fa25a58bb54dbdb470d7db064b4d804c34d26
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-04 14:23:24 +00:00
Christian Kandeler
0a9acad18c ClangCodeModel: Fix tooltip for clangd text mark copy action
Change-Id: Ie551971a114f1f45004a0eac0283507627c26be2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-04 13:50:26 +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
Christian Kandeler
abe09bfd76 ClangCodeModel: Adjust cursor for following destructor symbols
... with clangd. More specifically, for the case where we switch between
declaration and definition of a destructor. Since clangd expects the
cursor before the "~" character, we move it there.

Fixes: QTCREATORBUG-26809
Change-Id: I8ea6a060bea3545c963cb8ebbe2d3ae3a18da2d5
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-01-28 12:34:48 +00:00
Christian Kandeler
cfae24a6e5 ClangCodeModel: Enable clangd's new "dirty headers" flag, if possible
This feature will be availabe with LLVM 14,
see https://reviews.llvm.org/D95046.

Task-number: QTCREATORBUG-26810
Change-Id: I0a6797a836c56f5b72cca34be8f2d3edf8ac7359
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-01-24 12:46:29 +00:00
hjk
25f5771aa4 Rename QtSupport::BaseQtVersion to QtVersion
... and the Utils::QtVersion enum to Utils::QtMajorVersion to avoid
conflicts.

Change-Id: Ib688c67388272b7204a91444155f60b8c18a56bd
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-01-24 12:13:19 +00:00
Eike Ziller
9d8a419d10 Remove qmake build files
Removes qmake as a build system for building Qt Creator itself.
Keep them for some tests that are not completely moved to CMake yet.

Change-Id: I846c6ef65626b6dfae6375fdc85d00677aa8c2fb
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-01-20 12:18:15 +00:00
Marco Bubke
7457d3d8b6 ClangSupport: Break artificial dependency to Sqlite
Since the Sqlite library is not used anymore in clang there was only an
dependency to the Utf8String in ClangSupport. As we move Utf8String and
Utf8StringVector to ClangSupport we can break the dependency to Sqlite.

Change-Id: I0012906345bc49a48a7262c1d6e204fb8aff01e1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-01-20 11:33:21 +00:00
David Schulz
dc4b9e48dc Clangd: clean up text marks after deleting client
This is a blindshot and more a workaround than a fix.
Assert and try to cleanup dangling text marks after a client got
deleted. In theory those marks should get deleted by the
DiagnosticManager but somehow, they are still alive and happy after the
client was deleted.

Task-number: QTCREATORBUG-26585
Change-Id: I9d5d708db3fbbe30a09d322400d97184fe40a518
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-01-14 13:19:35 +00:00
Eike Ziller
7d92375b2f Merge remote-tracking branch 'origin/6.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/clangcodemodel/clangdclient.cpp

Change-Id: I75c954d2e573d65089205d2542747bba3276be2a
2022-01-03 14:14:12 +01:00
Christian Kandeler
3cf51b0cc7 ClangCodeModel: Fix build with MSVC 2022
Change-Id: Ifd0e1e67057e57e4c978784e9634f987edb9dfe4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-12-17 19:03:28 +00:00
Eike Ziller
85b60d9608 Merge remote-tracking branch 'origin/6.0'
Conflicts:
	src/plugins/coreplugin/editormanager/editormanager.cpp

Change-Id: I80fe565749ad5c06dfe99436f2dc6ab4b66a2537
2021-12-16 10:50:33 +01:00
Christian Kandeler
f72ea01c65 ClangCodeModel: Properly display clangd auxiliary diagnostic messages
... in text marks.
The main message can be followed by additional messages, separated by
pairs of newlines. Properly parse their contents and also display them
as clickable links, if applicable.

Change-Id: I341ce0a6bf0e628dfabdb3806fb8ef1b8ca019c6
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-12-15 16:40:57 +00:00
Cristian Adam
42d0280360 CMake: Only set COMPILE_OPTIONS if target ClangCodeModel exists
If Qt Creator is configured without Clang the target ClangCodeModel
might not exist and CMake configuration would fail.

Amends 08cbf13199

Change-Id: I1644d183bdcb4d9a6ae65e1257d9be7b7a0e5ff5
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2021-12-14 11:41:18 +00:00
Cristian Adam
08cbf13199 CMake: Fix compilation with Qt 5.15.x and MSVC
The code was replacing the existing COMPILE_OPTIONS property and
therefore fail to build when PCH was enabled.

Amends 9d6b8727ee

Change-Id: I5c530517d1acc899ac375119ce0741a05ee52cea
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2021-12-13 14:45:19 +00:00
Christian Kandeler
bbd4352188 ClangCodeModel: Fix flaky clangd completion test
Change-Id: I38e283146d43a9ce6e9cb07dfc5b0e9ea7eb2a76
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-12-13 09:34:12 +00:00