Commit Graph

1001 Commits

Author SHA1 Message Date
Christian Kandeler
ec7c60cd67 ClangCodeModel: Do not report non-type template parameters as types
... with clangd.

Change-Id: I9edad375eacc6c33a833c88da64dc29f79334157
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-01 11:40:08 +00:00
Christian Kandeler
be3dd751cb ClangCodeModel: Replace FIXME comments with links to bug reports
Change-Id: Ib6520781e88b8dcf63dd553e199939ff65ae1f05
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-30 08:19:07 +00:00
Christian Kandeler
324105febe ClangCodeModel: Fix a test
The missing header file threw off parsing for some of the code below.

Change-Id: I29f7895b4d88856cc39fd8e33742a37734953b9e
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-29 13:05:04 +00:00
Christian Kandeler
5e9ac00f19 ClangCodeModel: Replace FIXME comment with link to upstream bug report
Change-Id: I90524adbbc4481cb3e1a3c1bf40ae543cdaf6cd0
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-29 09:59:59 +00:00
Christian Kandeler
29c0512416 ClangCodeModel: Do not use clangd for completing #ifdef & friends
Annoyingly, LLVM does not complete preprocessor directives in disabled
code, so that we would not offer e.g. "#endif" after "#if 0" (but we
would offer it after "#if 1").
Fixing it would require messing with the clang libs (rather than just
clangd), so let's just keep using our existing code, which seems to work
fine.

Change-Id: I9dabf9a2a8f3a2f68e88a11b62c3df3b5e64a55c
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-29 09:31:33 +00:00
Christian Kandeler
94a59f15c6 ClangCodeModel: Replace a TODO item with a version check
Change-Id: I22911b5bc5da3e905d1f31ac1bb19251058a5471
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-29 09:30:49 +00:00
Christian Kandeler
7b53ce3439 ClangCodeModel: Replace FIXME comment with link to upstream bug report
Change-Id: I0ad5c67a481b72d637a4ea8793a7c6cb7b263a30
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-29 09:30:00 +00:00
Eike Ziller
45e23e07a8 Fix build on macOS
Amends 901a96231c

Change-Id: I4ebc961bed63a9f5a8fc3a997d0c861d779d0c11
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-29 08:12:07 +00:00
David Schulz
23a58a320e clangd: introduce ClangdCompletionItem
allowing to overwrite apply and get rid of the apply helper in the
LanguageClient completion provider and processor.

Change-Id: I066fe10b116d638bd1b7a81d4488840bec5f0b63
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-29 04:41:06 +00:00
Christian Kandeler
e7eeb5ae34 ClangCodeModel: Use namespace TextEditor in clangdclient.cpp
Less noise.

Change-Id: Ia7ec9c6cbe93868826828379ded2d039f6fa3a44
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-28 13:12:04 +00:00
Christian Kandeler
901a96231c ClangCodeModel: Cache clangd's AST
Since we use the AST in several contexts, it can easily happen that we
need to consult it more than once for the same document revision.
Therefore, it makes sense to cache the AST to prevent redundant requests
for potentially large amounts of data.

Change-Id: I33100e0052ee21bb46e91848d3d2e8a0a96bb860
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-28 11:34:25 +00:00
Christian Kandeler
03f6de1eeb ClangCodeModel: Properly mark "#ifdefed-out" blocks with clangd
The behavior is now the same as when using libclang. Namely:
    - The whole block is grayed out, rather than just symbols
      having a gray background.
    - Ifdefed-out blocks no longer mess with the brace depth.

Change-Id: I8b5f3a788430edcd9dd79249323c26a5ee5d68ed
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-28 10:23:03 +00:00
David Schulz
e7f6abc084 LanguageClient: remove codeassist proposal handler
Removes noise from the interface. Using specialized clangd processors
that redirect the proposals for testing purposes is an overall cleaner
solution.

Change-Id: Ia4f3d4720765f0533c5530a2a5c7db3cc971e0be
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-28 09:50:46 +00:00
Christian Kandeler
be6ea67bfd ClangCodeModel: Replace TODO items with links to upstream bug reports
Change-Id: Iff1ccf77aca74bc34e2944996e7ef2eb2fcb3bad
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-28 08:22:49 +00:00
Christian Kandeler
b35630c03d ClangCodeModel: Highlight "override" and "final" with clangd
Change-Id: If30de546ce360ab9bc3cfa2780f61d6a78e4191d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-09-27 15:03:50 +00:00
Christian Kandeler
553f4bec7e ClangCodeModel: Remove inapplicable TODO item
It's not worth the extra effort to restrict the identifier <-> file name
check to data types: There is hardly any possibility for a completely
false positive, as local variables do not pass through this code path.

Change-Id: Ia92549c8c6723e520789a2ad820a2606620d4efe
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-24 11:41:07 +00:00
Christian Kandeler
eefc8cbc7d ClangCodeModel: Remove inapplicable TODO item
I don't see any explicit sorting of the references in clangd, so let's
continue to not rely on that.

Change-Id: I65269af4995ab851e49f52686a10cc96697fbe64
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-24 11:40:49 +00:00
Christian Kandeler
b10641caa2 ClangCodeModel: Adapt clangd test to upstream change
See https://reviews.llvm.org/D110324.

Change-Id: I9dbc03dd814392939be28d1943515d581f9f5b58
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-24 08:42:21 +00:00
Christian Kandeler
f8c2ab9f7a ClangCodeModel: Remove outdated FIXME
Change-Id: I0f69ab0848c5196bf6cedd467bdff74d0d74dfda
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-24 08:41:46 +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
Christian Kandeler
15b6eaa47b ClangCodeModel: Switch off clang-tidy in clangd
We have our own dedicated clang-tidy support, so let's not confuse
users.

Change-Id: I69a32de3ac96ad2c51d70c82a9eb62f811e65460
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-21 13:24:32 +00:00
Christian Kandeler
002d0a97aa ClangCodeModel: Add XFAIL-ing test for clangd completion
Change-Id: Ic8672d5ce14b9a8d86dc511c5aa3289037258d64
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-20 08:26:57 +00:00
David Schulz
cb5eaf4a63 Clangd: remove unused member
Change-Id: Idd95245a6c5b0db37ca30966cb509fc75a4901e3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-17 12:44:22 +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
David Schulz
17b05bc3e8 Clangd: Create correct code assist processor in provider
... for the context of the code assist instead of using a callback from
the text editor.

Change-Id: I636b1b267a944895d4ff732e3c0a8811332ec14f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-17 12:00:18 +00:00
Christian Kandeler
56f9d17d35 ClangCodeModel: Fix an instance of mis-highlighting with clangd
In the expression x.f(), x was wrongly categorized as an output
parameter if f was a static function.

Change-Id: I9167f98916963cdaa4b5ac6ead2c86fab43ad02e
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-17 08:48:52 +00:00
Christian Kandeler
ad23d86b41 ClangCodeModel: Make use of clangd's non-const ref parameter tagging
clangd 14 will tag non-const reference parameters for us (https://
reviews.llvm.org/D108320), so let's make use of that at least as a
shortcut.

Change-Id: I0162b5d7b9fecc3e6ce0338e896980cd5b363ceb
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-16 09:09:51 +00:00
Christian Kandeler
bcfe229f8b ClangCodeModel: Get document symbols immediately
... when doing a decl/def switch via clangd.
The delay is fine for e.g. populating the outline, but shouldn't be used
when dealing with explicit user requests.

Change-Id: I0350ed6daf8220ec3b702a3876fbf0f726da8a67
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-16 09:09:27 +00:00
David Schulz
4324f3e8c1 Editor: pass AssistInterface to createProcessor
The interface can be used for checking the context of a codeassist
request to determine
the correct processor that has to be created.

Change-Id: I47ddb05c46399566e27bae21711f11a3a4132c3f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-16 08:25:36 +00:00
Christian Kandeler
719f51445e ClangCodeModel: Use dedicated completion assist provider for clangd
The pure LSP-based implementation is too inflexible with regards to
activation characters.

Change-Id: I386a60b80f59e1b48254d55c2a47f1a1ffe1f97f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-14 09:11:33 +00:00
Eike Ziller
3d4d7c7e14 Merge remote-tracking branch 'origin/5.0'
Conflicts:
	src/plugins/clangtools/clangtoolssettings.cpp
	src/plugins/clangtools/executableinfo.cpp
	src/plugins/clangtools/executableinfo.h

Change-Id: Id8caf63e3e594792467d3447870086bd2d8f73b9
2021-09-13 17:03:55 +02:00
David Schulz
04763a307d Clangd: prevent adding refactorings for outdated documents
Change-Id: I658662dca345e1ae209a4d74e145b59c44417b00
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-09 11:46:12 +00:00
Christian Kandeler
1b723f6fd9 CppEditor: Remove unneeded CppEditorWidgetInterface
Removes a pseudo-abstraction and simplifies ClangdClient.

Change-Id: I5161d069371ff92a517866bb7500517cab6781b7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-07 11:16:47 +00:00
Christian Kandeler
4504570447 ClangCodeModel: Fix access type categorization with clangd
... in "Find References".
This was broken in d6acd21fc0.

Change-Id: I0a185a8440bd5260b7cc18a87cefb450be71e77f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-07 10:06:06 +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
Christian Kandeler
847a03786c LanguageClient: Re-highlight also on empty deltas
This is needed for e.g. ClangdClient, which may need to update even if
the highlighting delta from the server is empty.

Task-number: QTCREATORBUG-26183
Change-Id: I38398c9563fa7a6a1906c5cb57fd1cbcd444cbd9
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-07 09:12:13 +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
Christian Kandeler
c8bc0eb512 CppEditor: Merge two smaller headers into cpptoolsreuse.h
Change-Id: If83190725a003a49bcd915225f049ccaf186f985
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-07 08:49:42 +00:00
Christian Kandeler
0b86b455b0 CppEditor: Put the locator filters into one file
These classes are strongly related, so no need to spread them around.

Change-Id: I4258b0c4198b3c650454ac734d7e52e09f46a4eb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-07 08:09:42 +00:00
Christian Kandeler
548e19370e CppEditor: Remove CppToolsBridge & friends
This redirection did nothing except to horribly obfuscate the code.
Note that most callers already accessed the model manager directly, and
some bridge functions were not called at all.

Change-Id: Ic1c728afe79bf98544da23a1955ee82d0dbde94f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-06 09:49:36 +00:00
Christian Kandeler
1d88a65747 CppEditor: Move CppHoverHandler to its only point of use
No need to compile an extra translation unit for this.

Change-Id: Ie21346700818ccadab864b77f13f167bd27a457a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-03 11:36:19 +00: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
25ff15a1fb Add convenience functions for creating ProjectExplorer::HeaderPaths
Change-Id: I7b1f63caca6b70ba4ec1b1870b83cbf20aa6564a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-30 10:46:56 +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
The Qt Project
d8a61bcea4 Merge "Merge remote-tracking branch 'origin/5.0'" 2021-08-18 14:42:50 +00:00
Eike Ziller
94d352ab28 Merge remote-tracking branch 'origin/5.0'
Conflicts:
	src/plugins/autotest/testresultdelegate.cpp

Change-Id: If172206f231fc2a9f4a672cd2e6eaeaea4988c96
2021-08-18 16:14:24 +02:00