Commit Graph

138 Commits

Author SHA1 Message Date
David Schulz
39a448c62e Editor: Simplify TextDocumentManipulator
The TextDocumentManipulatorInterface was introduced to decouple
modification operations from QTextDocument. But nowadays all tests and
production code usages are backed by a QTextDocument, so we can remove
this abstraction layer again. The first step is to merge the interface
and all manipulator implementations.

Change-Id: Idd1609df549d3b120dd516d5161af9aa8aa571ca
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2024-06-27 04:28:55 +00:00
Christian Kandeler
8577ab8bcb ClangCodeModel: Bump minimum clangd version
... and throw away old workarounds.
The current clangd version, to be shipped with Qt Creator 14, is 18.1, so
we can safely bump the minimum version to 17.

Change-Id: I74fd5997196d774b6c47dcb522284953ef82ad9c
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-05-24 07:58:22 +00:00
Christian Kandeler
3b80da7117 ClangCodeModel: Make "live update" of dependent sources opt-in
Not everyone wants to invest the extra computing resources needed for
this feature.
Amends b33b99e2d9.
See 6d805195f6 for the original
motivation.

Task-number: QTCREATORBUG-29943
Change-Id: I4c8cce5bb58b34d930a409ea3e0995377c90d4ab
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-04-15 08:58:23 +00:00
Christian Kandeler
faa595e38b CppEditor: Introduce per-project code model settings
Change-Id: I325cc39e60d4b1f0fba1651502d772bfb9c6a91c
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-03-15 14:21:21 +00:00
Christian Kandeler
1de045f687 CppEditor: Move some convenience functions to CppCodeModelSettings class
Change-Id: I0af8560c23374ce4f6c46f98d498d44f7cb50db3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-03-12 08:55:11 +00:00
David Schulz
325db93a7b LanguageClient: improve clangd function hint
Add a Clangd specific function hint model that alwys highlights the
current parameter based on the number of commas in front of the cursor
position, like the builtin code model. It also correctly closes the
proposal after typing the closing parenthesis.

Fixes: QTCREATORBUG-26346
Fixes: QTCREATORBUG-30489
Change-Id: I09d3ac6856acfe5e0f206d8c3a96dbb561ea2ce7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2024-03-11 12:39:06 +00:00
Christian Kandeler
f56fd04c8d Revert "Clangd: Avoid client restart after modifying open documents"
The whole point of tracking external changes to files is to use the open
files as a sentinel to indicate that non-open files (on which we don't
have a watch) have likely also been changed.
This reverts commit cff26d813a.

Change-Id: I5a8b3e6709eda881b912916cf0838b45d1ff4fa4
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>
2024-03-04 10:36:53 +00:00
Jarek Kobus
8bcc78a044 Various plugins: Fix some more C++20 warnings about [=] captures
Change-Id: If20aac4320c84096a07d67cc137886638286acf8
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-02-06 08:34:44 +00:00
hjk
8b86fe239b ClangcodeModel: Move test creation closer to tested code
Change-Id: Ifb6771673aa8639d2ee23d1f34b1ff821000e348
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-01-24 16:38:09 +00:00
Christian Kandeler
711b976294 CppEditor: Also rename function comments for declarations
... that are not definitions.
Amends 0a058bb657.

Change-Id: I4ba19f915d653d05570f8cd244ea50ab40d4b9dd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-11-29 09:42:18 +00:00
Eike Ziller
1c4de485da Merge remote-tracking branch 'origin/12.0'
Change-Id: Ib09af70f157a6c7d6cbda4e3de678fd2bbceb229
2023-11-20 09:48:43 +01:00
David Schulz
cff26d813a Clangd: Avoid client restart after modifying open documents
Change-Id: I116eed1b047159e3d1ce64f18f44da6a0ad7b231
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-11-17 05:38:13 +00:00
Christian Kandeler
d16d1718f3 ClangCodeModel: Forward to the built-in code model
... if the user tries to complete inside a comment or string.

Fixes: QTCREATORBUG-20828
Change-Id: I245e1bd16acaf696601cabe33f27210da21cc12a
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-17 12:03:17 +00:00
Christian Kandeler
0a058bb657 CppEditor: Consider symbol occurrences in comments
... when renaming.
For local renaming, we consider only function parameters.

Task-number: QTCREATORBUG-12051
Change-Id: I7948d69f11b97663c9bd747ae6241a82dd9bdd82
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-09-01 11:42:17 +00:00
Christian Kandeler
b33b99e2d9 ClangCodeModel: Take changes from header files into account immediately
... in the dependent sources. That's also how the built-in code model
behaves, but clangd itself only does this when a document is saved.

Change-Id: I52d6badb0b7f063e5924c05dbf83a6e9849c9f6f
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-08-22 13:59:04 +00:00
hjk
aa25fdcc69 QtSupport: Rename qtkitinformation.{h,cpp} -> qtkitaspect.{h,cpp}
Change-Id: I12229e5e98b468101d32edd35be74bbda0921d89
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-08-15 08:59:52 +00:00
David Schulz
520264999a ClangCodeModel: fix crash on followSymbol
Big files are loaded in chunks inside a QEventLoop. If follow symbol is
triggered via mouse and opens such a big file and the mouse is moved
while loading that file ClangdFollowSymbol got deleted while opening the
file in ClangdClient::followSymbol. Instead of the hard deletion just
cancel that follow symbol operation and make sure done is emitted
afterwards. The handling of that done signal takes care of the deletion
of that follow symbol operation.

Change-Id: Iba4ad6abb541186c2f26506f82fe1bc582818fca
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-06-28 12:33:51 +00:00
Christian Kandeler
7b8117ba2f TextEditor: Add dedicated text style for C++ concepts
Fixes: QTCREATORBUG-29286
Change-Id: Ifc89bad0b84dfdbcac0720fc59799edd461c00bb
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>
2023-06-20 08:15:50 +00:00
Christian Kandeler
f0a1591035 ClangCodeModel: Adapt to new "inactiveRegions" notification in clangd
See https://reviews.llvm.org/D143974.

Change-Id: Iff6cc39f7c567feee1953fde1ca96a9aefec75d4
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-06-08 11:06:15 +00:00
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