summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor/cppquickfix_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* CppEditor: Add quickfix for creating a member function from useChristian Kandeler2023-05-161-0/+116
| | | | | | | Fixes: QTCREATORBUG-10356 Change-Id: If7376e766f2817949259591560c74bd6fb0e0cd6 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Add quickfix adding a member declaration from assignmentChristian Kandeler2023-05-031-2/+119
| | | | | | | 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-2/+2
| | | | | | | | 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-11/+11
| | | | | | | | | 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>
* Remove GPL-3.0+ from license identifiersKai Köhne2023-01-061-1/+1
| | | | | | | | | | | | | | | 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>
* CPlusPlus: Do not try to qualify the names of template parametersChristian Kandeler2022-12-011-0/+22
| | | | | | | | | | These always appear as written. Task-number: QTCREATORBUG-28186 Change-Id: Iea8cc99ee6c17c1320817977fdb96ae1f730bc45 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>
* CppEditor: Another name minimalization fixChristian Kandeler2022-12-011-0/+33
| | | | | | | | | ... involving using declarations. See also aae3ce15aa72631e290b4eb6d0e163706b10390b. Fixes: QTCREATORBUG-28386 Change-Id: I4171dce7b4e34b41c4a894e3bb34b3f62f82ac0f Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Proliferate FilePath usehjk2022-11-221-2/+3
| | | | | | | | | | | | | | | | | | | 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>
* QuickFix: Fix generate function definition with unsigned typeArtem Sokolovskii2022-11-101-0/+89
| | | | | | | Fixes: QTCREATORBUG-28378 Change-Id: Ic94901e430d08aab22c8f4c394eda1f8a93398bc Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-9/+9
| | | | | | | | | | | | | | 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>
* CppEditor: Make value vs const ref return type configurableChristian Kandeler2022-09-191-0/+3
| | | | | | | | | | | | ... 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>
* Use SPDX license identifiersLucie Gérard2022-08-261-24/+2
| | | | | | | | | 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>
* CppQuickFixes: Add "auto" as local declaration incase cxx11Artem Sokolovskii2022-06-161-0/+10
| | | | | | | | | 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>
* CppEditor: Use "auto" in AssignToLocalVariableOperationChristian Kandeler2022-05-161-7/+7
| | | | | | | | | 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>
* CppEditor: Remove foreach / Q_FOREACH usage part 2Artem Sokolovskii2022-05-091-9/+9
| | | | | | | | Task-number: QTCREATORBUG-27464 Change-Id: I352bf37bd017e7381fbd7b050fbb55c9a73bd668 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>
* CppEditor: Do not crash on anonymous classesChristian Stenger2022-04-111-0/+52
| | | | | | | | | 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>
* CppEditor: Properly handle function types as template argumentsChristian Kandeler2022-04-071-0/+37
| | | | | | | | | | ... when creating getters and setters. Fixes: QTCREATORBUG-27133 Change-Id: Ia77147a270fb1229c765ff9d5f03aa243d51fe97 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>
* CppEditor: Ensure a space between ref qualifier and exception specChristian Kandeler2022-04-051-1/+1
| | | | | | | Task-number: QTCREATORBUG-27132 Change-Id: Iedb983f58ece345d5997607d2e557e36c951750f Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* CppEditor: Use trailing return type when moving function definitionChristian Kandeler2022-04-051-1/+1
| | | | | | | | | | ... 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>
* CppEditor: Fix "move function definition"Christian Kandeler2022-04-051-0/+35
| | | | | | | | | | | | | | | | | | | ... for member functions with exception specification and/or reference qualifiers. The FunctionDeclaratorAST::cv_qualifier_list member can contain both the proper qualifiers "const" and "volatile" as well as the pseudo-qualifiers "override" and "final". The problem is that the former appear before exception specification and reference qualifiers, whereas the latter come afterwards. Therefore, when calculating the declarator's first and last tokens, we can't just mechanically check the different declarator members in order. Instead, we need to compare the token values to see which comes first. Task-number: QTCREATORBUG-27132 Change-Id: I924f9afe49453fa51b4a2fe010d1cc00c9defad1 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>
* CPlusPlus: Fix "Find references"Christian Kandeler2021-11-091-0/+1
| | | | | | | | | ... for certain types of template/namespace combinations. This essentially reverts 2798c11d1d. Fixes: QTCREATORBUG-26520 Change-Id: I1ab0e4e19bd09695d1536bf6f10960107e9ecbc4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Fix "insert def from decl" for template return typesChristian Kandeler2021-10-271-0/+37
| | | | | | Fixes: QTCREATORBUG-26397 Change-Id: Ia215f2c2b5da708b0fd7c894987683b305f4ccec Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Mark generated setter as slot only for QObject-derived classChristian Kandeler2021-10-221-9/+18
| | | | | | Fixes: QTCREATORBUG-25789 Change-Id: I79174bcd617eb54540009491031cfae380383c41 Reviewed-by: David Schulz <david.schulz@qt.io>
* CppEditor: Fix "decl from def" quickfix with templated return typeChristian Kandeler2021-09-141-1/+23
| | | | | | | | | | 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>
* CppEditor: Merge the four TestDocument classesChristian Kandeler2021-09-081-302/+259
| | | | | | Change-Id: Ie3d5a4ac2b8e3beee92f5abb88583c845056842e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Merge remote-tracking branch 'origin/5.0'Eike Ziller2021-09-071-8/+8
|\ | | | | | | | | | | | | | | | | Conflicts: src/libs/utils/processreaper.cpp src/plugins/clangcodemodel/clangmodelmanagersupport.cpp src/plugins/cmakeprojectmanager/cmakeprocess.cpp Change-Id: Ie248bcb02a80f3e02ab19d73033ce2ba31e7fd83
| * CppEditor: Fix space issue for auto generated Q_PROPERTYArtem Sokolovskii2021-09-031-5/+5
| | | | | | | | | | Change-Id: I3744ecfc18c7291666f346ea7b047ee749672e05 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
| * CppEditor: Add property name to the generated signalArtem Sokolovskii2021-09-021-4/+4
| | | | | | | | | | | | Task-number: QTCREATORBUG-26184 Change-Id: I4689dfb8b74de154092b7916188159432a5c827d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | CppEditor: Un-export some classesChristian Kandeler2021-09-061-1/+1
| | | | | | | | | | Change-Id: I285fe7bd3ac835c4a43f0a200dd7905f577ff211 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | CppEditor: Remove class CppEditorChristian Kandeler2021-09-031-1/+0
| | | | | | | | | | | | | | | | It's not needed, and conflicts with the namespace of the same name in some contexts. Change-Id: I281025abbfad0feb602f006e3b997a8b9c308b48 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | Merge CppTools into CppEditorChristian Kandeler2021-09-011-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was no proper separation of responsibilities between these plugins. In particular, CppTools had lots of editor-related functionality, so it's not clear why it was separated out in the first place. In fact, for a lot of code, it seemed quite arbitrary where it was put (just one example: switchHeaderSource() was in CppTools, wheras switchDeclarationDefinition() was in CppEditor). Merging the plugins will enable us to get rid of various convoluted pseudo-abstractions that were only introduced to keep up the artificial separation. Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | Add convenience functions for creating ProjectExplorer::HeaderPathsChristian Kandeler2021-08-301-5/+3
| | | | | | | | | | Change-Id: I7b1f63caca6b70ba4ec1b1870b83cbf20aa6564a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | CppTools/CppEditor: Rename the TestDocument classesChristian Kandeler2021-08-301-1/+1
| | | | | | | | | | | | | | | | | | It was not helpful that we had four different classes with the same name. Note that they look suspiciously similar and could possibly be merged into a single class at some point. Change-Id: I7d4c10a09408226037bc0d276940bca39dc5f576 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | CppEditor: Use test objects to group related test functionsChristian Kandeler2021-08-271-128/+143
| | | | | | | | | | Change-Id: I65089f2a00d8d168f123becf160f82bfcca4c68c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | CppEditor: Fix "insert definition" for templates with value parametersChristian Kandeler2021-08-171-0/+21
|/ | | | | | Fixes: QTCREATORBUG-26113 Change-Id: I2d2a1c1bdcffd67072bbda99dabbbfbfafe115c5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Do not produce invalid code when escaping string literalsChristian Kandeler2021-08-021-0/+22
| | | | | | Fixes: QTCREATORBUG-26003 Change-Id: Ie4d0ae85cc0ae2d1d45ae0bedbf0212d217aa69b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Fix switch statement completionChristian Kandeler2021-07-291-0/+28
| | | | | | | | | ... for the case where the value is retrieved via a call to a template function whose scope does not include the template type. Fixes: QTCREATORBUG-25998 Change-Id: Ie33817f445fb53595b783f716093637926297549 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Fix moving function definition out of specialized classChristian Kandeler2021-07-291-0/+27
| | | | | | Fixes: QTCREATORBUG-25808 Change-Id: I5950c7f66b736c6ee30411e8fdc0356d78faa518 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Tweak test infrastructureChristian Kandeler2021-06-021-2/+2
| | | | | | | | | | | | | | ... so we can re-use the "follow symbol" test cases with clangd. Call Creator like this (clangd needs to be version 12 or later): $ QTC_CLANGD=<path to clangd> qtcreator -test 'CppEditor,*Follow*,*Switch*' -test 'ClangCodeModel,*dummy*' During testing, some invalid code in the test cases was uncovered and fixed. Change-Id: I9dc650fdba2a27600e6a550420ee873f6fb31d23 Reviewed-by: David Schulz <david.schulz@qt.io>
* Remove the inline keyword when moving implementation to cppAndy Shaw2021-04-271-5/+85
| | | | | | | | | | Since the implementation has been moved to the cpp file, then the inline keyword has to be removed otherwise it will cause a build error. Change-Id: I145bbaeb02674bd68501f1a41787bd4aa2a75f53 Fixes: QTCREATORBUG-20703 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Fix "Add Definition" quickfix for function parametersChristian Kandeler2021-04-091-2/+2
| | | | | | | | ... whose type is a template. Fixes: QTCREATORBUG-25560 Change-Id: I1d626f9376e8802a87ca1a28099932ccbf744d47 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Improve type name minimizationChristian Kandeler2021-02-221-0/+62
| | | | | | | | | | | ... for function parameters. These are located in the scope of the surrounding class or namespace. This uncovered a bug in the "Insert Virtual Functions of Base Classes" quickfix, which we also fix here. Fixes: QTCREATORBUG-8030 Change-Id: I7f11659dc8e252e3819df8178734e8958fa1b496 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Default to .cpp for QuickFix creation of 1-line setter/getterAlessandro Portale2021-02-111-20/+28
| | | | | | | | | | | | | | | | Until Qt Creator 4.14, the QuickFix for setter/getter creation for simple members added the implementation in the .cpp file. The new QuickFix settings in Qt Creator 4.15 in theory keep the default like before, but the threshold of 2 lines is usually not reached, which causes the getter/setter implementations to now land in the header file. This change sets the default threshold to 1 to restore the previous default behavior. Fixes: QTCREATORBUG-25331 Change-Id: I570deaa8b81686dc31254e8261b59ddcf8731f91 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CplusPlus: Fix minimal name constructionChristian Kandeler2021-02-091-0/+26
| | | | | | | | | ... when creating the constructor implementation for a derived class. We would erroneously strip off the class name. Amends aae3ce15aa. Change-Id: I62c800d490626e8cb9416829633f9ef7b0c666cd Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Do not add redundant access specifierChristian Kandeler2021-02-081-1/+4
| | | | | | | | ... when inserting a member function declaration for a definition. Fixes: QTCREATORBUG-5591 Change-Id: Ie85b435a1595832d0085abdcc0a4187d939820e0 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Add Base Class Support for Generate Constructor QuickFixLeander Schulten2021-02-041-0/+69
| | | | | Change-Id: Idd92229134609c0ac87aad030a6bb645ff4cce1b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Make "Complete switch statement" quickfix more visibleChristian Kandeler2021-02-041-0/+26
| | | | | | | | | Do not require the cursor to be on the "switch" keyword, but allow it to be anywhere within the switch construct. Fixes: QTCREATORBUG-5379 Change-Id: Ic25504237b3ef12958f339d7176dfeeac6bd3466 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CplusPlus: Fix minimal name constructionChristian Kandeler2021-01-291-3/+2
| | | | | | | | | | | | | | | | | | ... when using declarations are involved. Second attempt. I have a suspicion that this is not the "correct" approach, however: a) It appears to fix the problem. b) It does not break any tests. c) It's rather high in the call tree, so there's a low likelihood of breaking something else. d) Considering the hacky-looking pre-existing code dealing with using declarations (e.g. LookupContext::lookupByUsing()), it seems quite possible that there is no "correct" way with the current infrastructure. Fixes: QTCREATORBUG-14524 Change-Id: I28c6e53137c21ce158bbd03b92b3db39146116d5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Revert name minimization fixChristian Kandeler2021-01-291-1/+29
| | | | | | | This effetively reverts 87ec0f349f, which had unwanted side effects. Change-Id: I03438c18f43b07a6560416af746132bc4471fbb7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CplusPlus: Fix minimal name constructionChristian Kandeler2021-01-281-0/+35
| | | | | | | | ... when using declarations are involved. Fixes: QTCREATORBUG-14524 Change-Id: I0c391b88628f40973b6f601e60c64263f62a88a0 Reviewed-by: Christian Stenger <christian.stenger@qt.io>