Commit Graph

1332 Commits

Author SHA1 Message Date
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
David Schulz
08002c6278 Editor: delete assist interface in lsp/clangd support
The complete memory management in the code assistant needs an overhaul.
For now just delete or at least track the assist interface with scoped
pointers.

Fixes: QTCREATORBUG-28408
Change-Id: I0bd4cfaa36a660b6fd5bb467af3b13414ed76e63
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-08 12:07:56 +00:00
Christian Kandeler
c4ee485bdf ClangCodeModel: Fix persistent SwitchDeclDef object
If both AST and document symbols are available right away, the
ClangdSwitchDeclDef object emits its done() signal before it is
connected and stays around, potentially firing off new "follow symbol"
requests to the bewilderment of innocent users.

Fixes: QTCREATORBUG-28183
Change-Id: I972c8d4d9d7b7435e293d76fe710b19c9c4fb287
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-11-08 08:14:37 +00:00
Christian Kandeler
a459ee5d24 ClangCodeModel: Re-enable renaming via clangd
The hard rename limit is gone, see https://reviews.llvm.org/D136454.
Make the feature opt-in for now, as we still need to do some UI fine-
tuning

Change-Id: Ic631a5b39711c6f37fffeeec4d2a5f5bf3bde92b
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-10-24 11:44:51 +00:00
Christian Kandeler
72c1c891fa ClangCodeModel: Adapt to new highlighting modifier in clangd
See https://reviews.llvm.org/D134728.

Change-Id: I2bcfb09736b6eabc54cd986b0c096c8fa5869b8e
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-10-24 10:08:49 +00:00
Alessandro Portale
3cda873d7b ClangCodeModel: Set actual fileKind in clangOptionsForFile
Change-Id: Iff9ad3a6135d73359d6d5cc841f23b2ec5fe332c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-21 07:22:02 +00:00
David Schulz
938e9cab0f ClangCodeModel: fix null pointer access
Change-Id: I2c9e4dc04b7b27986eb0a3a74d8fa6879715df87
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-19 12:25:55 +00:00
Christian Kandeler
0759f55c00 ClangCodeModel: Make use of clangd's new "definition" modifier
See https://reviews.llvm.org/D127403.

Change-Id: I791b2396266810bfb3610a9f37565e4f01d67879
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-19 10:09:16 +00:00
Eike Ziller
638e73e4f8 Clangd indexing: Hide cancel button, open settings on click
Since we cannot reasonably "cancel" indexing, hide the cancel button
from the progress indicator.
Open the Clangd settings page when clicking on the progress indicator
instead.

Fixes: QTCREATORBUG-27744
Change-Id: I625464e7f7456bcf7f01ce7e52f6bd6b53e3d8b2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-19 06:24:54 +00:00
Christian Kandeler
679a726330 C++ support: Consider project-specific target triple
... before creating project parts.
Otherwise we can get wrong includes and defines from the compiler.
Amends 9c86e6746f.
Also do not add -m32 or -m64 for non-x86 targets.

Task-number: QTCREATORBUG-25615
Change-Id: I02da9251c77d45fc8827990a2d59c3ae2c262591
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>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-10-14 12:30:14 +00:00
Marcus Tillmanns
1b6728538e Clang: Fix compile_commands path setup
Change-Id: I2af0935ad022714f8e929c483455a8800e9f7cca
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-14 08:53:28 +00:00
Christian Kandeler
b6a7666697 ClangCodeModel: Do not needlessly update the configuration
... of a document.
This fixes the indexing progress bar appearing when opening a source file
(unless it has editor defines set).

Change-Id: Ia99b226abdb1d5a98a92b23eb4d7311611940b0a
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-10-13 13:27:22 +00:00
Christian Kandeler
48755cf7fd Revert "ClangCodeModel: Rename via LSP facilities"
We cannot use clangd's rename facilities yet, as there is a
hardcoded limit of affected files.
This mostly reverts commit 7dc2c6b3b3.

Change-Id: Ie441796569b533948cc028c867175d6f9d4b9d54
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-12 08:57:47 +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
eb59027920 ClangCodeModel: Save some disk space and unneeded allocations
... when writing out compile_commands.json files.

Change-Id: I8b2298eee87609a90ebb4dbd58b38bd6f36c5a7b
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 11:34:10 +00:00
Christian Kandeler
7dc2c6b3b3 ClangCodeModel: Rename via LSP facilities
Contrary to our original expectation, clangd's textDocument/rename does
not necessarily yield the same locations as /references. Instead, it can
find fewer or more occurrences, depending on server-side logic about what
constitutes a reference vs what should be renamed. Therefore, we need to
use /rename for proper behavior.

Fixes: QTCREATORBUG-27978
Fixes: QTCREATORBUG-28109
Change-Id: I27d092e807a4aa59dc0674111429c77ca13010e9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-06 11:09:57 +00:00
Jarek Kobus
95e54055ef Clang: Limit the usage of qMakePair and std::make_pair
Change-Id: Ida094760023047ecb8ba29e60d5e81f766981b65
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-04 08:45:28 +00:00
Eike Ziller
a254a9ba54 Merge remote-tracking branch 'origin/master' into work
Change-Id: I2235a55a599aaeca5d2b5377300a044b66c17da9
2022-09-29 12:03:13 +02:00
David Schulz
e2352f1cc0 Clangd: add setting for index priority
Change-Id: I5f9ea8c31747d1cd1e1e6b77ab7c705a7f275cff
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-09-28 12:16:13 +00:00
Christian Kandeler
c1e6307545 ClangCodeModel: Catch exceptions in semantic highlighter
I've repeatedly encountered std::bad_alloc recently, and would like to
get more info about where it is triggered. The crash comes from Qt,
apparently after the original thread has alresdy finished, so the
original location is not found in the stack trace.

Change-Id: I7bbdcce6534ea0c846a69af33ad8634c3415572d
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-09-27 07:55:49 +00:00
Christian Kandeler
9db286b3d6 CppEditor: Add actions for following a symbol to its type
Change-Id: I0b3913993b09b006e2d0431a68e98e21e8865898
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-27 07:55:21 +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
Eike Ziller
e3f375925d Prefer project's Qt version for context help
To avoid additional dependencies, let the QtSupport plugin register a
function for filtering help URLs, and add information about the
originating file path to the help items created by the context help
handlers. The filter hook then finds out the corresponding project,
active target, and corresponding Qt version, and filters the help URLs
accordingly.

With the default setting in "Kits > Qt Versions > Register
documentation", only the highest versioned documentation set within a
major Qt version is registered, so context help now shows the highest
versioned help from Qt 5 or Qt 6 depending on active target. If that is
changed to "All", context help now shows documentation from exactly the
version that is currently used by the project.

Fixes: QTCREATORBUG-10331
Change-Id: I7d87793737cc5ab7d228ee4bfe568d7e8343ee7d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-26 09:24:55 +00:00
Christian Kandeler
a522215840 CppEditor: Move renameFilesForSymbol() to ProjectExplorer
We'd like to use it outside of CppEditor in the future.

Change-Id: Ie7553a17aa1d86fb898eaa315a1613ac0ff6b452
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-09-22 07:09:38 +00:00
Christian Kandeler
d696f3380c ClangCodeModel: Add missing check in ClangdFindLocalReferences
When trying to find out whether a symbol refers to a local variable, we
first look up its definition. Afterwards, we need to check whether that
definition is located in the same file. This was forgotten, which lead to
seemingly random weirdness when trying to rename non-local symbols.

Change-Id: I505675a784fc69dc4f01105033608116fc7720c2
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-09-21 07:44:32 +00:00
Christian Kandeler
644c438c3a ClangCodeModel: Try to find help items for method overrides
... in the base class.
This is purely a heuristic, but should work well for Qt-based user
projects.

Fixes: QTCREATORBUG-9845
Change-Id: Icca336b3568c2c5f07a9eaf6a183bf6c7c4275bd
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-14 11:21:38 +00:00
Christian Kandeler
a33b37bfaf ClangCodeModel: Restart clangd on "internal" changes to non-open files
Our previous "openExtraFile" approach does not reliably trigger re-
indexing.

Task-number: QTCREATORBUG-26521
Change-Id: Ibb4008d9cc72afddf6709c6f9442426440b72d01
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-14 08:00:31 +00:00
Eike Ziller
9d745e0f53 ClangCodeModel: Fix compiler warning
Change-Id: I68648ffe4ae3aa8bdfdf2706c1a65eb2269eaa1f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-09-14 07:57:56 +00:00
Christian Kandeler
42121845cb ClangCodeModel: Add missing notification after symbol renaming
Task-number: QTCREATORBUG-26521
Change-Id: I3f3e25f4c28bc454f66bbd730e172833be8f87e4
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-14 07:44:25 +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
2fc5dba1c3 ClangCodeModel: Implement per-session mode for clangd
Fixes: QTCREATORBUG-26526
Change-Id: If9e018475b4e2f0557d9bf64ad9a7921c9dd6046
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-05 09:07:13 +00:00
Eike Ziller
04e50438eb Utils: Remove Utils::optional
Since we are now requiring macOS 10.14 we can remove our local
implementation of optional and use std::optional for macOS too.

Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2022-09-01 06:58:04 +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
Christian Kandeler
607900ae17 ClangCodeModel: Fix tests
Amends a7956df3ca.

Change-Id: I7cbbd391ee015c5481e90ebdad356d9c6e916d5e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-08-29 11:10:28 +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
Christian Kandeler
d454184467 ClangCodeModel: Use central functions for getting token positions
Change-Id: I192e2807067467906b38e164933755f763133cb4
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-26 07:44:21 +00:00
Eike Ziller
c6c92ec096 Merge remote-tracking branch 'origin/8.0'
Conflicts:
	src/libs/qmljs/qmljsmodelmanagerinterface.cpp
	src/plugins/clangcodemodel/clangdclient.cpp
	src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp
	src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp
	src/plugins/qmldesigner/designercore/include/modelnode.h
	src/plugins/qmldesigner/designercore/model/modelnode.cpp
	src/plugins/qmldesigner/designercore/model/rewriterview.cpp

Change-Id: I93c57879b79f27325321bfc045ca618bd835af93
2022-08-26 08:40:23 +02:00
Cristian Adam
9102452272 clangd: Use QtC system environment for environment variables
Users would set QTC_CLANGD_COMPLETION_RESULTS in the Qt Creator
system environment variable dialog and expect that clangd would
the be configured with the corresponding --limit-results value.

Task-number: QTCREATORBUG-28071
Change-Id: Ia7a9b6a96fabe7ba16906c547a15716f0b83f0ec
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-23 13:41:11 +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
The Qt Project
825b781a07 Merge "Merge remote-tracking branch 'origin/8.0'" 2022-08-19 12:24:55 +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
Eike Ziller
64247bf571 Merge remote-tracking branch 'origin/8.0'
Reverts/comments out parts of 45f93a817a,
which needs to be resolved in a follow-up commit.

 Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
	src/plugins/clangcodemodel/clangmodelmanagersupport.cpp
	src/plugins/cmakeprojectmanager/cmakesettingspage.cpp
	src/plugins/python/pythoneditor.cpp
	src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
	src/plugins/scxmleditor/common/colorsettings.cpp

Change-Id: I7f0f7b7120e75a9fc3a8886bc57c17345cbb501b
2022-08-19 12:48:27 +02:00
David Schulz
b39c7cd782 CppEditor: remove unneeded indirection for the outline model
Change-Id: I01e9fb0dae30d6df22c0f5d7255ab247c48749fc
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-16 07:53:41 +00:00
hjk
8953d68f9a CppEditor: Avoid a FilePath <-> QString roundtrip
Change-Id: Ia7860e04090aee8b7fae18cdc5f2d85880f29d69
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-10 14:50:26 +00:00
Christian Kandeler
93fbef4de6 ClangCodeModel: Consider the case of a restarted client
We must not assume the initialized() signal comes only once.

Task-number: QTCREATORBUG-27596
Change-Id: Ife19657b7e0701a0e0dc10806e230bd1744a20aa
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-10 11:14:39 +00:00
Christian Kandeler
e24591dbe5 ClangCodeModel: Move memory usage widget to its own set of files
Change-Id: Iaeb449a12a11e46e8ce03556c699fff4ffceffc5
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-05 08:47:59 +00:00
hjk
ed8c775def Merge remote-tracking branch 'origin/8.0'
Change-Id: Icbb87ac8bcee5fb86042d3863a973573510651b4
2022-08-05 08:50:27 +02:00
David Schulz
5d85c4dbdf ClangCodeModel: fix diagnostic settings link
Link the diagnostic configuration action of a tooltip against the clangd
code model settings page.

Change-Id: I367bda11f1d360ef4a0b686229c7466678cbb803
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-05 04:39:53 +00:00
hjk
0a1edae9de LSP: Use char16_t literals for keys into json objects
Allows use of QStringView based QJson* functions.

Change-Id: I6f39306652bea3abecdcf9e1d4ae494a6b9101c7
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-08-04 13:07:33 +00:00