Commit Graph

243 Commits

Author SHA1 Message Date
Artem Sokolovskii
dea72a4003 CppEditor: Remove foreach / Q_FOREACH usage part 2
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>
2022-05-09 13:30:46 +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
3cdec51eaf CppEditor: Properly handle function types as template arguments
... 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>
2022-04-07 08:20:22 +00:00
Christian Kandeler
c2c8b137c0 CppEditor: Ensure a space between ref qualifier and exception spec
Task-number: QTCREATORBUG-27132
Change-Id: Iedb983f58ece345d5997607d2e557e36c951750f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-04-05 12:59:49 +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
cb86ca547a CppEditor: Fix "move function definition"
... 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>
2022-04-05 11:38:46 +00:00
Christian Kandeler
f6c974fc1b CPlusPlus: Fix "Find references"
... 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>
2021-11-09 08:51:31 +00:00
Christian Kandeler
05e698a478 CppEditor: Fix "insert def from decl" for template return types
Fixes: QTCREATORBUG-26397
Change-Id: Ia215f2c2b5da708b0fd7c894987683b305f4ccec
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-10-27 11:23:36 +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
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
Christian Kandeler
8c7dcc44b9 CppEditor: Merge the four TestDocument classes
Change-Id: Ie3d5a4ac2b8e3beee92f5abb88583c845056842e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-08 13:17:20 +00:00
Eike Ziller
8e51295959 Merge remote-tracking branch 'origin/5.0'
Conflicts:
	src/libs/utils/processreaper.cpp
	src/plugins/clangcodemodel/clangmodelmanagersupport.cpp
	src/plugins/cmakeprojectmanager/cmakeprocess.cpp

Change-Id: Ie248bcb02a80f3e02ab19d73033ce2ba31e7fd83
2021-09-07 11:05:40 +02:00
Christian Kandeler
72d52f3ac2 CppEditor: Un-export some classes
Change-Id: I285fe7bd3ac835c4a43f0a200dd7905f577ff211
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-06 14:48:17 +00:00
Christian Kandeler
0a7aca5a71 CppEditor: Remove class CppEditor
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>
2021-09-03 11:10:26 +00:00
Artem Sokolovskii
83e926f1cd CppEditor: Fix space issue for auto generated Q_PROPERTY
Change-Id: I3744ecfc18c7291666f346ea7b047ee749672e05
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-03 08:37:25 +00:00
Artem Sokolovskii
17c6fb866c CppEditor: Add property name to the generated signal
Task-number: QTCREATORBUG-26184
Change-Id: I4689dfb8b74de154092b7916188159432a5c827d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-02 14:02:38 +00:00
Christian Kandeler
284817fae6 Merge CppTools into CppEditor
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>
2021-09-01 14:53:58 +00:00
Christian Kandeler
25ff15a1fb Add convenience functions for creating ProjectExplorer::HeaderPaths
Change-Id: I7b1f63caca6b70ba4ec1b1870b83cbf20aa6564a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-30 10:46:56 +00:00
Christian Kandeler
5fe3ead73e CppTools/CppEditor: Rename the TestDocument classes
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>
2021-08-30 08:21:57 +00:00
Christian Kandeler
59d2f96cf8 CppEditor: Use test objects to group related test functions
Change-Id: I65089f2a00d8d168f123becf160f82bfcca4c68c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-27 13:46:45 +00:00
Christian Kandeler
d7717f1eca CppEditor: Fix "insert definition" for templates with value parameters
Fixes: QTCREATORBUG-26113
Change-Id: I2d2a1c1bdcffd67072bbda99dabbbfbfafe115c5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-17 08:35:35 +00:00
Christian Kandeler
b152f3ace8 CppEditor: Do not produce invalid code when escaping string literals
Fixes: QTCREATORBUG-26003
Change-Id: Ie4d0ae85cc0ae2d1d45ae0bedbf0212d217aa69b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-02 14:29:39 +00:00
Christian Kandeler
2798c11d1d CppEditor: Fix switch statement completion
... 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>
2021-07-29 10:28:14 +00:00
Christian Kandeler
c5d080570b CppEditor: Fix moving function definition out of specialized class
Fixes: QTCREATORBUG-25808
Change-Id: I5950c7f66b736c6ee30411e8fdc0356d78faa518
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-29 09:27:21 +00:00
Christian Kandeler
ff0301635e CppEditor: Tweak test infrastructure
... 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>
2021-06-02 10:52:50 +00:00
Andy Shaw
df540d5611 Remove the inline keyword when moving implementation to cpp
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>
2021-04-27 10:21:41 +00:00
Christian Kandeler
24eb796231 CppEditor: Fix "Add Definition" quickfix for function parameters
... whose type is a template.

Fixes: QTCREATORBUG-25560
Change-Id: I1d626f9376e8802a87ca1a28099932ccbf744d47
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-09 07:43:19 +00:00
Christian Kandeler
b066b3029e CPlusPlus: Improve type name minimization
... 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>
2021-02-22 11:16:49 +00:00
Alessandro Portale
395e7cbfb9 CppEditor: Default to .cpp for QuickFix creation of 1-line setter/getter
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>
2021-02-11 16:05:25 +00:00
Christian Kandeler
e740295b8d CplusPlus: Fix minimal name construction
... 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>
2021-02-09 16:56:12 +00:00
Christian Kandeler
33d2d736ea CppEditor: Do not add redundant access specifier
... when inserting a member function declaration for a definition.

Fixes: QTCREATORBUG-5591
Change-Id: Ie85b435a1595832d0085abdcc0a4187d939820e0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-08 15:19:31 +00:00
Leander Schulten
29207e3eeb CppEditor: Add Base Class Support for Generate Constructor QuickFix
Change-Id: Idd92229134609c0ac87aad030a6bb645ff4cce1b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-02-04 11:40:05 +00:00
Christian Kandeler
feefe3585f CppEditor: Make "Complete switch statement" quickfix more visible
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>
2021-02-04 11:19:53 +00:00
Christian Kandeler
aae3ce15aa CplusPlus: Fix minimal name construction
... 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>
2021-01-29 14:21:46 +00:00
Christian Kandeler
e5982d9c3d CPlusPlus: Revert name minimization fix
This effetively reverts 87ec0f349f, which had unwanted side effects.

Change-Id: I03438c18f43b07a6560416af746132bc4471fbb7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-29 09:37:34 +00:00
Christian Kandeler
87ec0f349f CplusPlus: Fix minimal name construction
... when using declarations are involved.

Fixes: QTCREATORBUG-14524
Change-Id: I0c391b88628f40973b6f601e60c64263f62a88a0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-28 14:31:49 +00:00
Christian Kandeler
667d50e1bc CppEditor: Fix "add definition" quickfix insertion string
... for the edge case of the insertion location being preceded by a
function whose body is a try-catch clause.

Fixes: QTCREATORBUG-14661
Change-Id: Icc7d5283ead81d644231479317214a8cc177493d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-28 14:30:20 +00:00
Leander Schulten
8192f7f4f4 CppEditor: Make it possible to specify default values in generate constructor quickfix
Change-Id: If73b4bdad1e3878091378d800bec2f1682a55c9f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-19 13:48:46 +00:00
Leander Schulten
1342500fb0 CppEditor: Make it possible to change the order of parameters in the Generate Constructor Quickfix
Change-Id: Iacdf1d660f50a85c18bc48db842bf45ebccf686e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-18 11:46:32 +00:00
Leander Schulten
c960f279e6 CppEditor: Add QuickFix to generate a constructor
Change-Id: Iba2ce3bfa1a1d1a325626a21f46b485d12cbb060
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-11 14:59:40 +00:00
Eike Ziller
8d67dd57e8 Merge remote-tracking branch 'origin/4.14'
Change-Id: I5e138bb7883c0436fee14ca6af20e99396676af1
2020-11-20 13:00:37 +01:00
Leander Schulten
993b614d94 CppEditor: Remove using namespace quickfix: Don't insert inline namespaces
Change-Id: If386d31de723ca928d3c50f55e32205c50937b0a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-11-19 18:35:05 +00:00
Eike Ziller
5ca70bdcb3 Merge remote-tracking branch 'origin/4.14'
Change-Id: Iea84f23cf394de13e99a9ed777c8c113e4eff473
2020-11-19 15:38:13 +01:00
Leander Schulten
92667c779c CppEditor: Remove using directive at global scope always in all files
Previously only using directives in the global scope that followed the
quickfixed using directive were removed

Change-Id: I330acfe3236a6845fd1667f9fa699ab6c8fb560d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-11-16 13:55:27 +00:00
Eike Ziller
381c5656e7 Merge remote-tracking branch 'origin/4.14'
Conflicts:
	src/plugins/mesonprojectmanager/project/mesonprojectparser.h

Change-Id: Id38d20ce20981dcdc322fe5d1d7647f4bec89d8a
2020-11-13 16:03:26 +01:00
Christian Kandeler
3cd2e2c445 CppEditor: Improve "definition from declaration" for templates
- Make sure the template parameters are included in the definition.
- Find the correct insertion location when using an already-defined
  template member function as an anchor.

Fixes: QTCREATORBUG-24848
Change-Id: I1272ba36403904e7aed81bcef48745793c5e2217
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-13 12:49:51 +00:00
Eike Ziller
724fd58a3b Merge remote-tracking branch 'origin/4.14' into master
Conflicts:
	src/plugins/cppeditor/cppquickfix_test.cpp

Change-Id: I470ee35f54f883244d819531131c172bd25c0e3f
2020-10-29 09:18:31 +01:00
Christian Kandeler
d2ebc16b92 CppEditor: Fix "move definition" quickfix for template member functions
There are a lot more problems in this area (e.g. with nested classes),
but let's tackle them one by one.

Fixes: QTCREATORBUG-24801
Change-Id: I4b3805ea6f8b28373925693650150bbd89508096
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-28 12:41:26 +00:00
Christian Kandeler
0ebb004d85 CppEditor: Make "Complete Switch" quickfix work with enum classes
Fixes: QTCREATORBUG-20475
Change-Id: Id21a007ab4b652dcfe49d97bfa4c9fa77bacf8c4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-27 11:40:37 +00:00
Christian Kandeler
f515672ffd CppEditor: Offer class-level quickfixes also when clicking "in class"
That is, allow the cursor to on some "neutral" place in the body of the
declaration, not only strictly on the class name.

Fixes: QTCREATORBUG-15699
Change-Id: I74ad6048c16c19d418446c990178535d878fc630
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-23 10:27:49 +00:00