Commit Graph

1332 Commits

Author SHA1 Message Date
David Schulz
9c13db448b CppEditor: remove unused function hint provider
Since we removed the libclang based backend both implementations of
ModelManagerSupport::functionHintAssistProvider returned a nullptr.

Change-Id: I113c5a08cf604eb1bb2a64a851f022ecd5c908d6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-13 12:11:24 +00:00
Christian Kandeler
9ee60ecd87 ClangCodeModel: Derive displayed search term from adjusted cursor
Otherwise, we can have discrepancies between displayed and actual search
term.

Change-Id: Iadd2ec54db4cef4b103c3c0ef98eb47828ea544b
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-06-10 08:57:04 +00:00
Christian Kandeler
428a2c3c14 ClangCodeModel: Another cursor adjustment
Change-Id: Ie4859a52b12b3e87a65bd8c04e0123e6f34a9e73
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-06-10 08:56:44 +00:00
Christian Kandeler
49bb40f19e ClangCodeModel: Move "follow symbol" into its own class
Change-Id: Ic64c7275debaa59c524f349fd38460f47f826ecd
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-06-08 09:48:17 +00:00
Christian Kandeler
a167bd9ad2 Do not pass Utils::LinkHandler by rvalue ref
There is nothing special about this type that justifies it sticking out
everywhere it appears.

Change-Id: Iccdc95163d477db8a031d0d520f28fea26432a44
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-06-07 09:22:30 +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
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
Jarek Kobus
8cd9a2dd12 ModelManagerSupport: Get rid of UsagesCallback from findUsages()
It's not used currently.

Change-Id: Ic3625b0f3c53c09089a361453f29ac639692cffb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-06-02 08:52:55 +00:00
Jarek Kobus
b9f0663741 ModelManagerSupport: Get rid of UsagesCallback from globalRename()
It's not used currently.

Change-Id: Id859251f69abf33de3431d1e8b561aedefbb4651
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-02 08:41:33 +00:00
Christian Kandeler
b1e73ca45d ClangCodeModel: Try harder to catch bogus AST ranges
String literals that are adjacent after preprocessing are reported as a
single AST node, leading to potentially wrong highlighting.
We can catch this condition at least for the case where there are
semantic tokens in between the string components.

Fixes: QTCREATORBUG-27601
Change-Id: If023d06db74bd6cfefa670649f0e733ceaaede2d
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-31 11:38:41 +00:00
Christian Kandeler
51b6aa7649 ClangCodeModel: Move highlighting code into its own set of files
No functional changes.

Change-Id: If6e5da7e79bf39e564f0f38520ae088f76543642
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>
2022-05-31 11:15:13 +00:00
Christian Kandeler
c6c919e671 ClangCodeModel: Properly parse function types for outline
Fixes: QTCREATORBUG-27587
Change-Id: Icf663e386fa90c209aa998d2d7ab7ae0fcb40792
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-30 08:38:20 +00:00
Ihor Ivlev
6f7e7980d2 Display parent functions in the Find Usages menu
To display the parent function, first we find it in displayResults and
store the information to SearchResultItem, then
SearchResultTreeItemDelegate gets the information and renders it.

Similar approach is applied to ClangdClient, in addSearchResultsForFile.

This change also adds default style for containing function highlight in
the search.
Default foreground and background colors are same as usual text colors.

Task-number: QTCREATORBUG-27550
Change-Id: Id1251afa192f8d1232524742b7c211770bcb83fb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-25 15:05:25 +00:00
Christian Kandeler
5ae128f634 ClangCodeModel: Fix test crash
Amends 509600da99.

Change-Id: Ia07a65e509414b41f279f50c02893d1733fd1022
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-25 09:06:16 +00:00
Jarek Kobus
2853660a59 Utils: More forward declarations / drop unused headers [D-G]
Round 1 - focus on headers.
For classes with initial in range [D-G].
Try to keep the same separators between different kind of headers.

Change-Id: Id42cd7b3743a816f75cecb6b576c0e37cb057473
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-05-25 07:13:52 +00:00
Artem Sokolovskii
7954c4cc69 ProjectExplorer: Add a common template for project settings
- Added base widget class for common options among project settings tabs
- Added usage new template class to all pages used in project settings

ToDo
- Make CodeStyle tab standardized

Change-Id: I8f70413b6ee764c5e43fbeae104b9389237c582f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-24 10:02:45 +00:00
Artem Sokolovskii
6b8277fcd2 ClangTools: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464
Change-Id: I1c4711d87e5f95fc1653dd9aa6448b105d017435
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-24 08:02:52 +00:00
Christian Kandeler
760cf632af Move clang diagnostics config settings to clangd settings page
It was confusing to have both "Clang Code Model" and "clangd" project
settings pages, so we merge them.
Along the way, a lot of code dropped off.

Change-Id: I780850b716195c3729403ae59f0794c11b5c556d
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 12:15:40 +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
Christian Kandeler
10dd3706fa ClangCodeModel: Use dedicated TU for code related to the clangd AST
The clangdclient.cpp file is rather large, and the AST stuff is a nicely
self-contained chunk of code to move out.
No functional changes.

Change-Id: I0240413f561f5c67ca5ee310b5c4253ffa62fdae
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-19 11:25:59 +00:00
Christian Kandeler
70ec0cfff1 ClangCodeModel: Make use of clangd's "switchSourceHeader" extension
This allows us to switch between headers and sources with different base
names and/or locations, using symbol matching heuristics.

Task-number: QTCREATORBUG-16385
Change-Id: I2d9c07f412d70b75322ed65d491982d78674483d
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-19 09:54:34 +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
Christian Kandeler
affa2cda9e CppEditor: Tell users about clangd configuration files
It's not feasible to map every possible setting into our UI, so instead
teach people how to use the clangd configuration mechanism.

Change-Id: Id11e81e25b687a4f49af4e090203faca3a75722d
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-17 08:56:32 +00:00
Christian Kandeler
a5dc6f8434 ClangCodeModel: Switch on clangd's Include Cleaner
Task-number: QTCREATORBUG-147
Task-number: QTCREATORBUG-14040
Change-Id: Ib215ed3bbb6f42d25752c747693371239222e67a
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-17 08:51:26 +00:00
David Schulz
52770b746e LSP: fix hover request result
According to the protocol a hover request can also return a Null as a
result. Reflect this in the protocol implementation and adapt usages.

Change-Id: I14ce71639c64b6de00e9c1198617083c1a3de9eb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-16 12:36:44 +00:00
Christian Kandeler
1e25be0cfd ClangCodeModel: Suppress broken clang fix-it (again)
This time with clangd.

Fixes: QTCREATORBUG-18593
Change-Id: I26cedec0dcdf07c46ae96a5d714df128dfcd2d26
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-16 07:50:30 +00:00
David Schulz
b2e2421d2d ClangCodeModel: remove duplicates from clangd quickfix assist
Do not report quickfixes with a diagnostic since those are already
collected by the ClangdQuickFixFactory as builtin quickfixes.

Change-Id: I8d29a08b823291f8beaa762c09b7d29a4b9d0384
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-13 14:19:13 +00:00
David Schulz
4f29bd5613 ClangCodeModel: Fix positioning lightbulbs for diagnostics
Set the diagnostic to the containing code action when generating
refactor markers. This makes sure the light bulb is displayed at the
diagnostic and not the edit location.

Change-Id: I46ac7a19879d2358eb49f5cb1b695ee10a0c682d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-13 12:40:05 +00:00
David Schulz
59a77a4965 TextEditor: add text cursor to assist interface
This will allow us to request assistance for a specific selection
instead of just the position.

Change-Id: Ib8e5b32d4a8f2936e5a6f1b7ac968d7f1d8d9de6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-13 09:18:53 +00:00
David Schulz
fa577eb049 ClangCodeModel: pass ClangdClient to text mark constructor
Change-Id: Ie7b9c23365648fcf6034175e0e18970d342e25e6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-13 05:06:46 +00:00
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
48abae97b6 ClangCodeModel: Fix handling of code actions in diagnostic tooltip
We need to create a sub-diagnostic for every clangd code action.

Task-number: QTCREATORBUG-27514
Change-Id: I9a12bcb390c9cc157ba7bca5015bbf51d31263da
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:49:48 +00:00
Christian Kandeler
031fe30260 ClangCodeModel: Update build system files
There is no compile-time dependency to libclang anymore.

Change-Id: I3b07977ba037a9c39c54d95c39f0505ae934cb02
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-12 07:49:10 +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
f03868bd6b ClangCodeModel: Another clangd cursor adjustment
QVector<QString|> should go to QString, not QVector.

Fixes: QTCREATORBUG-27524
Change-Id: Iceab3d9a796bbe974a13cea3fa91de9b4aaaee7a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-12 07:39:54 +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
ad8db12de9 CppEditor: Make CompilerOptionsBuilder take the actual clang include dir
This is more clear than passing in version and fallback path and
calculating the real path from them somewhere down the line.
No functional changes for now.

Change-Id: Iae2fc8015c778d787ed6e0ce898f41a7a05b2607
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-10 10:41:50 +00:00
Christian Kandeler
026126eed0 ClangCodeModel: Remove some unused functions
Change-Id: Ibaab69aaab66998d1975663d1a1824d89aaa23a6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-09 13:04:36 +00:00
Christian Kandeler
e79c432291 Remove clangsupport library
Change-Id: I18455fc451b6e1b73c7183f6c75820379e26951a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-09 08:22:45 +00:00
Christian Kandeler
56b5e1f4de ClangCodeModel: Remove ClangFixItOperationsExtractor
Not used anymore.

Change-Id: Ice3dd4c58df73f4075d0c79c011554286b5d9dd7
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-06 12:35:06 +00:00
Christian Kandeler
3d1ba205d0 ClangCodeModel: Minimize QStringList -> QJsonArray conversions
... when setting up the compilation database.
As it turns out, these conversions were the most expensive part of
creating the JSON file. We now build the JSON arrays incrementally
instead of setting them up from scratch for every source file.

Change-Id: I1e664a6320d5b3c49b31366c58aa14f63818e008
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>
2022-05-06 11:03:13 +00:00
Christian Kandeler
3ce7ca7242 ClangCodeModel: Move another call out of a tight loop
... when creating a compilation db.

Change-Id: I4d392587f13214042b449a450ef1d4ae1c283ecb
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>
2022-05-06 11:02:45 +00:00
Christian Kandeler
0a9d1df61d ClangCodeModel: Do not re-classify source files for compilation db
This information is already present in the project part.

Change-Id: I797b6f573e7fb434b323efa4219dab54103aecaa
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-06 11:02:25 +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
780f89b377 ClangCodeModel: Bump minimum clangd version
We need clangd >= 14 to get rid of the cumbersome compile_commands.json
creation.

Change-Id: I30c19a385e2d76e478985f3df64968d1cb3efe87
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-04 12:55:03 +00:00