Commit Graph

413 Commits

Author SHA1 Message Date
Eike Ziller
ad7d559028 Tr: More small fixes
Change-Id: I5d9324d3f64eaa522fa1d435efa39fa43d84798a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-10-18 12:10:45 +00:00
Christian Kandeler
f1365d99fa CppEditor: Add quickfix for moving function documentation
... between declaration and definition.

Fixes: QTCREATORBUG-13877
Change-Id: If2a8977587ef2ac888e9c9dde5f63d222d96d964
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-09-07 08:47:50 +00:00
Christian Kandeler
6847d69008 CppEditor: Consider comments when extracting a new function
That is, do not place the newly created function in between the function
and its comment.

Fixes: QTCREATORBUG-6934
Change-Id: I79f564a90c7e3c45188f5d694cbde47029651324
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-09-04 12:45:23 +00:00
Christian Kandeler
f93836b25d CppEditor: Add quickfix for converting comments from C++ to C style
... and vice versa.

Fixes: QTCREATORBUG-27501
Change-Id: I8584cc1e86718b3fe0f0ead2a3436495303ca3c8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-08-08 07:33:41 +00:00
Jarek Kobus
1ceea7a91f CppEditor: Add context object into connections
Change-Id: I1a74f62b0a42ea4971b14fb82213f662b5fe4736
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-03 06:53:22 +00:00
Christian Kandeler
fdc834c0d1 CPlusPlus: Remove TranslationUnit::getTokenStartPosition()
It was exactly the same as getTokenPosition().

Change-Id: I292522faa18933ec400b556c384786eb9efdfb3a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-07-13 07:16:29 +00:00
hjk
0b83f110f4 CppEditor: Make a few CppModelManager functions static
... to simplify code using it.

Change-Id: Ib2bfbb5a17a1d48088a9cf4973d4c3f006cd34e4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-07-12 13:08:09 +00:00
Christian Kandeler
bcd49bafdd CppEditor: Add test case for quickfix formatting
Also fixes an off-by-one error in the formatting code that was uncovered
by the test.

Change-Id: I013194e21cf37f318bb806bb60ea659b91b99fbf
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>
2023-06-29 11:51:19 +00:00
Christian Kandeler
cf6bd7e012 Fix occurrences of the contains/insert anti-pattern
Introduce and make use of Utils::insert() for QSet with a return value
that indicates whether insertion actually happened.

Change-Id: I655e4bc3553b74fea5ae8956205e4d8070118d63
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-06-23 09:51:54 +00:00
Christian Kandeler
118c493c6c CppEditor: Make generated function const, if necessary
... in "Add member function" quickfix.

Fixes: QTCREATORBUG-29274
Change-Id: Ie939389ac2336f70fd216f29ce0d38e495786b3e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-06-16 09:11:31 +00:00
Christian Kandeler
7869c4e810 CppEditor: Add quickfix for creating a member function from use
Fixes: QTCREATORBUG-10356
Change-Id: If7376e766f2817949259591560c74bd6fb0e0cd6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-05-16 10:32:04 +00:00
Eike Ziller
7f5876b45a Merge remote-tracking branch 'origin/10.0'
Change-Id: I98e5e1ad43103984b490c65cdeed84b7414303b3
2023-05-11 10:33:18 +02:00
hjk
3f5d33fe5c CppEditor: Fix an error raised by Clang 16
error: integer value -1 is outside the valid range of values [0, 255]
 for this enumeration type [-Wenum-constexpr-conversion]

Change-Id: I1b029099634dcc8f11071aad6a974ec0c41077ce
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-05-10 15:21:07 +00:00
Christian Kandeler
7808195f74 CppEditor: Refactor "insert member from use" quickfixes
The interfaces make much more sense now, and the coding style is taken
into account (except for the fallback case where the user enters the
type).

Change-Id: If08dfc41ebd63287fb5b0b187944e7fdf08b0823
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-05-08 13:09:44 +00:00
Christian Kandeler
89b589c0ea CppEditor: Add quickfix adding a member declaration from assignment
Fixes: QTCREATORBUG-1918
Change-Id: I92c409ba0831edb056d23ae3244f5155876c039b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-05-03 08:58:44 +00:00
Christian Kandeler
5e73bacb0e CppEditor: Merge two factories
They are closely related, and we might want to add more variants of this
functionality.

Change-Id: Ida83cce018fad5a84d5f6d24a0fa4ff2bca5a67b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-04-26 09:23:32 +00:00
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