Commit Graph

397 Commits

Author SHA1 Message Date
Ulf Hermann
1c60f57340 C++ editor: Make generated Q_PROPERTYs FINAL by default
It's bad style to omit the FINAL because such properties can be
shadowed, causing problems in QML.

Change-Id: I9083c69128f6335f584f0a1d28f1fe1e54a02eaf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-04-20 07:44:42 +00:00
Jarek Kobus
16b9539a40 CppLocatorData: Introduce findSymbols
Reuse it inside cppquickfixes.cpp. Don't use global
CppModelManager::classesFilter, but more specialized and
much faster CppLocatorData::findSymbols.

The return value of CppLocatorData::findSymbols is a list of
IndexItem::Ptr instead of LocatorFilterEntries, so that we
may avoid using internalData for passing IndexItem::Ptr.

Change-Id: I14591b3fcf4de34d6fea23b9f354fe898123c9af
Reviewed-by: Christian Kandeler <christian.kandeler@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:50:10 +00:00
Jarek Kobus
4396820145 CppQuickFixes: Add lacking calls to prepareSearch()
Before matchesFor() are called.

Change-Id: I6acc9b39c5fd9c500312fa1863456d4e71e50165
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-03-16 09:07:48 +00:00
hjk
3e7d93c788 ProjectExplorer: Move some not-fully-session related bits
... out of SessionManager.

The idea is to later move SessionManager into the Core plugin,
which both is sensible conceptually and also prerequisite to
merge the Bookmark plugin into TextEditor plugin.

Currently, only the interface is split, as the load/save
implemetations are non-mechanical to disentangle.

Change-Id: I31631db3094ea192825a2ccaa6add6188662940b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-03-01 09:26:50 +00:00
Orgad Shaneh
7cd4c295c7 CppEditor: Initialize member in GetterSetterRefactoringHelper
Reported by Coverity.

Change-Id: I0b6a1a36a33fe9b1cd81d2b314c80f42054d3d11
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-30 17:09:23 +00:00
Alessandro Portale
f7bcd4f574 CppEditor: Convert to Tr::tr
Change-Id: Ic4025e06e17c45eb6dc2162fb7f21f5b8aebe84d
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-01-12 06:46:45 +00:00
Christian Kandeler
11569852d4 CppEditor: Get rid of an unneeded use of std::tolower()
Task-number: QTCREATORBUG-28612
Change-Id: I48a912b202ef0f0687c39600a14653d75df28215
Reviewed-by: hjk <hjk@qt.io>
2023-01-11 13:32:55 +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
hjk
e42d24fca9 CppEditor: FilePathify some of the refactoring operations
... and adjust surrounding code.

Change-Id: I1d36e5a0c6ba14a1d9b8fd59340f1bb2a1e45ad1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-12-16 14:27:50 +00:00
Eike Ziller
af60fb8241 Merge remote-tracking branch 'origin/9.0'
Conflicts:
	src/plugins/cppeditor/cppelementevaluator.cpp
	src/plugins/vcsbase/vcsbaseclient.cpp

Change-Id: I31e03b063240416280f5ca88c31f432911d5c67e
2022-12-12 11:07:15 +01:00
Jarek Kobus
834f89acf2 Remove unused variables
Change-Id: I653f6fa71bb04e049d4e1848a7e38a606692e678
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-12-09 13:01:53 +00:00
Jarek Kobus
154e3df17e CppQuickFixes: Fix possible null dereference
It may happen that we dereference null inside the following
condition:

  if (declarator->postfix_declarator_list)

This may happen in case we entered the "if (!declarator)"
condition, but didn't fulfill the nested
"if (path.at(n - i++)->asPointer())" condition.

Detected by clazy analyzer.

Change-Id: I47135bc5648459e91664a4f65f9752b58248a496
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-08 14:10:53 +00:00
Christian Kandeler
7c0bc1384c CppEditor: Prevent showing unwanted function template parameters
Task-number: QTCREATORBUG-28186
Change-Id: Ic52090e873b4defa68cf98e2a5d08f2f0604e714
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-12-01 12:17:49 +00:00
Christian Kandeler
524f9e063a CppEditor: Make "Move Definition" available for member templates
The resulting signature is broken; this needs to be fixed in a follow-up
patch.

Task-number: QTCREATORBUG-28186
Change-Id: I9b8211c6d6a4b7bef5940da5e74dda00024abd19
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-12-01 12:17:32 +00:00
hjk
39ffdb416f CPlusPlus: Use FilePath for resolved include paths
... and fix fallout.

Change-Id: I66886e91ff476eff15db51cc024a8021e952d44d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-30 17:27:56 +00:00
hjk
83720540a1 CppEditor: Convert parts of ModelManagerInterface to FilePath
Change-Id: If7503b6d6732e1735eb8d48ece6e80886d10c647
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-29 12:27:10 +00:00
hjk
038771051d CppEditor: Switch to FilePath in IndexItem
... and fix fallout.

Change-Id: I45d27146806bdcb5ceb728b710eca51c7cd32ee2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-25 11:16:38 +00:00
hjk
fa1adf4d40 CPlusPlus: Proliferate FilePath use
The starts with CppDocument::filePath(), plus a bit of the fallout

This is one patch of potentially many. It is hard to draw the
line where to stop this kind of chunk, this here converts a few
additional functions for which including it in the patch looked
like less churn than without.

Converting is mostly fromString/toString, with a few exceptions
for "already seem" like caches, that use cheaper "path()" to
avoid likely performance regressions (on Windows FilePath
comparison is currently case-insenstive, and more expensive).

There should be no difference for local operation with this patch.

Change-Id: I7b35f98a0a6f0bfed4ea0f8f987faf586f7a8f2b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-22 15:30:00 +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
Jarek Kobus
cd582faa7e CppEditor: Limit the usage of qMakePair and std::make_pair
Change-Id: I4c85edbaccb553320b5488d3dd2c2595fc2bd825
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-10-04 14:06:00 +00:00
Christian Kandeler
0f7a539262 CppEditor: Let user decide whether to use "auto"
... in "Assign to Local Variable" quickfix.

Fixes: QTCREATORBUG-28099
Change-Id: I3640ef3d1e069bb2cac4d78f0ae60726b131c4fe
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-22 13:26:20 +00:00
Christian Kandeler
4119181762 CppEditor: Make value vs const ref return type configurable
... in the quickfix settings.
Also change the default: With mandatory RVO and move semantics, value
return types are the right choice most of the time.

Fixes: QTCREATORBUG-25790
Change-Id: I68fc6c616358478ba893101b3e04aa6bbbe79348
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2022-09-19 12:30:47 +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
Alessandro Portale
912b016ab0 Utils: Add "Layouting::HorizontalRule" LayoutItem
We have many horizontal separator lines in the UI, which are each time
repetitively created from a QFrame with some flags set. With the .ui
inlining, we will have more of these separators coming.

This change intoduces a Layouting::HorizontalRule LayoutItem and
replaces various existing QFarme separators with it.

Change-Id: I60bad89e2a2b777fbd2f9d0cf872af81e41dcfd7
Reviewed-by: hjk <hjk@qt.io>
2022-08-29 15:30:25 +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
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
Christian Kandeler
725c36e8d0 CppEditor: Keep offering "Extract Function" after all
As it turns out, there are some bugs in clangd that prevent this
functionality from working in some circumstances.
This effectively reverts 840263eb9a.

Fixes: QTCREATORBUG-28030
Change-Id: I511eb9a5cc45e3fd5e3cc25898aebb493f1ba3d3
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-08-16 11:08:22 +00:00
Marcus Tillmanns
a251126485 warnings: Fix unused/unnecessary lambda capture
Change-Id: I1d0ed78da53c56f0a87bf35b1ee2480f9dfd330c
Reviewed-by: hjk <hjk@qt.io>
2022-08-04 10:22:29 +00:00
Jarek Kobus
44f1fd6498 Drop Qt5: Cpp/TextEditor: Get rid of QOverload
Change-Id: I010f211b40f876c0f033fd717aaa094f775ea214
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-07-26 16:58:45 +00:00
Eike Ziller
91fb0cf123 Merge remote-tracking branch 'origin/8.0'
Conflicts:
	src/plugins/qmldesigner/qmldesignerprojectmanager.cpp

Change-Id: I5106bb632c2a3a144287097137be45b0894b9ee4
2022-07-04 08:53:22 +02:00
David Schulz
d09081d07c CppEditor: Initialize pointer member with nullptr
... when generating missing Q_PROPERTY infos.

Fixes: QTCREATORBUG-27770
Change-Id: I31d13ae6d6ed5b2be354097d48303d0cadfa253e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-30 08:48:55 +00:00
hjk
e2bb204d4d CPlusPlus: Inline more simple Type related functions
Change-Id: I2103e8047b385b438e58072e8a2689f1889d2724
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-28 11:02:22 +00:00
hjk
ffa3aad576 CPlusPlus: Inline some simple central functions
Depending on context, callgrind sees contributions of >8% to
the total cost of project parsing for these functions. The
functional are actualy executed executed out-of-line, often
for a function body of one "payload" instruction only.

Inlining removes the call/endbr64/ret overhead.

Change-Id: I6886f08e322fcaa4e0f54d424279e0a8c24e4718
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-24 11:49:41 +00:00
Artem Sokolovskii
5d8f13bfd4 CppQuickFixes: Add "auto" as local declaration incase cxx11
Add local declaration function add "auto " incase
cxx11 features are enabled.

Fixes: QTCREATORBUG-26004
Change-Id: I10da77e8baa52740b1c4df5a21d78ac5f0d1c5d6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-16 11:43:47 +00:00
Artem Sokolovskii
706dc654b9 CppQuickFixes: Add function getDeclaration for AddLocalDeclaration
Change-Id: Ie2d5c5de6b871a855b95efe7c633b28d6ed5c512
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-16 11:20:20 +00:00
Christian Kandeler
75502f2998 CppEditor: Fix check for static-ness
... in generate getter/setter quickfixes.

Fixes: QTCREATORBUG-27547
Change-Id: I29e937ae28c0bce7cd7745b92f371b97876f3e01
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-06-13 14:10:25 +00:00
Christian Kandeler
6e358cbdd4 CppEditor: Switch off "remove using namespace" quickfix with clangd
There is an equivalent tweak in clangd.

Change-Id: I895750f1e942f82da94f441b56b8a7d660ba7086
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-31 11:16:50 +00:00
Christian Kandeler
840263eb9a CppEditor: Switch off "extract function" quickfix with clangd
There is a clangd tweak that does the same, but better.

Fixes: QTCREATORBUG-13240
Fixes: QTCREATORBUG-18607
Change-Id: I59822c725ccb38d995fd8ac03861b1931b81f74c
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-05-18 10:23:50 +00:00
Christian Kandeler
15665680df CppEditor: Use "auto" in AssignToLocalVariableOperation
Fixes: QTCREATORBUG-9577
Fixes: QTCREATORBUG-18412
Change-Id: I46a925611939a3dade142eaf76e20090ae203856
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-05-16 14:35:10 +00:00
Christian Kandeler
8c8e9e55b1 CppEditor: Refactor "assign to local" quickfix
Mostly to separate type and name deduction. No functional changes.

Change-Id: I87858f06bec73fbc59a0359769bd37038176b3ad
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-05-16 11:29:56 +00:00
Artem Sokolovskii
2be4e8c5d5 CppEditor: Remove foreach / Q_FOREACH usage part 3
Task-number: QTCREATORBUG-27464
Change-Id: Icbe620a83b6c2cf6b6166b76d01ca5f3c65ea87a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-12 07:42:02 +00:00
Christian Kandeler
938bef8959 CppEditor: Do not offer "complete switch statement" quickfix
... if the document is managed by clangd.
We should not offer the same functionality twice, and clangd's works
better.

Change-Id: Ifd8edfa91451ab70940a50b550c8d274ee93e6e0
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-11 07:43:06 +00:00
Christian Stenger
2f64cf4779 CppEditor: Do not crash on anonymous classes
While performing generate getters and setters we crashed
when using members of anonymous classes.

Change-Id: I27dc8da950345aa4e26ddb1da3914edcffad5af3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-04-11 10:44:15 +00:00
Christian Kandeler
b8144e0c51 CppEditor: Use trailing return type when moving function definition
... if the original definition also used a trailing return type.

Task-number: QTCREATORBUG-27132
Change-Id: Iaeeeac08601f1d931aabe12be9f89ca0240d97a2
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>
2022-04-05 12:58:39 +00:00
Christian Kandeler
d60c8787cd CppEditor: Only open refactored file in editor if we have a position
It's just confusing to the user otherwise.

Fixes: QTCREATORBUG-27114
Change-Id: I127d97ca165af0eb751cd6479d0ec0ffec480c17
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-02-28 14:24:31 +00:00
Christian Kandeler
3a03b50c7c CppEditor: Consider not only classes
... when trying to find out whether an include statement needs to be
inserted for a given symbol.
The previous code used to ignore e.g. function declarations, so an
unneeded refactoring operation would be triggered.

Fixes: QTCREATORBUG-26591
Change-Id: I5ce0bb064b6ba76e5977de73ea2697342cf74d7e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-11-22 13:49:17 +00:00
Christian Kandeler
49a8b021d9 CppEditor: Make pure virtual functions opt-in
... in the "Create implementations for all member functions" quickfix.

Fixes: QTCREATORBUG-26468
Change-Id: I0965290c38cc66cffaf5dd3871eb96b6ff24b4d2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-10-27 09:19:22 +00:00
Christian Kandeler
404cf0f632 CppEditor: Mark generated setter as slot only for QObject-derived class
Fixes: QTCREATORBUG-25789
Change-Id: I79174bcd617eb54540009491031cfae380383c41
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-22 12:34:51 +00:00
Christian Kandeler
6dd66e012b CppEditor: Fix possible crash in CompleteSwitchCaseStatement
There can be an unexpected null pointer if the built-in code model fails
to parse the code properly.

Fixes: QTCREATORBUG-26316
Change-Id: I5751be505b1182df17f58e1a174d645cef1e95cf
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-10-13 14:05:37 +00:00
Christian Kandeler
50046dbc54 CppEditor: Fix "decl from def" quickfix with templated return type
We must treat return and parameters types of the function differently
from the function itself with regards to template parameters. This was
already done for parameters, but not for the return type.

Fixes: QTCREATORBUG-26248
Change-Id: I44cf6f0bda7b5e3c38f9f73e13f51f2c12ab7dc4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-14 08:22:27 +00:00