Commit Graph

411 Commits

Author SHA1 Message Date
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
Christian Kandeler
98499e7caa CppEditor: Do not offer generated QObject functions
... in "create implementations" quickfix.

Change-Id: Ie8aa00e432afdf1338d4897ad211c15fef753404
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-04 14:19:04 +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
Eike Ziller
9c6108afd1 Merge remote-tracking branch 'origin/4.14' into master
Change-Id: Ib4363db8e71488e1d13e8c1012023abfaf06286b
2020-10-22 14:38:01 +02:00
Christian Kandeler
135e76f965 CppEditor: Offer InsertDefsOperation quickfix for all classes
The check whether there are unimplemented member functions takes quite
long, so Creator would freeze for several seconds when right-clicking on
the name of even a medium-sized class.
Therefore, we offer the operation for all classes with member functions
and move the expensive check into the perform() method.

Change-Id: Ie19958ba8c53493be859f9982d7d5697e6e9d88b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-21 08:19:25 +00:00
Eike Ziller
dbb6201605 Merge remote-tracking branch 'origin/4.14' into master
Change-Id: Id7ad82997873da828456a15c441620d93c6fc7e7
2020-10-21 09:31:01 +02:00
Christian Kandeler
2b5e1ea62e CppEditor: Fix some "convert to camel case" edge cases
Fixes: QTCREATORBUG-16560
Change-Id: I8573ae6c5dce0956c868addc69a921c62f1d571a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-20 13:27:54 +00:00
Eike Ziller
80951d3e59 Merge remote-tracking branch 'origin/4.14' into master
Conflicts:
	src/plugins/cppeditor/cppquickfix_test.cpp

Change-Id: Ib2984a3b3d9d071d11304b6cf132c2f8cef77e1c
2020-10-19 15:22:37 +02:00
Leander Schulten
5b5ae97104 CppEditor: Introduce QuickFix settings and unify getter/setter generation
Introduces a QuickFix settings page where the generation of getters and
setters can be customized. The settings can be saved into a file that can
go into a VCS. All QuickFixes that generate getter/setter/signals/
Q_PROPERTIES now use the same backend. QuickFixes that generate getters/
setters are now extended to also generate signals and Q_PROPERTIES.

Fixes: QTCREATORBUG-1532
Fixes: QTCREATORBUG-17941
Fixes: QTCREATORBUG-12678
Fixes: QTCREATORBUG-15779
Fixes: QTCREATORBUG-11620
Fixes: QTCREATORBUG-22707
Fixes: QTCREATORBUG-20157
Fixes: QTCREATORBUG-21804
Fixes: QTCREATORBUG-19814
Fixes: QTCREATORBUG-14622
Fixes: QTCREATORBUG-19803
Change-Id: I50ed2dad9b4a637fbd87b3e1f2856060ad0ad920
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-14 10:12:44 +00:00
Leander Schulten
15f39cf37c CppEditor: Fix Typedef Handling with 'Remove Using Directive' QuickFix
Previously, typedefs were ignored and the new code became invalid after
applying the quickfix.

Change-Id: I0d4295e90d02dfacc3edac5ac3f96d9edbeaf662
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-12 14:34:54 +00:00
Christian Kandeler
023a77ea80 CppEditor: Consider templates in "complete switch" quickfix
Fixes: QTCREATORBUG-24752
Change-Id: I39bc007e5f493a9826adb4575eb210bf9ec21159
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-12 09:01:29 +00:00
Leena Miettinen
1fcac114a3 Doc: Describe new refactoring actions (quick fixes)
Fix capitalization of action names.

Task-number: QTCREATORBUG-24529
Change-Id: I021717bbae237dd293bdbd56d5e10407ee12f224
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-07 12:54:25 +00:00
Eike Ziller
830a829b2e Fix build of Clang code model and CppEditor with Qt 6
QStringRef gone.
QSharedPointer is no longer auto-converted to bool.
Small things.

Task-number: QTCREATORBUG-24098
Change-Id: I3a2a55459b905118d1ca81ec015d741ab273471d
Reviewed-by: hjk <hjk@qt.io>
2020-09-21 07:21:48 +00:00
David Schulz
dba4bff703 TextEditor: use Utils::FilePath as file member in AssistInterface
Change-Id: I3bf9b013b9350411f918efdb9d1a36a2c22bf972
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-09-04 10:14:21 +00:00
Leander Schulten
32ee29cb9e CppEditor: Implement remove using namespace Quickfix
Fixes: QTCREATORBUG-24392
Change-Id: Iaf4df4ebf161a4a757f59f22e692e0f9b99cd63c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-08-12 13:32:20 +00:00
Christian Kandeler
d9eb3dc5a4 CppEditor: Do not re-indent existing code
... in "Complete Switch Statement" quickfix.

Fixes: QTCREATORBUG-12445
Change-Id: Ic168f5b434b81d2b5f5a0d344d6c6786a75d07a5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-08-10 12:02:11 +00:00
Christian Kandeler
77d13f08ba CppEditor: Let users create implementations for all member functions
... in one go.

Fixes: QTCREATORBUG-12164
Change-Id: Ifc81c8b1caf4319ce57882375f513d72e4c0ea52
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-29 11:56:07 +00:00
Leander Schulten
fdd70d898d CppEditor: Don't create 'namespace xyz{}' if there is 'using namespace xyz'
Change-Id: Idc08de5f44ccac0de8490158199c4e44f7efe79e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-07-28 09:53:48 +00:00
Christian Kandeler
73f3056c3e CppEditor: Add class member from member initialization
That is, if a class member being initialized is not yet declared, offer
to add the declaration.

Fixes: QTCREATORBUG-11842
Change-Id: I1d2a56ab99543e996e220aa26b7923023dd163f7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-23 12:57:29 +00:00
Christian Kandeler
e4100c31fc CppEditor: Fix trailing whitespace after extracting a function
... from a block of code.
We must not insert an empty line into the newly created function,
because it gets indented in the first indent operation, resulting in
trailing characters after the actual code has been inserted later.

Fixes: QTCREATORBUG-12118
Change-Id: If438d4de379cae90baa846c112866f2777b44fce
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-23 09:00:44 +00:00
Christian Kandeler
affd4ee658 CppEditor: Extend Q_PROPERTY quickfix
... to also generate the RESET function.

Fixes: QTCREATORBUG-11809
Change-Id: I94789227230a67f074ff5fdc76ad8113d2870dd6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-22 07:46:11 +00:00
Christian Stenger
1e0b82e77d CppEditor: Fix possible wrong location for function definitions
Having no namespace when inserting generated functions may insert
explicitly at the end of a header which is not always desired as we
need to take care of e.g. header guards as well.

Change-Id: I3b154ae936a96f2f8e7e34cda6b5bcdfcbc83faf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-16 11:11:58 +00:00
Christian Kandeler
9fa1286faf CppEditor: Ensure "inline" specifier
... when creating functions in header files. Otherwise, we will likely
cause linker failures in non-trivial projects.

Fixes: QTCREATORBUG-15052
Change-Id: Ic0fff8779ba924f8b9943ab233a0cda409e73e9d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-15 08:04:43 +00:00
Christian Kandeler
bfd49fe5ce CppEditor: Ensure proper namespace for new getter/setter functions
If the class is in a namespace and the cpp file does not yet have any
implementations in that namespace, then we would erroneously put the
getters in the global namespace.

Fixes: QTCREATORBUG-14886
Change-Id: I836537abddfdd92ced783d60e1226b082bbc238e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-14 14:32:40 +00:00
hjk
5937fa009f CppEditor: Avoid a use of QCharRef to make it compile with Qt6
Task-number: QTCREATORBUG-24098
Change-Id: If857b6e473f7df7303621695ffc0a66ad777bd7c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-07-14 05:56:45 +00:00
Christian Kandeler
e210bcf3eb CppEditor: Offer to create getters and setters for all class members
Fixes: QTCREATORBUG-14504
Change-Id: I12c687492b12c6997064eb7f137b6ccb189d2009
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-10 08:07:16 +00:00
Christian Kandeler
5b3aece387 CppEditor: Make "Add curly braces" quickfix more robust
Anchor the opening brace at the closing parenthesis, rather than at the
statement. This way, we won't get troubled by macro weirdness in the
statement part.

Fixes: QTCREATORBUG-13921
Change-Id: I05af24d1642e6b62c78bb2f47a1ef0b1fea326d0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-07 14:13:37 +00:00
Christian Kandeler
11a7ccb865 CppEditor: Relax soft assert
The look-up results are ordered by precedence and we can just use the
first one; there doesn't seem to be a reason that additional results
should stop the operation.

Fixes: QTCREATORBUG-14531
Change-Id: Ibe12f975f87ae0d526299219ff54492bef34065c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-06 08:42:51 +00:00
Christian Kandeler
e100939ba7 CppEditor: Extend "Add Include" quickfix
... so it works for all kinds of symbols, not just Qt classes.

Fixes: QTCREATORBUG-21
Change-Id: I2d329c09b64cd8f7eef8cce7d9f022aca8586c0d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-05 14:56:21 +00:00
Christian Kandeler
d811e7773f CppEditor: Do not treat friend declaration as member function
... when trying to create definitions from declarations.
Instead, we completely ignore friends in this context, arguing that the
respective function normally should have a proper declaration somewhere
else.

Fixes: QTCREATORBUG-7164
Change-Id: I3ddb89cefecbc494f9c7e63600b65fd6288b7169
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-05 14:51:18 +00:00
Christian Kandeler
9e08ecb816 CppEditor: Fix access to dangling pointer
Found by coverity.

Change-Id: I4b73af9b22b80953b4ba6c1004884862c9bdd3b8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-06-04 07:20:50 +00:00
Christian Kandeler
c8d7c074f5 CppEditor: Consider namespaces in "extract function" quickfix
Fixes: QTCREATORBUG-23256
Change-Id: I99b1271907767c3607e35adb49bd4109f3eca18c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2020-05-29 09:02:49 +00:00
Christian Kandeler
6c4b8b10b7 CppEditor: Add quickfix for creating a forward declaration
In header files, a forward declaration is often preferable to including
another header file, so let's offer this as a quickfix.

Fixes: QTCREATORBUG-23444
Change-Id: Ib50550abb5337098e4122e65e2af42a66742d6f6
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2020-05-27 13:25:19 +00:00
Eike Ziller
0f30adcc8c Merge remote-tracking branch 'origin/4.11'
Change-Id: I949f4f63abe12e11c4598c98295bfccc82e0ebdb
2020-01-09 11:18:44 +01:00
David Schulz
1ab9dc9464 CppEditor: generate valid code via "Convert to Pointer/Stack Variable"
Adding a "= new <TypeName>" after converting a stack variable without
assignment or initializer to pointer.
Also remove the assignment when converting from pointer to stack
variable as this works better with explicit constructors.

Fixes: QTCREATORBUG-23181
Change-Id: I377ec32a1b66cf4b96db14cfcb4b71fb96c80c98
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-01-08 09:21:25 +00:00
hjk
e109b731ad Utils: Rename FilePathList to simply FilePaths
The exact storage type does not really matter here.

Change-Id: Iefec40f0f5909c8e7ba3415db4a11962694e1b38
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-12-18 08:43:18 +00:00
Nikolai Kosjar
d337d03ce1 CppEditor: Simplify
bugprone-branch-clone
readability-simplify-boolean-expr

Change-Id: Id30a155e224370713d23b4b534fb82f5e630f36c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-11-01 09:21:29 +00:00
Nikolai Kosjar
c2d36c9387 CppEditor: Fix reference to temporary
Change-Id: I3e2d7cb046e645e03ce5da7f18c48d6ce05fc76a
Reviewed-by: hjk <hjk@qt.io>
2019-08-01 08:14:06 +00:00
Antonio Di Monaco
545b0537ae Skip pure virtual functions in "Insert Definition From Declaration"
Pure virtual functions do not need a definition.

The issue is that, when the codebase is very huge (hundreds of thousands
of files), the match method starts exploring the whole codebase,
searching for an already present definition that will never be found,
so the QuickFix wastes time for nothing and freezes the UI.

Change-Id: Ia17740d740afcb40ec4f1b3237d8b9f5c1e3d54c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-07-29 09:28:02 +00:00
hjk
e3b1106afa Compile fix with recent Qt dev
The reasoning in 1b4766e26c did not take into account that the scope
of QT_NO_JAVA_STYLE_ITERATORS may change over time, as done with
f70905448f6 in Qt base.

Change-Id: Ib1966ff26c4d36d5f62e149d6b45baa4aecf825d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-29 08:54:18 +00:00
hjk
7ab6783e24 Standardize on int for line and column values
Recently tons of warnings show up for presumably "problematic"
singned <-> unsigned and size conversions.

The Qt side uses 'int', and that's the biggest 'integration surface'
for us, so instead of establishing some internal boundary between
signed and unsigned areas, push that boundary out of creator core code,
and use 'int' everywhere.

Because it reduces friction further, also do it in libcplusplus.

Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-07-26 09:23:48 +00:00
hjk
0ec860009a Replace uses of QString::sprintf()
There are patches appearing on gerrit for Qt 6 to remove the functions.

Change-Id: Ic189c0a19ddc0f84eb34a56c0861532303de5129
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-06-20 12:03:00 +00:00
hjk
473a741c9f Utils: Rename FileName to FilePath
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.

Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-28 12:23:26 +00:00
Nikolai Kosjar
e0c7722441 CppEditor: Modernize
modernize-orgad
modernize-return-braced-init-list
modernize-use-auto
modernize-use-default-member-init
modernize-use-equals-default
modernize-use-nullptr
modernize-use-override
modernize-use-using

Change-Id: Ifa862782fb7b56ed3f93d9f98685c3af616797c2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-02-08 08:39:58 +00:00
Nikolai Kosjar
55f4c28889 CppEditor: modernize-loop-convert
Change-Id: I80382880a3c35ef0b59729bd222a626bc5c4a32b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-08 07:52:23 +00:00