aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppquickfixes.cpp
Commit message (Collapse)AuthorAgeFilesLines
* CppEditor: Consider all "else" branchesChristian Kandeler2024-03-141-3/+39
| | | | | | | | | ... in "Add braces to control statement" quickfix. Change-Id: Ie9dde7692e72300d350029cac01b712795c6e200 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CppEditor: Refactor AddBracesToControlStatement quickfixChristian Kandeler2024-03-111-17/+17
| | | | | | | | | Preparation for bracifying if-else chains. No functional changes. Change-Id: Idc101131c02aac88598a6de1f8f511f89c958346 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* CppEditor: Make check for clangd more fine-grainedChristian Kandeler2024-02-211-3/+6
| | | | | | | | | | | ... in the quickfix factories. We want to be able to offer or not offer certain quickfixes based on the current clangd version. Change-Id: I7dca69ff990ab9f1a691785cd72e633f7882ae3d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CppEditor: Add curly braces for more control statementsChristian Kandeler2024-02-151-33/+76
| | | | | | | | Fixes: QTCREATORBUG-24542 Change-Id: I3e0893e1c736730d94e2c9ab2baa0aa580393fe4 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Merge remote-tracking branch 'origin/13.0'Eike Ziller2024-02-141-14/+19
|\ | | | | | | Change-Id: Iaf7373d449668bba57e53810858b58e2ec83dcc0
| * CppEditor: Support wrapping strings in QByteArrayLiteral()Christian Kandeler2024-02-071-14/+19
| | | | | | | | | | | | | | Fixes: QTCREATORBUG-12995 Change-Id: I9c0136b93fcfde0d2326bbd2bd6dbd5e75ae97a8 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | CppEditor: Add quickfix for converting a function callChristian Kandeler2024-02-071-25/+168
|/ | | | | | | | ... to a Qt meta-method invocation. Fixes: QTCREATORBUG-15972 Change-Id: Id84c83c5832cef32a877a451b0931ec47d2afe9d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* LookupContext: Replace QSharedPointer with std::shared_ptrJarek Kobus2024-02-061-10/+10
| | | | | | | | According to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews QSharedPointer impl is poor and it's going to be removed from Qt 7. Change-Id: Ia7ec4b427c5971d6bd375659b291a9aad2ead253 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Various plugins: Fix some more C++20 warnings about [=] capturesJarek Kobus2024-02-061-2/+3
| | | | | | Change-Id: If20aac4320c84096a07d67cc137886638286acf8 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* FunctionDeclDefLinkFinder: Replace QSharedPointer with std::shared_ptrJarek Kobus2024-02-051-3/+3
| | | | | | | | | According to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews QSharedPointer impl is poor and it's going to be removed from Qt 7. Change-Id: I41b753f52d06bb35988d1a57478e06daaec04f31 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Hide most of LineForNewIncludeDirective implementationhjk2024-02-021-5/+4
| | | | | Change-Id: Ic70d28beb057359fcd028aca2ab49ecb66dd990d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Fix & simplify "extract function" quickfixChristian Kandeler2024-01-301-26/+8
| | | | | | | | | No need to fiddle with whitespace manually (and make potentially invalid assumptions about previously inserted code). RefactoringFile takes care of formatting these days. Change-Id: I6e566e6e4cd2a90b73c29365483b92f94e8c58ce Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Add formatting information to ChangeSet::EditOpChristian Kandeler2023-12-131-17/+4
| | | | | | | | | | | ... and make use of that in TextEditor::RefactoringFile. This allows calling code to have fine-grained control over which parts of a refactoring should get re-formatted, while also providing sensible default values that are "almost always" right, so things typically work as expected out of the box. Change-Id: I9200c2135b7477c33bc5a61c5d410b34853e4b61 Reviewed-by: David Schulz <david.schulz@qt.io>
* CppQuickFixes: Make lambda non-mutableJarek Kobus2023-12-121-1/+1
| | | | | Change-Id: I13a1aadfab05e18d833f3b21240be49fdf4ce06d Reviewed-by: David Schulz <david.schulz@qt.io>
* CppEditor: Allow tests to run with ClangCodeModel enabledChristian Kandeler2023-11-291-63/+68
| | | | | | | | | | So that in the CI we can simply run: $ qtcreator -test CppEditor -load ClangCodeModel There are some failures left, which we will tackle one by one in follow- up patches. Change-Id: Ic4ebcb82f6439b344ae055889a6a16d56b2e3206 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Merge remote-tracking branch 'origin/12.0'Eike Ziller2023-11-271-1/+3
|\ | | | | | | | | | | | | | | | | Conflicts: cmake/QtCreatorIDEBranding.cmake qbs/modules/qtc/qtc.qbs src/plugins/cppeditor/cppeditorwidget.cpp Change-Id: I618826eaea8acfa65148bd191a0263454bf50e43
| * CppEditor: Fix comment conversion for indented commentsChristian Kandeler2023-11-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | Due to accidentally overlapping removal/replace operations, it could happen that we lost actual content when trying to remove whitespace. Amends f93836b25d57fed5888b1376e1e1b2d084fcb98d. Change-Id: I7a624e78cf0986ee9818d47ea0812c6632426a24 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>
* | TextEditor: Get rid of extra indent ranges in RefactoringFileChristian Kandeler2023-11-221-44/+23
| | | | | | | | | | | | | | | | | | | | Having extra indent regions complicates the interface, the implementation and the calling code. Instead, derive the indent regions from the change set and let callers opt out for the relatively few cases where indentation is not desired. Change-Id: I49d2854830a51778534ef260fb5c9f2c7685554a Reviewed-by: David Schulz <david.schulz@qt.io>
* | TextEditor: Make RefactoringChanges::file() virtualChristian Kandeler2023-11-171-48/+48
| | | | | | | | | | | | | | | | | | More preparation for de-virtualization of RefactoringChangesData. Change-Id: Ib5f7782a8dcaa2ae093b62aebedbd7bae9d4c3f1 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>
* | Merge remote-tracking branch 'gerrit/12.0'Eike Ziller2023-11-151-5/+10
|\| | | | | | | | | | | | | Conflicts: src/plugins/texteditor/texteditor.cpp Change-Id: I76620975760a8f9e64f6d381c948d457e949a87c
| * CppEditor: Fix the lookUpDefinition() functionChristian Kandeler2023-11-141-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | ... that tells us whether we need to offer the "add #include" quickfix. If we encounter a forward declaration, we cannot return yet, as a proper declaration might still show up. Fixes: QTCREATORBUG-29883 Change-Id: Ie1b831b9414043c3fc0d5d1e914b6096957757e6 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>
* | Merge remote-tracking branch 'origin/12.0'Eike Ziller2023-11-101-2/+43
|\| | | | | | | Change-Id: Ib9f8b81d60162a8b01e7c627ba54901af68afa98
| * CppEditor: Manually indent moved commentsChristian Kandeler2023-11-091-2/+43
| | | | | | | | | | | | | | | | | | Using the indenter yields unepected results in certain contexts. Fixes: QTCREATORBUG-29786 Change-Id: Id15eff841d2aa54e7fff65c6bf728516e03f9fc6 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | QuickFix: Fix add definition for templated functionArtem Sokolovskii2023-11-091-5/+22
| | | | | | | | | | | | | | | | | | | | - Fix add definition for templated function in templated class - Fix "inline" placement for templated function Fixes: QTCREATORBUG-29408 Change-Id: I15f7793c9ae1e49d8338c1120135ddd1afbca4ca Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | ClangCodeModel: Fall back to built-in code model when following symbolsChristian Kandeler2023-11-091-1/+3
| | | | | | | | | | | | | | | | | | | | In normal interactive mode, users likely want fuzzy look-up, e.g. to a non-matching overload if no exact match is present. Fixes: QTCREATORBUG-29814 Change-Id: I55ca32c001e619d374cc015a7dd2f1564ed2a2c9 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
* | Merge remote-tracking branch 'origin/12.0'Eike Ziller2023-10-241-4/+4
|\| | | | | | | Change-Id: I04104ef638b28d99da11b9b7a22f31f8d0ddf460
| * Tr: More small fixesEike Ziller2023-10-181-4/+4
| | | | | | | | | | | | Change-Id: I5d9324d3f64eaa522fa1d435efa39fa43d84798a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* | CppEditor: Special handling for included header corresponding to sourceChristian Kandeler2023-10-191-1/+1
| | | | | | | | | | | | | | | | ... when inserting additional header files. Fixes: QTCREATORBUG-21826 Change-Id: I1b62f8a9ee3fbc222fc8ee23e840d3c55cbee390 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | CppEditor: Add a second variant of "move def to decl" quickfixChristian Kandeler2023-10-091-10/+90
|/ | | | | | | | | This time with the cursor on the declaration. Fixes: QTCREATORBUG-9515 Change-Id: I50b2ac8516f4df98e4cc9e3ffa60a9e5cf079c4e Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Add quickfix for moving function documentationChristian Kandeler2023-09-071-0/+161
| | | | | | | | | ... 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>
* CppEditor: Consider comments when extracting a new functionChristian Kandeler2023-09-041-0/+11
| | | | | | | | | | 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>
* CppEditor: Add quickfix for converting comments from C++ to C styleChristian Kandeler2023-08-081-0/+226
| | | | | | | | | ... 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>
* CppEditor: Add context object into connectionsJarek Kobus2023-08-031-4/+4
| | | | | | Change-Id: I1a74f62b0a42ea4971b14fb82213f662b5fe4736 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CPlusPlus: Remove TranslationUnit::getTokenStartPosition()Christian Kandeler2023-07-131-1/+1
| | | | | | | | 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>
* CppEditor: Make a few CppModelManager functions statichjk2023-07-121-4/+3
| | | | | | | ... to simplify code using it. Change-Id: Ib2bfbb5a17a1d48088a9cf4973d4c3f006cd34e4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Add test case for quickfix formattingChristian Kandeler2023-06-291-0/+9
| | | | | | | | | | 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>
* Fix occurrences of the contains/insert anti-patternChristian Kandeler2023-06-231-2/+1
| | | | | | | | | 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>
* CppEditor: Make generated function const, if necessaryChristian Kandeler2023-06-161-8/+12
| | | | | | | | | ... 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>
* CppEditor: Add quickfix for creating a member function from useChristian Kandeler2023-05-161-70/+183
| | | | | | | Fixes: QTCREATORBUG-10356 Change-Id: If7376e766f2817949259591560c74bd6fb0e0cd6 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Merge remote-tracking branch 'origin/10.0'Eike Ziller2023-05-111-1/+2
|\ | | | | | | Change-Id: I98e5e1ad43103984b490c65cdeed84b7414303b3
| * CppEditor: Fix an error raised by Clang 16hjk2023-05-101-1/+2
| | | | | | | | | | | | | | | | 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>
* | CppEditor: Refactor "insert member from use" quickfixesChristian Kandeler2023-05-081-102/+57
| | | | | | | | | | | | | | | | | | 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>
* | CppEditor: Add quickfix adding a member declaration from assignmentChristian Kandeler2023-05-031-61/+232
| | | | | | | | | | | | | | Fixes: QTCREATORBUG-1918 Change-Id: I92c409ba0831edb056d23ae3244f5155876c039b Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* | CppEditor: Merge two factoriesChristian Kandeler2023-04-261-52/+55
| | | | | | | | | | | | | | | | 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>
* | C++ editor: Make generated Q_PROPERTYs FINAL by defaultUlf Hermann2023-04-201-1/+1
| | | | | | | | | | | | | | | | | | 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>
* | CppLocatorData: Introduce findSymbolsJarek Kobus2023-04-041-38/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | CppQuickFixes: Add lacking calls to prepareSearch()Jarek Kobus2023-03-161-1/+4
| | | | | | | | | | | | | | Before matchesFor() are called. Change-Id: I6acc9b39c5fd9c500312fa1863456d4e71e50165 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | ProjectExplorer: Move some not-fully-session related bitshjk2023-03-011-2/+2
|/ | | | | | | | | | | | | | | ... 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>
* CppEditor: Initialize member in GetterSetterRefactoringHelperOrgad Shaneh2023-01-301-3/+2
| | | | | | | Reported by Coverity. Change-Id: I0b6a1a36a33fe9b1cd81d2b314c80f42054d3d11 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Convert to Tr::trAlessandro Portale2023-01-121-151/+110
| | | | | | Change-Id: Ic4025e06e17c45eb6dc2162fb7f21f5b8aebe84d Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>