Commit Graph

143 Commits

Author SHA1 Message Date
Eike Ziller
ff83642681 ClangCodeModel: Use Utils::runAsync instead of QtConcurrent::run
That works the same with Qt 5 and Qt 6.

This reverts commit c1fcaa2877.

Change-Id: I603e50c793c2477454253a57bfe01eb25ecab6e3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-12 11:00:51 +00:00
Christian Kandeler
35963fd2b8 ClangCodeModel: Fix issue pane management for clangd diagnostics
We basically forgot to implement this. A task in the issues pane was
created for every text mark, but there was no code to deal with handling
editor switches, resulting in seemingly random behavior.

Fixes: QTCREATORBUG-27260
Change-Id: Ifcc1e04db4c37dde7e80f0e1646dc7c557cd7481
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-12 10:29:31 +00:00
Christian Kandeler
e0ab8ad258 ClangCodeModel: Fix check for whether clangd should be used
Change-Id: I789c12b1b4098e6f11f190cf1ada6de9429c6101
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-12 07:48:45 +00:00
Christian Kandeler
52959ce472 CppEditor: Acknowledge the existence of clangd
Stop pretending to be super generic. Instead, let interested code know
directly whether a document is under clangd's control.
This saves code and makes the logic easier to understand.

Change-Id: Ia19d0ec6c4e83926379a7d17ca53896bee3a50e1
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-11 07:41:44 +00:00
Christian Kandeler
c1fcaa2877 ClangCodeModel: Fix build with Qt 5.15
Artificially lower the number of function parameters in
generateCompilationDB(), to accommodate Qt5's QtConcurrent::run().

Change-Id: Ide88925deb443378b9308d924406ec6f6f90e8aa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-05-11 07:40:30 +00:00
Christian Kandeler
b5b9b7e32c ClangCodeModel: Use clangd's include path
... rather than the one from the LLVM that Qt Creator was compiled
against.

Task-number: QTCREATORBUG-27120
Change-Id: I4f211345ed547cd13f0b0774b99bc0f199a9cd44
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-10 13:16:09 +00:00
Christian Kandeler
7ef5001076 ClangCodeModel: Speed up compilation db generation
We needlessly re-evaluated the same compiler options again and again for
all files in a project part.
Now we only do the actual file-related work per file. Along the way, we
dissolved some unneeded classes and made CompilerOptionsBuilder non-
polymorphic.

Change-Id: I9710d641a57032936cc0812515974dbc91676c8c
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-06 09:05:59 +00:00
Christian Kandeler
818dc8b0cc Remove clangsupport dependency from plugins
Change-Id: Ifd4215a590d32cd04fab720d0d8d5e746e81c6e8
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-05-06 08:11:42 +00:00
Christian Kandeler
969b1f711f CppEditor: Remove RefactoringEngine
Another useless indirection.

Change-Id: Icfcc0704a1056d8002a674edbe74b946cb56ff27
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-04 10:05:31 +00:00
Christian Kandeler
356b43e9aa ClangCodeModel: Stop communicating with clangbackend
Change-Id: I9a5f4e7f0f94d33de9816cb643e6ec88cbf9ca15
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-05-02 10:36:58 +00:00
Christian Kandeler
6da7babc4a ClangCodeModel: Remove libclang-based completion and function hints
Change-Id: I742fb14b1aba3ba1f35a5c80bf553d2a735cac48
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-02 10:31:05 +00:00
Christian Kandeler
b52fac7148 ClangCodeModel: Remove libclang-based diagnostics and highlighting
Change-Id: Ib7c423884b76c27a6350ddea611919d3352fb80e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-02 07:51:51 +00:00
Christian Kandeler
e045af7e69 ClangCodeModel: Remove libclang-based outline support
Change-Id: Ic7a7b0cfe1d3eb822dbad610fc84f29676404505
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-04-28 11:34:46 +00:00
Christian Kandeler
52d9def5e9 ClangCodeModel: Remove libclang-based tooltip support
Change-Id: I63d934fc3d480e3c5198e7db1a595b3309e89533
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-04-28 11:26:04 +00:00
Christian Kandeler
f2c267f328 ClangCodeModel: Remove libclang fallback for "follow symbol"
... and "switch between declaration/definition".
It's either clangd or built-in code model now.
Use the opportunity to dissolve the pointless FollowSymbolInterface
class hierarchy, which introduced a confusing parallel inheritance
chain.

Change-Id: I792ad55656c5dd9f10c6b4db7c5c36cf7be45125
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-04-28 09:47:52 +00:00
Christian Kandeler
1f0ea9ef7f ClangCodeModel: Allow users to set a file size threshold for clangd
With huge source files it might not be so useful to continuously
recompile them while editing, which is basically what clangd does.
Let users opt out.

Change-Id: If3e95c1e286090606a84961d071179f8b40f9180
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-03-30 07:53:07 +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
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
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
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
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
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
0c53c2daef CppEditor: Do not overwrite extra selections from language client
The broken libclang-based implementation used to remove the correct
results we got from clangd.

Task-number: QTCREATORBUG-26339
Task-number: QTCREATORBUG-26596
Change-Id: I9b7c1214c376b616fe204986ed37c287e2307f81
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-23 16:44:37 +00:00
Christian Kandeler
95e8afabba ClangCodeModel: Handle UI header updates with clangd
We need to manually refresh the documents that include the generated
header, as clangd does not know about it.

Change-Id: I8c4303ac029bbb56c01aa99b7950dcc651701678
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-12 14:37:51 +00:00
Christian Kandeler
9a16eb5fe6 ClangCodeModel: Inform clangd about changes to non-open files
That is, project-wide changes done from Qt Creator, such as search/
replace or quickfixes.

Fixes: QTCREATORBUG-26523
Change-Id: Ide4e56a7a1300eb6f25cabf1cfd94624d66e7e4e
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-08 09:32:02 +00:00
Christian Kandeler
f08d0e3d3e ClangCodeModel: Prevent restarting the same clangd client more than once
Change-Id: Ifd81a26506e48817b97c8ed1e5fa16ebb31d8c69
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-01 14:20:02 +00:00
Christian Kandeler
b403258c87 ClangCodeModel: Try to correct unexpected ClangdClient count
Ideally, it should not happen that there is more than one client per
project, but if it does, try to fix the situation by choosing the "best"
one and shutting down the others.

Change-Id: If00924925afabf6bc7efe7f33da693db323a00d8
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-01 09:37:39 +00:00
Christian Kandeler
d7c7089ff3 ClangCodeModel: Restart clangd fallback client
... on fallback project part change.

Change-Id: Icfc355443b4d6bb3c94eae27c2d23bbd9f681211
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-21 09:23:38 +00:00
Christian Kandeler
19119b9533 ClangCodeModel: Use more suitable location for compile_commands.json
... for clangd.
Putting it in the build directory seems sensible in principle, but that
can be problematic for in-source builds. So introduce another level of
nesting to prevent conflicts.

Fixes: QTCREATORBUG-26431
Change-Id: Id66aa0852d206695f2fc2ec42292b1cecefe2b59
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-20 09:06:23 +00:00
Christian Kandeler
8c86b9bca1 CppEditor: Make sure fallback project part is up to date
... with regards to the session include paths.
Amends 0636238429.

Fixes: QTCREATORBUG-26323
Change-Id: I8e2cd5f5e87d9dc3d2df3f943e13599bc7139768
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-19 12:20:47 +00:00
Christian Kandeler
2fcd764d56 ClangCodeModel: Add clangd-based document locator filter
Change-Id: I2811be80e740cacf57eccd19e47560af746ad0c1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-04 15:40:49 +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
David Schulz
07cfae77ba Clangd: fix opening document with client for project
Using LanguageClientManager::openDocumentWithClient function to assign a
document to a specific server. This function also takes care of
deactivating the document for the old client and opens it if necessary
in the new client.

Fixes: QTCREATORBUG-26205
Change-Id: Idbff154a62d12c432a2cb10d547f78a537e63a3c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-17 12:00:32 +00:00
The Qt Project
934c0bc423 Merge "Merge remote-tracking branch 'origin/5.0'" 2021-09-07 10:06:01 +00:00
Christian Kandeler
d583dde17b ClangCodeModel: Force clangd restart on external changes
Neither we nor clangd can afford to watch all source files, which means
that after e.g. a branch switch we can easily end up in an inconsistent
state.
We alleviate this problem by restarting clangd if at least one open file
was changed externally.

Change-Id: I7e0d14835e3afbd7a64c3233614f2161282dddc0
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-07 10:05:28 +00:00
Eike Ziller
8e51295959 Merge remote-tracking branch 'origin/5.0'
Conflicts:
	src/libs/utils/processreaper.cpp
	src/plugins/clangcodemodel/clangmodelmanagersupport.cpp
	src/plugins/cmakeprojectmanager/cmakeprocess.cpp

Change-Id: Ie248bcb02a80f3e02ab19d73033ce2ba31e7fd83
2021-09-07 11:05:40 +02:00
David Schulz
dc40af5fa5 Clangd: fix opening document with client for project
Using LanguageClientManager::openDocumentWithClient function to assign a
document to a specific server. This function also takes care of
deactivating the document for the old client and opens it if necessary
in the new client.

Fixes: QTCREATORBUG-26205
Change-Id: I3c3a5fbcd3d07c2e492ebffdf7870e4d2cb517d4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-02 08:20:39 +00:00
Christian Kandeler
22823b2190 ClangCodeModel: Add debug output to soft assert
I saw this getting triggered recently, and would like to see more
information if it happens again.

Change-Id: I1c616b8126b8b5eea3709a97124968e9e706aaf3
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-02 07:06:30 +00:00
Christian Kandeler
284817fae6 Merge CppTools into CppEditor
There was no proper separation of responsibilities between these
plugins. In particular, CppTools had lots of editor-related
functionality, so it's not clear why it was separated out in the first
place.
In fact, for a lot of code, it seemed quite arbitrary where it was put
(just one example: switchHeaderSource() was in CppTools, wheras
switchDeclarationDefinition() was in CppEditor).
Merging the plugins will enable us to get rid of various convoluted
pseudo-abstractions that were only introduced to keep up the artificial
separation.

Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-01 14:53:58 +00:00
Christian Kandeler
a952500e90 CppTools: Use only const pointers for ProjectInfo and ProjectPart
All members were already const, but this makes it clear at all points of
use that these data structures are immutable.

Change-Id: Iea615c090bde462c445d15223caccc561b0c713d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-08-27 10:53:54 +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
hjk
09ae643153 ClangTools/CppTools: Code cosmetics
Mostly namespaces.

Change-Id: Ife8bbcb128344cf56d444da8f9d76b1204b9fe34
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-18 14:13:03 +00:00
hjk
f29bc8c787 ClangTools: Proliferate use of FilePath
Change-Id: I3eb16546a729ab01c10e37572adac9aef83f5cd4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-18 11:43:30 +00:00
Christian Kandeler
33108795d6 CppTools: Turn some classes into pure value types
ProjectInfo, ProjectPart and ProjectUpdateInfo used to carry pointers
to Project and/or Toolchain, even though they were used in contexts
where these pointers were either unsafe to access or not guaranteed to
be valid anymore, which made their use difficult and error-prone.
We turn these classes into pure value types by copying in all relevant
information before the first async operation takes place.

Fixes: QTCREATORBUG-25678
Change-Id: I1914b0dbda6c7dfba6c95e5e92f2d69977755590
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-08-13 12:35:49 +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
Christian Kandeler
c999b6066f ClangCodeModel: Start a fallback clangd for files without a project
These were still being served by the old code model even when clangd
support was enabled.

Change-Id: I5f01b6a7071b90c374750f93435299755cabe3e9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-29 11:33:45 +00:00
Christian Kandeler
1f4826a0c4 ClangCodeModel: Clear existing libclang diagnostics
... when clangd takes over a document.
This fixes the problem that temporary diagnostics persisted after opening
a session.

Change-Id: Ic781f83747cabb4d15c2c1f8181e36f4343e0394
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-09 07:29:55 +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
Christian Kandeler
f4a3310059 Clangd: Handle settings changes
Users no longer have to re-load a project for settings changes to take
effect.

Change-Id: I86dccccac14a30514c8dac292c7765ee4806f6ba
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-01 08:34:51 +00:00
Christian Kandeler
fbb804c442 Clangd: Add per-project settings
Users might want to use clangd for certain project, but not for others.

Change-Id: Id29ce3349f0acd359cf7c824ece073b147ed2280
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-30 15:09:56 +00:00