Commit Graph

1332 Commits

Author SHA1 Message Date
Christian Kandeler
34a1971ede Clangd: Allow more fine-grained logging
Change-Id: Ia882575a3b6babd0945ef60be08b152428d3f39d
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-16 08:18:30 +00:00
Christian Kandeler
3c1e787215 ClangCodeModel: Limit result count in clangd-based locator searches
clangd memory usage explodes when the workspace/symbol result count hits
the six-digit mark, so prevent that.

Change-Id: Iefc2eeb3da7fe541e2b1d3105818126980fc3323
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-13 06:55:23 +00:00
Christian Kandeler
d603654aca ClangdClient: Do not close temporarily opened files
... if they have been properly opened in the meantime.
This fixes the problem that when a file was opened indirectly via "Go to
definition", the didClose message for the file that we temporarily opened
to search for overrides sometimes came in after the "regular" opening of
the file. As a result, such files were not actually in clangd's open
documents set, and no functionality was available for them (e.g. F2 on a
symbol would do nothing).
Also remove a left-over related declaration.

Change-Id: I9fc85d95595cb38a8d92e3f46505b9c514537d21
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-12 12:49:30 +00:00
Christian Kandeler
792699be06 ClangdClient: Do not send document update requests
... when requesting extra data from clangd.

Change-Id: I3552a2b7e09a1947de6570352936fd45e95f37a2
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-09 11:24:57 +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
68846a7729 ClangCodeModel: Provide highlighting via clangd
Note that we lose the highlighting for virtual function calls. We need
to amend clangd to add the respective information to its semantic tokens
message.
Also, Qt properties are no longer highlighted as class members. We'll
investigate how to best restore this feature.

Change-Id: I403712aada3d7a8e1c7b7c1277f43f7f64f8450b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-05 07:39:06 +00:00
Christian Kandeler
4d27740baf ClangCodeModel: Prefer ui headers from ExtraCompilers
... to the ones from the actual build. The former are generally more up-
to-date.

Fixes: QTCREATORBUG-25937
Change-Id: I20859de9816457c340d9e1ec6a3008c536537d8b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-07-02 08:20:51 +00:00
Christian Kandeler
58f0f3928c Clangd: Fix tooltip test
- We require the "full AST" feature from clangd 13.
- QSKIP does not work like QEXPECT_FAIL.

Change-Id: Ie1c417013d668ace600fad76e83276ca961b8327
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-02 07:08:57 +00:00
hjk
a58dd22f2d Utils: Use FilePath in TemporaryDirectory API
This helps to lower impedance in the using code.

Even though TemporaryDirectory will very likely always stay on the local
host, this is one of the entry points into path related string
manipulation
that we want to base on FilePath nowadays.

Change-Id: I302016b8d65e54df94296659a54a93935d9e4627
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-02 05:05:12 +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
David Schulz
813c4b807a Clangd: add quick fix factory
Change-Id: Idea71364b0e3f528e9dd366d46a2797f5056dfed
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-06-30 12:29:58 +00:00
Christian Kandeler
f9083cc6ad ClangCodeModel: Keep a QPointer to the ClangdClient in ClangdTextMark
Apparently, the pointer might already be invalid when
addToolTipContent() is called.

Change-Id: I649bdca0945247b2b8ce4f709721c4d0bf96a11b
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-30 12:29:44 +00:00
Christian Kandeler
673d596c84 ClangCodeModel: Provide tooltips via clangd
Note that we temporarily lose the ability to hover over an include and
get the full path of the header file. This is a valuable feature that we
need to restore, preferably by fixing clangd itself.
Fixing the remaining few test failures would likely require more
complicated code as well as additional LSP round-trips, and as of now
I'm not convinced it is worth the effort.

Change-Id: I08c72c4bd1268bbd67baeb57bbfd29d9b11303a5
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-30 08:49:24 +00:00
Christian Kandeler
4e777fcf90 Clangd: Make "Follow Symbol" more robust
The AST is only needed for virtual function disambiguation, while the
basic functionality works fine without it. So in case clangd fails to
retrieve the AST node for some reason, just use the original "go to
definition" result.
This also makes "Follow Symbol" work with clangd < 12.

Change-Id: I2c110e9a51b01dc912fcdf6f4ed45fce766df374
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-29 12:50:33 +00:00
Christian Kandeler
117fa35e00 Clangd: Ensure open document for "Send Goto Implementation" requests
Fixes: QTCREATORBUG-25861
Change-Id: Ied14b3ad129b205b05653a40c249a0a339ab686a
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-29 08:37:06 +00:00
Christian Kandeler
7bf52b0c0d ClangCodeModel: Provide diagnostics via clangd
Change-Id: Ib45a62ebe200c2b56a1bb1a66f8a92103e60d092
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 13:22:36 +00:00
Christian Kandeler
782779f8f4 ClangCodeModel: Remove outdated code
Diagnostics from clang-tidy and clazy do not take this route anymore.

Change-Id: Ifca2d9861d69dda94638277ec1210d28a3350b12
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 12:56:58 +00:00
Christian Kandeler
56cddf38b3 Clangd: Let users limit the worker thread count
This is particularly interesting for indexing, where users might prefer
a slower-building index with less CPU load.

Change-Id: Id44c58e9041df2857cd0772e71345673b14623f3
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 10:35:33 +00:00
Christian Kandeler
876cd8e975 Clangd: Allow to switch off background indexing
It is conceivable that users don't want to spend the extra CPU time on
this.

Change-Id: Ic3611c8d17d201ae986fad08b344369a8728ce1b
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 10:35:06 +00:00
Christian Kandeler
ba138a1855 CppTools: Add dedicated settings and settings page for clangd
We plan to add more clangd settings, and it makes sense to have a
dedicated place for them both in the code and the UI.

Change-Id: Ideb92935b7a5a6a98e07980f4011736fb82042d1
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 10:34:24 +00:00
David Schulz
b6367b6359 Core: use FilePaths to notify files changed internally
Change-Id: I2fce65ad340f18292fc0286233e78aaf769a130d
Reviewed-by: hjk <hjk@qt.io>
2021-06-23 12:03:10 +00:00
Christian Kandeler
d6d2d18373 ClangdClient: Consolidate the job counter variables
We need only one of these.

Change-Id: Icb50890981fa1465e091abb42a52afc1b810fbf0
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-22 08:12:22 +00:00
Eike Ziller
d42953160b Fix build in clangd tests
Amends 40181057cd

Complained that the Q_DECLARE_METATYPE comes too late.

Change-Id: Id5dd355fadcb4a6790d4c74dd1c637e0b1569aa4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-06-22 07:02:53 +00:00
Christian Kandeler
40181057cd ClangCodeModel: Use clangd for local renaming
Change-Id: I1536265a8d46c9840e722bdfcb8638906d3f45cf
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-21 13:00:40 +00:00
Christian Kandeler
dc4a8b3866 TextEditor: Allow incremental proposals
... and make use of them with clangd.
This way, users can get immediate feedback when a new proposal entry
has been found, rather than having to wait until all of them have been
collected.

Change-Id: I2adfe0153aa7a058f28eb3bd65c71dd30ea018e0
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-18 11:43:08 +00:00
Christian Kandeler
41dafc8132 ClangCodeModel: Implement declaration/definition switch via clangd
Change-Id: I522a415d76fbc5332e5cc1fdfd2d7ab19cb9ed64
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-18 11:11:17 +00:00
Kai Köhne
bf04c98c1c Do not pass QStringView by const reference
That's what the documentation says:

  https://doc.qt.io/qt-6/qstringview.html#details

Change-Id: I0b41fc4abad1601c0ed416a505534cf7ae7633e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-17 09:54:42 +00:00
Christian Kandeler
072958c3b0 ClangCodeModel: Do not include base declaration in virtual overrides
... if the cursor was on it.

Change-Id: Ie0d6981e9f0d23a57c430f3aa33448e8f9002ee9
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-17 06:13:37 +00:00
Christian Kandeler
3e5621428b ClangdClient: Handle C files
We somehow forgot to add the corresponding mime type to the language
filter.

Change-Id: Idefe2ed1dfe689340dabcf98363b3d160168000b
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-17 06:13:15 +00:00
Christian Kandeler
692995ec88 ClangCodeModel: Tighten the check for qualified member function call
Just checking for the base cast is not enough.

Change-Id: I455533b7da31cf5c52d8c1b9dd93b3bb2fb58929
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-16 15:30:29 +00:00
Eike Ziller
baa83725f6 Remove ClangRefactoring and ClangPchManager
This removes the plugins and tools, and removes all the tests that would
fail to build because of that.

Fixes: QTCREATORBUG-25659
Change-Id: I8adb5d503fc8eea313bcaada421f309dbbfa8c26
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2021-06-15 10:07:57 +00:00
Christian Kandeler
c218d8a543 ClangCodeModel: Prevent locator helpers from appearing in settings
Change-Id: Ic64beba528dad8db1a63ee0a370e5be0a8234ed5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-14 15:04:27 +00:00
Christian Kandeler
9426ce99a1 ClangCodeModel: Fix providing virtual override list
... when the cursor is right before the opening parenthesis of a member
function call. The clang AST is different then.

Change-Id: Ibb75c15d2e28c2004b5ab2dd8fd3db0a2da88e56
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-14 13:30:27 +00:00
Christian Kandeler
4899e133c9 ClangCodeModel: Keep base declaration on top
... when presenting the list of virtual overrides, as we do in the
built-in code model.

Change-Id: I2598438f78cd9d9a7ddc1620391cea51d7e2da42
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-14 07:48:48 +00:00
Christian Kandeler
7275402ce9 ClangCodeModel: Fix links for virtual overrides
For some reason, clangd returns the declaration instead of the definition
position in the "Goto Implementation" result, so we have to do another
look-up for each override.

Change-Id: I2a99eb0dacdea07d5882087445dc2b2d61b24e58
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-11 13:57:01 +00:00
Christian Kandeler
27243bcfe3 ClangCodeModel: Do the "Go to Implementation" requests recursively
clangd reports only the first level of overrides.

Change-Id: I4aef7ca548a7a06fc7461994c3b750f9372aa738
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-11 05:35:58 +00:00
David Schulz
79b9a2fea6 TextEditor: filepathify RefactoringChanges
Change-Id: Ie97e484bcdeaa0cb2f5d04b3c79ace55ff2e426c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-08 11:40:10 +00:00
Christian Kandeler
eba2f2df84 CppEditor: Run test cases for virtual functions also with clangd
This uncovered some bugs, of which we fixed the ones that we could do
something about.

Change-Id: Id8494793bec4d25635bf920133d9f9331bd36228
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-08 09:51:09 +00:00
Christian Kandeler
a5ba33cbeb CppEditor: Add second "Find References" Action
This one includes access type categorization, while the "normal" one
does not.
We need this now, because with clangd, the categorization is too slow to
enable it by default.

Change-Id: I2eb4608630d34452ae28f0836befd5d9053f42bf
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-07 08:28:49 +00:00
David Schulz
068873c9d5 Utils: add FilePath::baseName
Removing some FilePath::toFileInfo() calls

Change-Id: I49be2ef260f225e07b64ee8ace6a8cd47a9d8bb2
Reviewed-by: hjk <hjk@qt.io>
2021-06-03 11:23:35 +00:00
Christian Kandeler
898558508d ClangCodeModel: Add test for "follow symbol"
These are the tests from clangbackend, so we are now up to par coverage-
wise.

Change-Id: I7b8a63109bff17745782a646f684fd795f732672
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-03 08:15:32 +00:00
Christian Kandeler
ff0301635e CppEditor: Tweak test infrastructure
... so we can re-use the "follow symbol" test cases with clangd.

Call Creator like this (clangd needs to be version 12 or later):
$ QTC_CLANGD=<path to clangd> qtcreator -test
'CppEditor,*Follow*,*Switch*' -test 'ClangCodeModel,*dummy*'

During testing, some invalid code in the test cases was uncovered and
fixed.

Change-Id: I9dc650fdba2a27600e6a550420ee873f6fb31d23
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-02 10:52:50 +00:00
Christian Kandeler
b0d4fc359f ClangCodeModel: Let user choose the override
.... when following virtual function calls.
This brings us up to par with the built-in code model.
We do lose the icons, but they are of very little use in this context.

Change-Id: I29b27d538e7277d06a5af7acee07bddb6eb94c98
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-01 08:22:21 +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
hjk
76db1e3746 Core: Add FilePath based overloads to EditorManager::openEditor{,at}
Part of the overall FilePath migration. Keep the original version for
a while to allow using code to catch up.

Change-Id: Ia7c5ea14416a06e679e8661c0e4045981db87b9b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-25 09:55:50 +00:00
Christian Kandeler
6ffe16d90b ClangCodeModel: Use clangd for all "follow symbol" actions
Change-Id: I4e33342d9683c24ad6ea5fbb578a1b460790aa4d
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-21 08:41:51 +00:00
Christian Kandeler
fe0bdf8314 ClangCodeModel: Add helper for retrieving ClangdClient for source file
Change-Id: I0a379e146abe65a144efb307696852de75fa14a6
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-19 11:34:39 +00:00
Christian Kandeler
b087897b42 ClangCodeModel: Implement global "follow symbol" via clangd
Change-Id: Iaa58e3ee2e74b1a1210850f944df942e3669d247
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-19 11:32:06 +00:00