Commit Graph

358 Commits

Author SHA1 Message Date
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
The Qt Project
934c0bc423 Merge "Merge remote-tracking branch 'origin/5.0'" 2021-09-07 10:06:01 +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
0b86b455b0 CppEditor: Put the locator filters into one file
These classes are strongly related, so no need to spread them around.

Change-Id: I4258b0c4198b3c650454ac734d7e52e09f46a4eb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-07 08:09:42 +00:00
Christian Kandeler
548e19370e CppEditor: Remove CppToolsBridge & friends
This redirection did nothing except to horribly obfuscate the code.
Note that most callers already accessed the model manager directly, and
some bridge functions were not called at all.

Change-Id: Ic1c728afe79bf98544da23a1955ee82d0dbde94f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-06 09:49:36 +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
a952500e90 CppTools: Use only const pointers for ProjectInfo and ProjectPart
All members were already const, but this makes it clear at all points of
use that these data structures are immutable.

Change-Id: Iea615c090bde462c445d15223caccc561b0c713d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-08-27 10:53:54 +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
4ff26e2a27 CppEditor: Do not rely on object identity when comparing names
In particular, the same namespace can be declared in lots of different
places.

Fixes: QTCREATORBUG-25776
Change-Id: I7e255cee560043ed4beb47b8047f99c3a9c21198
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-24 13:46:25 +00:00
David Schulz
79b9a2fea6 TextEditor: filepathify RefactoringChanges
Change-Id: Ie97e484bcdeaa0cb2f5d04b3c79ace55ff2e426c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-08 11:40:10 +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
ecafdb7543 ClangCodeModel: Add experimental clangd support
If the user has enabled clangd (default is off), we start up one instance
per project when it is opened/changed (including build config switches),
and trigger background indexing.
So far, the index is used to provide results for locators and "Find
Usages".
Per-document functionality such as semantic highlighting and completion
is still provided by libclang.

Change-Id: I12532fca1b9c6278baab560e7238cba6189cde9f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-22 07:32:58 +00:00
Eike Ziller
e9bf841dc9 Fix lupdate issues
Some wrong tr calls / missing tr functions.
Some places where we need to bring lupdate to the right track with
regard to namespace resolution.

Change-Id: Idf552054a34e24d9671db68c816bf37f4d403dbc
Reviewed-by: hjk <hjk@qt.io>
2021-03-22 15:00:37 +00:00
Leena Miettinen
4c58465b25 C++ Editor: Fix UI text to follow the guidelines
Change-Id: Icea20999410df78d01222d6ebcfb9cdd497d5068
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-03-18 10:24:19 +00:00
Alessandro Portale
72d91dc94a Use qAsConst with non-const Qt containers in range-loops
... in various places

Change-Id: Ic6c0c1b9437a1ed402105c7a14a1f5f9454a68d4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-02-17 14:43:29 +00:00
Christian Kandeler
8dc4cb17c1 Designer: Re-use CppTools functionality
... for slot insertion logic.

Fixes: QTCREATORBUG-8220
Change-Id: I3516a62d62174b64d557c82ce38a9cc334790efc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-12 14:16:14 +00:00
David Schulz
667f8563bc CppEditor: Move ast path checker to relevant quick fix provider
We have quick fix factories that do not require an ast path at the
cursor position nowadays, for example the quick fix factories that
provide fixes from the clang tools. Move the check to those factories
that rely on a valid ast.

Change-Id: Iab4b30d5935fbd32f101fb5fda60e994f14dc94c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-02-11 14:22:04 +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
Orgad Shaneh
2674e9c62e CppEditor: Fix MSVC warnings
Implicit size_t -> int conversions.

Change-Id: I8c792fb692d1c5f3572aa0037ca2f20192cdc903
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-02-08 08:46:28 +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
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
8082df491a CppEditor: Only generate valid identifiers in QuickFixes
Change-Id: Idcb3495f04627610eaf530dcb5d3b58429eda616
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-19 12:51:33 +00:00
Christian Kandeler
89ad72c789 CppEditor: Start renaming the new function parameter
... in the ExtractLiteralAsParameter quickfix. It's unlikely that the
user wants to keep the generic default name.

Fixes: QTCREATORBUG-25104
Change-Id: Ic354f20c27da43664bcb3c2839e981c176aaf821
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-18 16:13:33 +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
Christian Kandeler
887cb05b98 CppEditor: Fix renaming location for "optimize for loop" quickfix
Use the start of the variable name, not the end. It's more natural, and
it prevents problems with the clang code model, as isCursorOnIdentifier()
returns false if the cursor is after the last character of the name.

Change-Id: I368ccf5cef9c3fb04c0902e49f8a189c102c481f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-15 13:12:00 +00:00
Christian Stenger
fb64cb12bc CppEditor: Fix compile on Windows
Amends c960f279e6.

Change-Id: I87249b5cdd984c00e44fc21d32534174edea73d2
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-12 05:48:21 +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
8795ecbf5e CppEditor: Improve performance of QuickFix 'Remove using directive in global scope'
Change-Id: Id929255b5bf39a25b66ea18855b0c3c1f01720f0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-11-17 13:24:27 +00: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
1d2b5db02f Merge remote-tracking branch 'origin/4.14'
Change-Id: I2ae0eb18782224e48cd20d41907f9dfea6ee1771
2020-11-10 13:42:46 +01:00
Leena Miettinen
2bb1ff6077 CPP Editor: Fix UI text capitalization
Task-number: QTCREATORBUG-24873
Change-Id: I166b2aa8867e694d0b3ba1756edd0afc6e487211
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-11-09 09:07:19 +00:00