Doc: Add use cases for Add Curly Braces quick fix

- Update and add examples
- Make punctuation in the topic more consistent
- Add a link to the docs to the change log

Task-number: QTCREATORBUG-30604
Change-Id: I723af29117a4b35a70eed61058c5d43da285242d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Leena Miettinen
2024-06-14 13:08:05 +02:00
parent 625fd895ce
commit a3a543a55f
2 changed files with 68 additions and 16 deletions

View File

@@ -51,9 +51,11 @@ Editing
([QTCREATORBUG-12190](https://bugreports.qt.io/browse/QTCREATORBUG-12190)) ([QTCREATORBUG-12190](https://bugreports.qt.io/browse/QTCREATORBUG-12190))
* Added `Re-order Member Function Definitions According to Declaration Order` * Added `Re-order Member Function Definitions According to Declaration Order`
([QTCREATORBUG-6199](https://bugreports.qt.io/browse/QTCREATORBUG-6199)) ([QTCREATORBUG-6199](https://bugreports.qt.io/browse/QTCREATORBUG-6199))
* Added triggers for `Add Curly Braces` * Added `Add Curly Braces` for do, while, and for loops
* Fixed issues with macros * Fixed issues with macros
([QTCREATORBUG-10279](https://bugreports.qt.io/browse/QTCREATORBUG-10279)) ([QTCREATORBUG-10279](https://bugreports.qt.io/browse/QTCREATORBUG-10279))
[Documentation](https://doc.qt.io/qtcreator/creator-reference-cpp-quick-fixes.html)
* Clangd * Clangd
* Increased the minimum version to LLVM 17 * Increased the minimum version to LLVM 17
* Added the `Per-project index location` and `Per-session index location` * Added the `Per-project index location` and `Per-session index location`

View File

@@ -115,7 +115,7 @@
\row \row
\li Assign to Local Variable \li Assign to Local Variable
\li Adds a local variable which stores the return value of a \li Adds a local variable which stores the return value of a
function call or a new expression. For example, rewrites: function call or a new expression. For example, rewrites
\code \code
QString s; QString s;
@@ -195,7 +195,7 @@
\row \row
\li Move All Function Definitions \li Move All Function Definitions
\li Moves all function definitions to the implementation file or \li Moves all function definitions to the implementation file or
outside the class. For example, rewrites: outside the class. For example, rewrites
\code \code
class Foo class Foo
{ {
@@ -281,12 +281,14 @@
\li Description \li Description
\row \row
\li Add Curly Braces \li Add Curly Braces
\li Adds curly braces to an if statement that does not have a \li Adds curly braces to an if clause or to a do, while, or for
compound statement. For example, rewrites loop. For example, rewrites an if clause
\code \code
if (a) if (a)
b; b;
else
c;
\endcode \endcode
as as
@@ -294,6 +296,54 @@
\code \code
if (a) { if (a) {
b; b;
} else {
c;
}
\endcode
Rewrites a do loop
\code
do
++i;
while (i < 10);
\endcode
as
\code
do {
++i;
} while (i < 10);
\endcode
Rewrites a while loop
\code
while (i > 0)
--i;
\endcode
as
\code
while (i > 0) {
--i;
}
\endcode
Rewrites a for loop
\code
for (int i = 0; i < 10; ++i)
func(i);
\endcode
as
\code
for (int i = 0; i < 10; ++i) {
func(i);
} }
\endcode \endcode
\row \row
@@ -321,7 +371,7 @@
post-decrement operators as pre-decrement operators. It also post-decrement operators as pre-decrement operators. It also
moves other than string or numeric literals and id expressions moves other than string or numeric literals and id expressions
from the condition of a for loop to its initializer. For from the condition of a for loop to its initializer. For
example, rewrites: example, rewrites
\code \code
for (int i = 0; i < 3 * 2; i++) for (int i = 0; i < 3 * 2; i++)
@@ -451,7 +501,7 @@
The quick fix also works on invokable methods outside the class that are The quick fix also works on invokable methods outside the class that are
visible from the location where they are called from. For example, it visible from the location where they are called from. For example, it
rewrites: rewrites
\code \code
Foo f; Foo f;
@@ -470,7 +520,7 @@
\row \row
\li Move Function Definition \li Move Function Definition
\li Moves a function definition to the implementation file, outside \li Moves a function definition to the implementation file, outside
the class or back to its declaration. For example, rewrites: the class or back to its declaration. For example, rewrites
\code \code
class Foo class Foo
{ {
@@ -555,7 +605,7 @@
\row \row
\li Rewrite Condition Using || \li Rewrite Condition Using ||
\li Rewrites the expression according to De Morgan's laws. For \li Rewrites the expression according to De Morgan's laws. For
example, rewrites: example, rewrites
\code \code
!a && !b !a && !b
\endcode \endcode
@@ -569,7 +619,7 @@
\row \row
\li Rewrite Using \e operator \li Rewrite Using \e operator
\li Rewrites an expression negating it and using the inverse \li Rewrites an expression negating it and using the inverse
operator. For example, rewrites: operator. For example, rewrites
\list \list
@@ -609,7 +659,7 @@
\row \row
\li Split if Statement \li Split if Statement
\li Splits an if statement into several statements. For example, \li Splits an if statement into several statements. For example,
rewrites: rewrites
\code \code
if (something && something_else) { if (something && something_else) {
@@ -645,7 +695,7 @@
\row \row
\li Swap Operands \li Swap Operands
\li Rewrites an expression in the inverse order using the inverse \li Rewrites an expression in the inverse order using the inverse
operator. For example, rewrites: operator. For example, rewrites
\code \code
a op b a op b
\endcode \endcode
@@ -801,7 +851,7 @@
\row \row
\li Convert to Pointer \li Convert to Pointer
\li Converts the selected stack variable to a pointer. For example, \li Converts the selected stack variable to a pointer. For example,
rewrites: rewrites
\code \code
QByteArray foo = "foo"; QByteArray foo = "foo";
@@ -822,7 +872,7 @@
\row \row
\li Convert to Stack Variable \li Convert to Stack Variable
\li Converts the selected pointer to a stack variable. For example, \li Converts the selected pointer to a stack variable. For example,
rewrites: rewrites
\code \code
QByteArray *foo = new QByteArray("foo"); QByteArray *foo = new QByteArray("foo");
@@ -847,7 +897,7 @@
project is open, the current global code style settings are project is open, the current global code style settings are
used. used.
For example, rewrites: For example, rewrites
\code \code
char*s; char*s;
@@ -867,7 +917,7 @@
\row \row
\li Split Declaration \li Split Declaration
\li Splits a simple declaration into several declarations. For \li Splits a simple declaration into several declarations. For
example, rewrites: example, rewrites
\code \code
int *a, b; int *a, b;
\endcode \endcode