Commit Graph

119 Commits

Author SHA1 Message Date
Christian Kandeler
24df1f1183 ClangCodeModel: Support new clangd semantic token for labels
See https://reviews.llvm.org/D143260.

Task-number: QTCREATORBUG-27338
Change-Id: I26eb3688f311d93c966901a6639931fec944dd49
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-06-07 14:00:37 +00:00
David Schulz
9bb126c0d6 Utils: make column of convertPosition 0-based to merge it into Position
Change-Id: I239b3cb33b8ad59ac4097c919155ab5ca7d57b8e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-05-24 11:53:28 +00:00
Jarek Kobus
c879aeb565 SearchResultItem: Introduce SearchResultItems
And reuse it.

Change-Id: Ia052297340f2bf2478fbfdb2427b45e30bd9d067
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-08 06:41:41 +00:00
Jarek Kobus
8b3aa900da Utils: Move SearchResultItem/Color into Utils
It's going to be reused inside FileSearch.

Change-Id: I8993d7158ff31c311c2283d32bc43465a8946a52
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-05-08 06:41:27 +00:00
Eike Ziller
2bc37de42b Merge remote-tracking branch 'origin/10.0'
Conflicts:
	src/plugins/python/pipsupport.cpp
	src/plugins/qtsupport/exampleslistmodel.cpp
	src/plugins/qtsupport/examplesparser.cpp
	tests/auto/examples/tst_examples.cpp

Change-Id: I00273622423fa99d41621969f6ecbbdaa0e18664
2023-04-13 15:59:08 +02:00
Christian Kandeler
0319542937 ClangCodeModel: Do not try to rename macros and namespaces with clangd
Unfortunately, clangd refuses to rename macros and namespaces.
Fall back to our old two-stage "find + replace" approach for macros
(which clangd can find just fine) and employ the built-in code model for
namespaces (as they don't get indexed at all by clangd).

Change-Id: I08b1088ff4de9220427e089ef0700dbf2a944081
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-04-04 07:26:49 +00:00
Eike Ziller
0d8d4322b4 Merge remote-tracking branch 'origin/10.0'
Change-Id: Ie591b7130b33a042509e56701384f8ff4d9cb7f8
2023-03-16 11:57:01 +01:00
Christian Kandeler
25f1a4804a ClangCodeModel: Consider concepts in semantic highlighting
We highlight concepts as types for now, as it's a pretty good fit. We can
always introduce a dedicated concept highlighting type later if there is
demand.

Task-number: QTCREATORBUG-28887
Change-Id: I405db5ca4351efd565b968e765fe8bca976a2800
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-03-14 13:03:02 +00:00
Christian Kandeler
8257369b73 ClangCodeModel: Remove unneeded code
This was liblclang-specific.

Change-Id: I3fe8a8d2d49b1c7b92a54a90864e4ead7152e4ae
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-02-15 12:07:32 +00:00
Christian Kandeler
d7308cc7a6 ClangCodeModel: Ignore built-in types
... in the semantic highlighter. The syntax highlighter already handles
these.

Change-Id: Ib1e80ec194021dbd2b4eca7a300db869ccddb7b0
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>
2023-02-03 10:59:41 +00:00
Christian Kandeler
7c6a00b4e7 ClangCodeModel: Ignore number literals
... in the semantic highlighter. The syntax highlighter already handles
these.

Change-Id: I26f6bca06c4fc648ffe59bd9e3639d81d2265755
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>
2023-02-03 09:33:55 +00:00
Christian Kandeler
c31522731c ClangCodeModel: Ignore boolean and pointer literals
... when doing semantic highlighting. The syntax highlighter already
handles these.

Change-Id: I048e033eda5b72d2e6eafaaccdb66040a00afe6a
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>
2023-02-02 13:36:16 +00:00
Christian Kandeler
209e3d0e66 CppEditor: Fully handle raw string literals in the syntax highlighter
As of a3af941adf, the built-in highlighter
can properly handle multi-line raw string literals, so we don't need to
abuse the semantic highlighter for this anymore.

Fixes: QTCREATORBUG-26693
Fixes: QTCREATORBUG-28284
Change-Id: If644767dfa8a97294e84a541eea44143e8d1bb88
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-02-02 09:52:55 +00:00
Christian Kandeler
be9a01252d ClangCodeModel: Make use of new semantic token in clangd
... for angle brackets.
See https://reviews.llvm.org/D139926.

Change-Id: I17be843005e290a8aec91573d9ed4bd0727e2dab
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-02-01 11:06:54 +00:00
Christian Kandeler
0d909c353c Designer: Update C++ code model on an object name change in designer
We try to locate the old symbol name in the generated ui header and
rename the symbol in the background.

Task-number: QTCREATORBUG-1179
Change-Id: Iaf68e3922cd728cbc87d0dc97125e34b8bdaa6be
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-01-27 10:02:52 +00:00
hjk
33cdb052ba FilePathify some testing code
Change-Id: I3739a6eb3c2172078e9519e8186daf94ec74d99a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-01-13 10:46:13 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
Christian Kandeler
8d17762bb0 ClangCodeModel: Use newly implemented clangd support for operators
We now get a semantic token "operator" from clangd;
see https://reviews.llvm.org/D136594.
As a side effect, this results in the following subtle changes in what
exactly gets highlighted, both of which make sense:
    - The type part of a conversion operator is now highlighted as
      a type, not an operator.
    - We no longer add special highlighting for the brackets in
      operator new[] and operator delete[].

Change-Id: Ic149487496768762728a712c9fbcde5c9516529c
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-12-13 09:38:34 +00:00
Christian Kandeler
bfecefabc0 CppEditor: Let users check for unused functions in (sub-)projects
Note that especially in C++, there can be a lot of false positives,
especially in template-heavy code bases. We filter out the most notorious
offenders, namely:
    - templates themselves
    - constructors and destructors
    - *begin() and *end()
    - qHash()
    - main()
Since the code model does not know about symbol visibility, the
functionality is quite useless for libraries, unless you want to check
your test coverage.
The procedure is rather slow, but that shouldn't matter so much, as it's
something you'll only run "once in a while".

Fixes: QTCREATORBUG-6772
Change-Id: If00a537b760a9b0babdda6c848133715c3240155
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-24 09:27:03 +00:00
Eike Ziller
10dca6b37f Merge remote-tracking branch 'origin/9.0'
Change-Id: Ie069f3b2a1200b3e665341b1d56ce836024b0d29
2022-11-10 13:22:43 +01:00
Christian Kandeler
f93c316b73 ClangCodeModel: Adapt to new upstream feature
See https://reviews.llvm.org/D130015.

Change-Id: I2c2590265f2d7a2c2b5e966b0dc65ceff6b1b3e6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-11-08 14:21:25 +00:00
Christian Kandeler
074126cf47 ClangCodeModel: Fix usage type of constructors in "Find References"
In particular, in a variable definition, the (invisible) reference to the
constructor is *not* a declaration (but an implicit call).

Change-Id: Ic1f29a4da360959e81ec536efbf1175924ea34d7
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-11-08 10:53:25 +00:00
Christian Kandeler
3e3569f6dc CPlusPlus: Add more usage tags
To be used in subsequent patches.

Change-Id: Id7140aa39bb2adba343cc12b0273c90f3c12abeb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-07 13:24:58 +00:00
Christian Kandeler
d891e18edc CPlusPlus: Make Usage::Type QFlags-based
We want to extend the enum with more non-exclusive values.

Change-Id: I4d8ebe1f7327139c7817b9f621b4b74a883c5e09
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-07 11:33:33 +00:00
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +00:00
Christian Kandeler
813c6fbd81 ClangCodeModel: Implement following a symbol to its type
Making use of LSP's "Go To Type Definition".
Just the backend for now, UI to follow.

Change-Id: Id73b2cf701eab03913477f6d4d3093e257e80dbd
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-26 11:24:20 +00:00
Christian Kandeler
f7efefb6d4 ClangCodeModel: Support setting additional preprocessor directives
... for a document.
This was only ever implemented for the built-in code model.

Fixes: QTCREATORBUG-20423
Change-Id: Ia99d0136e9995a5626058ad06173ea077be024d8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-13 08:14:28 +00:00
Christian Kandeler
02a76947a5 ClangCodeModel: Adapt test to upstream change
Apparently, friend declarations now get the "declaration" modifier.

Change-Id: I30255d9953c96f2579a3fc66232a21edf406a01a
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-08-31 09:01:20 +00:00
Eike Ziller
57745407de Clang/C++: Use qtcEnvironmentVariable* instead of qEnvironmentVariable*
And instead of qgetenv.
Takes Qt Creator's setting at "Environment > System > Environment" into
account, which makes it easier on some platforms to set them (e.g.
macOS), can be configured differently in different settings paths, and
potentially can be changed at runtime (depending on usage).

Change-Id: I7678b8e429b5eff79f87eb637f6f2131be43d904
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-29 09:12:20 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Marco Bubke
84c1d6572b Utils: Remove variant.h
Since we are now requiring macOS 10.14 we can remove our local copy of
std::variant and use for macOS std::variant too.

Change-Id: I589d03b35fc56878b7392ffa7047a439e588fe43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-23 09:51:43 +00:00
Christian Kandeler
1c0ef80861 ClangCodeModel: Fix semantic highlighting for __func__
This is a local variable, not a macro.
Also take into account the new upstream support for this (see
https://reviews.llvm.org/D131175), which required us to fix our
assumption that "static" always means "static member".

Change-Id: I69f3c98737571cbd55f9c64c02292426acb6031b
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-08-19 12:23:54 +00:00
Christian Kandeler
321fae46f6 LanguageClient: Support limit parameter for completion request
... and make use of it in the ClangCodeModel tests.

Change-Id: Ib2186273aec1db9b354892c2e1c4ebd82e3c1c96
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-08-04 12:05:18 +00:00
Christian Kandeler
5fcb459d6b LanguageClient: Add LanguageClientManager::clientAdded() signal
For consumption by interested parties.

Change-Id: I0cbecb4ce99cdd208fc3ff019d4f0ea672dcf752
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-08-04 10:21:47 +00:00
Christian Kandeler
2f169bdfcb ClangCodeModel: Make some ClangModelManagerSupport methods static
Change-Id: Ie34a89ae01783631c6482cff8d4866595e757be5
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-08-02 11:21:16 +00:00
Christian Kandeler
9cbe2439dd CppEditor: Do not highlight macros as preprocessor statements
Macros are used like identifiers; there is no reason why they should need
to have the same highlighting as a preprocessor directive.

Fixes: QTCREATORBUG-23548
Change-Id: I186befc06ccb36a00451fd707c41e3687a84af14
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-06-29 09:08:27 +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
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
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
cf96a91b69 ClangCodeModel: Fix mis-detection of class members as operators
The name check was not tight enough.

Change-Id: I5d813a29525bd5b5c23ce04f0bd9e5982a36536e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-04-21 09:17:15 +00:00
Christian Kandeler
260095c924 ClangCodeModel: Fix another false positive
... in output argument highlighting.
If there is not enough information for clang to determine the const-ness
of the argument passing (as it can happen in templates), do not report
an output argument.

Change-Id: I8d0143042f02ac44d8d971398014828cff14697f
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-13 10:25:01 +00:00
Christian Kandeler
53d6aea404 ClangCodeModel: Fix another false positive
... in output argument highlighting.

Fixes: QTCREATORBUG-27367
Change-Id: I80fc7628d62de18f9114290b8104a7a1e9a95c4b
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-13 08:43:22 +00:00
Christian Kandeler
06ce449a01 ClangCodeModel: Fix another output argument mis-detection
We need to relax the range check: In expressions such as x.y->z, the
second argument for the operator->call is x.y, not just y.

Fixes: QTCREATORBUG-27352
Change-Id: Ida542c11c129630f0a1d301508ec5f8076eb9902
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-04-11 07:16:22 +00:00
Christian Kandeler
25144c0afe ClangCodeModel: Fix erroneous highlighting as output argument
... for objects with non-const member calls.
Amends 8247f4f3dd.

Fixes: QTCREATORBUG-27306
Change-Id: I13fdf1ff9daf9ac084beda6c1d8ada5801adca4c
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-04-04 12:46:28 +00:00
Christian Kandeler
a1b910724d ClangCodeModel: Fix local renamings with clangd
This functionality somehow stayed in the proof-of-concept
stage, working only for free functions.

Fixes: QTCREATORBUG-27249
Change-Id: I840beae66314330ce643e159c596e702a0ec3273
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-31 07:59:46 +00:00
Christian Kandeler
f8cec0a85a ClangCodeModel: Properly highlight static data members
C_STATIC_MEMBER is mutually exclusive with C_FIELD, so it must not be a
mix-in style.

Task-number: QTCREATORBUG-27111
Change-Id: If9e5f44790f1b7d124f4b2e9859f8c2223c0c424
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-02 12:59:22 +00:00
Christian Kandeler
8247f4f3dd ClangCodeModel: Do not highlight objects in method calls
... as output arguments with clangd.
We might want to do so in the future, but right now it's not intended.

Task-number: QTCREATORBUG-27111
Change-Id: Ie6941f18943a1d6942901c526c62999cba6c1125
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-03-01 10:14:32 +00:00
Christian Kandeler
41038ba8cf ClangCodeModel: Do not highlight argument of operator*
... as output parameter with clangd.

Task-number: QTCREATORBUG-27111
Change-Id: I5def562dcb9b8b0dac036fd46ed7e996c0297c95
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-03-01 10:04:16 +00:00
Christian Kandeler
64a1bf6c43 ClangCodeModel: Properly highlight built-in defines
These are not reported as semantic tokens, so consult the AST

Task-number: QTCREATORBUG-27111
Change-Id: I38efcfbdc3197173a50033a74a1bc631eaa8d2c1
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-02-25 11:53:39 +00:00