From c01129828f1775c7ad8e3d8637a9fee600e109bc Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Mon, 8 Jan 2024 17:50:31 +0100 Subject: [PATCH] Doc: Split up "Refactoring" and "Applying Refactoring Actions" Replace "refactoring actions" with "quick fixes", as they are called that in the UI. Task-number: QTCREATORBUG-29361 Change-Id: I6952bb1b222c340a6bccb175733c611907885a47 Reviewed-by: Christian Kandeler --- ...rences-quick-fixes-function-locations.webp | Bin 0 -> 3726 bytes .../src/editors/creator-code-refactoring.qdoc | 29 +- .../creator-only/creator-clang-codemodel.qdoc | 2 +- .../creator-only/creator-cpp-quick-fixes.qdoc | 799 ++++++++++++++++ .../src/editors/creator-quick-fixes.qdoc | 869 ++---------------- .../creator-projects-settings-overview.qdoc | 2 +- doc/qtcreator/src/qtcreator-toc.qdoc | 1 - .../src/qtdesignstudio-toc.qdoc | 1 - 8 files changed, 889 insertions(+), 814 deletions(-) create mode 100644 doc/qtcreator/images/qtcreator-preferences-quick-fixes-function-locations.webp create mode 100644 doc/qtcreator/src/editors/creator-only/creator-cpp-quick-fixes.qdoc diff --git a/doc/qtcreator/images/qtcreator-preferences-quick-fixes-function-locations.webp b/doc/qtcreator/images/qtcreator-preferences-quick-fixes-function-locations.webp new file mode 100644 index 0000000000000000000000000000000000000000..e0a2b5c85b6bb789ed0cd89bc8aeba5e55fa0739 GIT binary patch literal 3726 zcmWIYbaQLtV_*n(bqWXzu<)tkV_?wdKcvZUHDdOE|3c}Pdu5FEjEzrn8P5`9cIWt7mb!N7w=Aau z70;qOQ@9gP$v@bzJw)%mzqpio+<_e((ZW(s#OB=Ic1`2?86LjaEsK?Fc=%-h@4uSS zuNL3#eX%}rLT+nraop-KInTZCn*;(66n(CAPHTP_GMi~7BF)4lK29=}#L zX~)c)$`?J=smk~zCva8!-GO@H zwv;Qkl)uV-I~~Qcj^TPms%((JA(y?=AID0#>7Res(&=&kt88GO(Doe~RbkFuR~T&a z?e=_0uQX*9EwGR*c~NOr$fdiA*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doc index 285ab394799..eab5601c25f 100644 --- a/doc/qtcreator/src/editors/creator-code-refactoring.qdoc +++ b/doc/qtcreator/src/editors/creator-code-refactoring.qdoc @@ -1,13 +1,18 @@ -// Copyright (C) 2022 The Qt Company Ltd. +// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \page creator-editor-refactoring.html \previouspage creator-jump-to-the-code.html - \nextpage creator-editor-quick-fixes.html + \nextpage creator-editor-options.html \title Refactoring + \e {Code refactoring} is the process of improving and simplifying code + without modifying the existing functionality of an application. You + can easily find and rename symbols and apply predefined actions to + refactor code. + Refactor code to: \list @@ -17,9 +22,8 @@ \li Simplify code structure \endlist - \QC allows you to quickly and conveniently apply actions to refactor your - code by selecting them in a context menu. For more information, see - \l{Applying Refactoring Actions}. + To quickly and conveniently apply actions to refactor your + code, \l{Apply quick fixes}{select quick fixes in a context menu}. By default, the refactored files are saved automatically. To disable this feature, deselect \preferences > \uicontrol Environment > @@ -33,13 +37,13 @@ \uicontrol {C++} > \uicontrol {Find References to Symbol Under Cursor} or press \key {Ctrl+Shift+U}. - \image qtcreator-find-references-to-symbol-under-cursor.png "Search results for finding references to symbols" + \image qtcreator-find-references-to-symbol-under-cursor.png {Search results for finding references to symbols} To view the same results color-coded according to the access type, such as read, write, or declaration, select \uicontrol Tools > \uicontrol {C++} > \uicontrol {Find References with Access Type}. - \note You can also select \uicontrol Edit > \uicontrol {Find/Replace} > + \note Select \uicontrol Edit > \uicontrol {Find/Replace} > \uicontrol {Advanced Find} > \uicontrol {C++ Symbols} to search for classes, functions, enums, and declarations (including type aliases) either from files listed as part of the project or from all files that are used by @@ -76,7 +80,7 @@ \image qml-find-usages.png \endif - You can browse the search results in the following ways: + Browse the search results in the following ways: \list \li To go directly to an instance, double-click the instance in @@ -138,7 +142,12 @@ box to also change the filenames that match the class name. \note Renaming local symbols does not open \uicontrol {Search Results}. - The instances of the symbol are highlighted in code and you can edit + The instances of the symbol are highlighted in code, and you can edit the symbol. All instances of the local symbol are changed as you type. + + \sa {Specify settings for quick fixes}, {Quick Fixes}, {C++ Quick Fixes} + \endif - */ + + \sa {Apply quick fixes}, {QML Quick Fixes} +*/ diff --git a/doc/qtcreator/src/editors/creator-only/creator-clang-codemodel.qdoc b/doc/qtcreator/src/editors/creator-only/creator-clang-codemodel.qdoc index 0e0b453d7cd..e45cedb10ba 100644 --- a/doc/qtcreator/src/editors/creator-only/creator-clang-codemodel.qdoc +++ b/doc/qtcreator/src/editors/creator-only/creator-clang-codemodel.qdoc @@ -40,7 +40,7 @@ \li \l{Finding Symbols}{Finding and renaming symbols} - \li \l{Applying Refactoring Actions}{Refactoring actions} + \li \l{Apply quick fixes}{Quick fixes} \endlist diff --git a/doc/qtcreator/src/editors/creator-only/creator-cpp-quick-fixes.qdoc b/doc/qtcreator/src/editors/creator-only/creator-cpp-quick-fixes.qdoc new file mode 100644 index 00000000000..f0da2561295 --- /dev/null +++ b/doc/qtcreator/src/editors/creator-only/creator-cpp-quick-fixes.qdoc @@ -0,0 +1,799 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \page creator-reference-preferences-cpp-quick-fixes.html + \previouspage creator-reference.html + + \ingroup creator-reference-preferences-cpp + + \title Quick Fixes + + \brief Set global preferences for C++ quick fixes. + + To set global preferences for C++ quick fixes, go to \preferences > + \uicontrol C++ > \uicontrol {Quick Fixes}. + + \section1 Function Locations + + In the \uicontrol {Generated Function Locations} group, set + whether quick fixes should generate getter and setter functions + in the header file (inside or outside the class) or in the implementation + file. + + \image qtcreator-preferences-quick-fixes-function-locations.webp {Generated Function Locations group in Quick Fixes preferences} + + \section1 Function Names and Attributes + + In the \uicontrol {Getter Setter Generation Properties} group, + specify additional settings for getter and setter names, attributes, and + parameters. You can specify that setter functions should be created as + \e slots and that signals should be generated with the new value as a + parameter. + + \image qtcreator-refactoring-options-generation.png {Getter and Setter generation settings} + + \section1 Namespace Handling + + In the \uicontrol {Missing Namespace Handling} group, select whether to + generate missing namespaces, add \c {using namespace} where necessary, or + rewrite types to match the existing namespaces. + + \image qtcreator-refactoring-options-namespaces.png "Namespace handling settings" + + \section1 Custom Parameter Types + + In the \uicontrol {Custom Getter Setter Templates} group, specify how the + code of a getter or setter function for a certain data type should look + like. This is necessary for types where assignment cannot use \c operator=, + as in the pre-defined settings for \c unique_ptr or where \c operator== is + not suitable for comparison, as in the pre-defined settings for + floating-point types. For example, if you have a special type \c MyClass, + you can specify that a function, \c myCompare, should be used for comparison + rather than the default of \c ==. + + To specify special handling for a custom parameter type, select + \uicontrol Add and set the parameter type, comparison, return expression, + and return type. In the \uicontrol {Return type} field, use \c + and \c to access the parameter and current value. Use \c to + access the type and \c for the template parameter. + + \image qtcreator-refactoring-options-templates.png {Settings for handling custom parameter types} + + Usually, arguments are passed by using a \c const reference. To pass + arguments of a particular type as values, list them in the + \uicontrol {Value types} field. Namespaces and template arguments are + removed. The real Type must contain the given Type. For example, \c int + matches \c int32_t but not \c vector, and \c vector matches + \c {std::pmr::vector} but not \c {std::optional>}. + + To return non-trivial objects by using a \c const reference, select the + \uicontrol {Return non-value types by const reference} check box. + + \sa {Apply quick fixes}, {Specify settings for quick fixes}, + {C++ Quick Fixes}, {QML Quick Fixes}, {Refactoring} +*/ + +/*! + \page creator-reference-cpp-quick-fixes.html + \previouspage creator-reference.html + + \ingroup creator-reference + + \title C++ Quick Fixes + + \brief Summary of quick fixes for C++ code. + + If you use the \l{Clang Code Model}{Clang code model} to parse the C++ files, + you get \l{http://clang.llvm.org/diagnostics.html}{Clang fix-it hints} in the + \uicontrol Edit mode. Use the standard ways of activating quick fixes, or + select the fixes that are applicable on a line in the context menu in the + left margin of the code editor. + + Apply the following types of quick fixes to C++ code: + + \list + \li Change binary operands + \li Simplify if and while conditions (for example, move declarations out + of if conditions) + \li Modify strings (for example, set the encoding for a string to + Latin-1, mark strings translatable, and convert symbol names to + camel case) + \li Create variable declarations + \li Create function declarations and definitions + \endlist + + The following table summarizes the quick fixes for C++ code. The + fix is available when the cursor is in the position described in the + Activation column. + + \table + \header + \li Quick Fix + \li Description + \li Activation + \row + \li Add Curly Braces + \li Adds curly braces to an if statement that does not have a + compound statement. For example, rewrites + + \code + if (a) + b; + \endcode + + as + + \code + if (a) { + b; + } + \endcode + \li \c if + \row + \li Move Declaration out of Condition + \li Moves a declaration out of an if or while condition to simplify + the condition. For example, rewrites + + \code + if (Type name = foo()) {} + \endcode + + as + + \code + Type name = foo; + if (name) {} + \endcode + \li Name of the introduced variable + \row + \li Rewrite Condition Using || + \li Rewrites the expression according to De Morgan's laws. For + example, rewrites: + \code + !a && !b + \endcode + + as + + \code + !(a || b) + \endcode + \li \c && + \row + \li Rewrite Using \e operator + \li Rewrites an expression negating it and using the inverse + operator. For example, rewrites: + + \list + + \li \code + a op b + \endcode + + as + + \code + !(a invop b) + \endcode + + \li \code + (a op b) + \endcode + + as + + \code + !(a invop b) + \endcode + + \li \code + !(a op b) + \endcode + + as + + \code + (a invob b) + \endcode + + \endlist + + \li \c {<=}, \c {<}, \c {>}, \c {>=}, \c {==} or \c {!=} + \row + \li Split Declaration + \li Splits a simple declaration into several declarations. For + example, rewrites: + \code + int *a, b; + \endcode + + as + + \code + int *a; + int b; + \endcode + \li Type name or variable name + \row + \li Split if Statement + \li Splits an if statement into several statements. For example, + rewrites: + + \code + if (something && something_else) { + } + \endcode + + as + + \code + if (something) { + if (something_else) { + } + } + \endcode + + and + + \code + if (something || something_else) + x; + \endcode + + with + + \code + if (something) + x; + else if (something_else) + x; + \endcode + + \li \c && or \c || + \row + \li Swap Operands + \li Rewrites an expression in the inverse order using the inverse + operator. For example, rewrites: + \code + a op b + \endcode + + as + \code + b flipop a + \endcode + \li \c {<=}, \c {<}, \c {>}, \c {>=}, \c {==}, \c {!=}, \c {&&} + or \c {||} + \row + \li Convert to Decimal + \li Converts an integer literal to decimal representation + \li Numeric literal + \row + \li Convert to Hexadecimal + \li Converts an integer literal to hexadecimal representation + \li Numeric literal + \row + \li Convert to Octal + \li Converts an integer literal to octal representation + \li Numeric literal + \row + \li Convert to Objective-C String Literal + \li Converts a string literal to an Objective-C string literal if + the file type is Objective-C(++). For example, rewrites the + following strings + + \code + "abcd" + QLatin1String("abcd") + QLatin1Literal("abcd") + \endcode + + as + + \code + @"abcd" + \endcode + \li String literal + \row + \li Enclose in QLatin1Char() + \li Sets the encoding for a character to Latin-1, unless the + character is already enclosed in QLatin1Char, QT_TRANSLATE_NOOP, + tr, trUtf8, QLatin1Literal, or QLatin1String. For example, + rewrites + + \code + 'a' + \endcode + + as + + \code + QLatin1Char('a') + \endcode + \li String literal + \row + \li Enclose in QLatin1String() + \li Sets the encoding for a string to Latin-1, unless the string is + already enclosed in QLatin1Char, QT_TRANSLATE_NOOP, tr, trUtf8, + QLatin1Literal, or QLatin1String. For example, rewrites + \code + "abcd" + \endcode + + as + + \code + QLatin1String("abcd") + \endcode + + \li String literal + + \row + \li Mark as Translatable + \li Marks a string translatable. For example, rewrites \c "abcd" + with one of the following options, depending on which of them is + available: + + \code + tr("abcd") + QCoreApplication::translate("CONTEXT", "abcd") + QT_TRANSLATE_NOOP("GLOBAL", "abcd") + \endcode + + \li String literal + + \row + \li Add Definition in ... + \li Inserts a definition stub for a function declaration either in + the header file (inside or outside the class) or in the + implementation file. For free functions, inserts the definition + after the declaration of the function or in the implementation + file. Qualified names are minimized when possible, instead of + always being fully expanded. + + For example, rewrites + + \code + Class Foo { + void bar(); + }; + \endcode + + as (inside class) + + \code + Class Foo { + void bar() { + + } + }; + \endcode + + as (outside class) + + \code + Class Foo { + void bar(); + }; + + void Foo::bar() + { + + } + \endcode + + as (in implementation file) + + \code + // Header file + Class Foo { + void bar(); + }; + + // Implementation file + void Foo::bar() + { + + } + \endcode + + \li Function name + \row + \li Add \c Function Declaration + \li Inserts the member function declaration that matches the member + function definition into the class declaration. The function can + be \c {public}, \c {protected}, \c {private}, \c {public slot}, + \c {protected slot}, or \c {private slot}. + \li Function name + \row + \li Add Class Member + \li Adds a member declaration for the class member being + initialized if it is not yet declared. If \QC cannot + automatically detect the data type of the member, you + must add it. + \li Identifier + \row + \li Create Implementations for Member Functions + \li Creates implementations for all member functions in one go. + In the \uicontrol {Member Function Implementations} dialog, + specify whether the member functions are generated + inline or outside the class. + \li Function name + \row + \li Switch with Next/Previous Parameter + \li Moves a parameter down or up one position in a parameter list. + \li Parameter in the declaration or definition of a function + \row + \li Extract Function + \li Moves the selected code to a new function and replaces the block + of code with a call to the new function. Enter a name for the + function in the \uicontrol {Extract Function Refactoring} + dialog. + \li Block of code selected + \row + \li Extract Constant as Function Parameter + \li Replaces the selected literal and all its occurrences with the + function parameter \c{newParameter}. The parameter + \c{newParameter} will have the original literal as the default + value. + \li Block of code selected + \row + \li Add Local Declaration + \li Adds the type of an assignee, if the type of the right-hand + side of the assignment is known. For example, rewrites + + \code + a = foo(); + \endcode + + as + + \code + Type a = foo(); + \endcode + + where Type is the return type of \c {foo()} + + \li Assignee + + \row + \li Convert to Camel Case + \li Converts a symbol name to camel case, where elements of the name + are joined without delimiter characters and the initial + character of each element is capitalized. For example, rewrites + \c an_example_symbol as \c anExampleSymbol and + \c AN_EXAMPLE_SYMBOL as \c AnExampleSymbol + \li Identifier + \row + \li Complete Switch Statement + \li Adds all possible cases to a switch statement of the type + \c enum + \li \c switch + \row + \li Generate Missing Q_PROPERTY Members + \li Adds missing members to a \c Q_PROPERTY: + \list + \li \c read function + \li \c write function, if there is a WRITE + \li \c {onChanged} signal, if there is a NOTIFY + \li data member with the name \c {m_} + \endlist + \li \c Q_PROPERTY + \row + \li Generate Q_PROPERTY and Missing Members + \li Generates a Q_PROPERTY and adds missing members to it, as + described above. + \li Class member + \row + \li Generate Constant Q_PROPERTY and Missing Members + \li Generates a constant Q_PROPERTY and adds missing members + to it, as described above. + \li Class member + \row + \li Generate Q_PROPERTY and Missing Members with Reset Function + \li Generates a Q_PROPERTY and adds missing members to it, as + described above, but with an additional \c reset function. + \li Class member + \row + \li Apply Changes + \li Keeps function declarations and definitions synchronized by + checking for the matching declaration or definition when you + edit a function signature and by applying the changes to the + matching code. + \li Function signature. When this fix is available, a light bulb + icon appears: \inlineimage icons/refactormarker.png + \row + \li Add #include for undeclared or forward declared identifier + \li Adds an \c {#include} directive to the current file to make the + definition of a symbol available. + \li Undeclared identifier + \row + \li Add Forward Declaration + \li Adds a forward declaration for an undeclared identifier + operation. + \li Undeclared identifier + \row + \li Reformat Pointers or References + \li Reformats declarations with pointers or references according + to the code style settings for the current project. In case no + project is open, the current global code style settings are + used. + + For example, rewrites: + + \code + char*s; + \endcode + + as + + \code + char *s; + \endcode + + When applied to selections, all suitable declarations in the + selection are rewritten. + + \li Declarations with pointers or references and selections + that have such declarations + \row + \li Create Getter and Setter Member Functions + \li Creates either both getter and setter member functions for + member variables or only a getter or setter. + \li Member variable in class definition + \row + \li Generate Getter and Setter + \li Creates getter and setter member functions for a member + variable. + \li Member variable in class definition + \row + \li Generate Getter + \li Creates a getter member function for a member variable. + \li Member variable in class definition + \row + \li Generate Setter + \li Creates a setter member function for a member variable. + \li Member variable in class definition + \row + \li Generate Constructor + \li Creates a constructor for a class. + \li Class definition + \row + \li Move Function Definition + \li Moves a function definition to the implementation file, outside + the class or back to its declaration. For example, rewrites: + \code + class Foo + { + void bar() + { + // do stuff here + } + }; + \endcode + + as + \code + class Foo + { + void bar(); + }; + + void Foo::bar() { + // do stuff here + } + \endcode + + \li Function signature + \row + \li Move All Function Definitions + \li Moves all function definitions to the implementation file or + outside the class. For example, rewrites: + \code + class Foo + { + void bar() + { + // do stuff here + } + void baz() + { + // do stuff here + } + }; + \endcode + + as + + \code + class Foo + { + void bar(); + void baz(); + }; + + void Foo::bar() { + // do stuff here + } + + void Foo::baz() { + // do stuff here + } + \endcode + + \li Class name + \row + \li Assign to Local Variable + \li Adds a local variable which stores the return value of a + function call or a new expression. For example, rewrites: + + \code + QString s; + s.toLatin1(); + \endcode + + as + + \code + QString s; + QByteArray latin1 = s.toLatin1(); + \endcode + + and + + \code + new Foo; + \endcode + + as + + \code + Foo * localFoo = new Foo; + \endcode + + By default, \QC uses the \c auto variable type when creating the + variable. To label the variable with its actual type, select + \preferences > \uicontrol C++ > + \uicontrol {Quick Fixes}, and then deselect the + \uicontrol {Use type "auto" when creating new variables} check + box. + + \li Function call or class name + \row + \li Insert Virtual Functions of Base Classes + \li Inserts declarations and the corresponding definitions inside or + outside the class or in an implementation file (if it exists). + For more information, see \l{Insert virtual functions}. + \li Class or base class name + \row + \li Optimize for-Loop + \li Rewrites post increment operators as pre increment operators and + post decrement operators as pre decrement operators. It also + moves other than string or numeric literals and id expressions + from the condition of a for loop to its initializer. For + example, rewrites: + + \code + for (int i = 0; i < 3 * 2; i++) + \endcode + + as + + \code + for (int i = 0, total = 3 * 2; i < total; ++i) + \endcode + \li \c for + + \row + \li Escape String Literal as UTF-8 + \li Escapes non-ASCII characters in a string literal to hexadecimal + escape sequences. String Literals are handled as UTF-8. + \li String literal + + \row + \li Unescape String Literal as UTF-8 + \li Unescapes octal or hexadecimal escape sequences in a string + literal. String Literals are handled as UTF-8. + \li String literal + + \row + \li Convert to Stack Variable + \li Converts the selected pointer to a stack variable. For example, + rewrites: + + \code + QByteArray *foo = new QByteArray("foo"); + foo->append("bar"); + \endcode + + as + + \code + QByteArray foo("foo"); + foo.append("bar"); + \endcode + + This operation is limited to work only within function scope. + Also, the coding style for pointers and references is not + respected yet. + \li Pointer Variable + + \row + \li Convert to Pointer + \li Converts the selected stack variable to a pointer. For example, + rewrites: + + \code + QByteArray foo = "foo"; + foo.append("bar"); + \endcode + + as + + \code + QByteArray *foo = new QByteArray("foo"); + foo->append("bar"); + \endcode + + This operation is limited to work only within function scope. + Also, the coding style for pointers and references is not + respected yet. + \li Stack Variable + \row + \li Remove \c {using namespace} and Adjust Type Names Accordingly + \li Remove occurrences of \c {using namespace} in the local scope + and adjust type names accordingly. + \li \c using directive + \row + \li Remove All Occurrences of \c {using namespace} in Global Scope + and Adjust Type Names Accordingly + \li Remove all occurrences of \c {using namespace} in the global + scope and adjust type names accordingly. + \li \c using directive + \row + \li Convert connect() to Qt 5 Style + \li Converts a Qt 4 QObject::connect() to Qt 5 style. + \li QObject::connect() (Qt 4 style) + \row + \li Convert Comment to C/C++ Style + \li Converts C-style comments into C++-style comments, and vice + versa. Tries to preserve \e pretty layout and takes Doxygen and + qdoc formatting into consideration, but you might need to clean + up the results. + \li Code comment + \row + \li Move Function Documentation to Declaration/Definition + \li Moves the documentation comment for a function between its + declaration and definition. + \li Documentation comment for a function + \endtable + + \sa {Apply quick fixes}, {Specify settings for quick fixes}, + {QML Quick Fixes}, {Quick Fixes}, {Refactoring} +*/ + +/*! + \page creator-how-to-specify-settings-for-quick-fixes.html + \previouspage creator-how-tos.html + + \ingroup creator-how-to-projects-configure + + \title Specify settings for quick fixes + + To refactor your code, select quick fixes in the context menu in the + \uicontrol Edit mode. + + To create custom quick fix settings for a particular project, go to + \uicontrol Projects > \uicontrol {Project Settings} > + \uicontrol {Quick Fixes} and clear \uicontrol {Use global settings}. + + \image qtcreator-refactoring-options-locations.png {Quick Fixes preferences} + + To revert to global settings, select \uicontrol {Reset to Global}. To + delete the custom settings, select \uicontrol {Use global settings}, and + then select \uicontrol {Delete Custom Settings File}. + + \sa {Apply quick fixes}, {C++ Quick Fixes}, {QML Quick Fixes}, {Quick Fixes}, + {Configuring Projects}, {Refactoring} +*/ diff --git a/doc/qtcreator/src/editors/creator-quick-fixes.qdoc b/doc/qtcreator/src/editors/creator-quick-fixes.qdoc index f161a5fe1c5..af49d65612d 100644 --- a/doc/qtcreator/src/editors/creator-quick-fixes.qdoc +++ b/doc/qtcreator/src/editors/creator-quick-fixes.qdoc @@ -1,849 +1,111 @@ -// Copyright (C) 2022 The Qt Company Ltd. +// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \page creator-editor-quick-fixes.html - \previouspage creator-editor-refactoring.html \if defined(qtdesignstudio) - \nextpage creator-editor-options.html + \previouspage creator-editor-refactoring.html \else - \nextpage creator-beautifier.html + \previouspage creator-how-tos.html \endif - \title Applying Refactoring Actions + \ingroup creator-how-to-edit - \QC allows you to quickly and conveniently apply actions (quick fixes) - to refactor your code by selecting them in a context menu. The actions - available depend on the position of the cursor in the code editor. + \title Apply quick fixes + To apply quick fixes while refactoring code, select them in a context menu + in the code editor. The fixes available depend on the position of the + cursor in the code editor. + + \list 1 \if defined(qtcreator) - To apply refactoring actions to C++ code, right-click an operand, - conditional statement, string, or name to open a context menu. + \li To apply quick fixes: + \list + \li In C++ code, right-click an operand, conditional statement, + string, or name. + \li In QML code, right-click an item ID or name. + \endlist + \else + \li To apply quick fixes to QML code, right-click an item ID or name. \endif - To apply refactoring actions to QML code, right-click an item ID or name. + \li In the context menu, go to \uicontrol {Refactoring} and then select a + quick fix. + \endlist - In the context menu, select \uicontrol {Refactoring} and then select a - refactoring action. - - You can also press \key {Alt+Enter} to open a context menu that has - refactoring actions available in the current cursor position. + Or, press \key {Alt+Enter} to open a context menu that has + quick fixes available in the current cursor position. \if defined(qtcreator) - \section1 Creating Functions + \section1 Create functions - You can apply refactoring actions to implement member functions, insert + Apply quick fixes to implement member functions, insert virtual functions of base classes, create getter and setter functions, - and generate constructors. You can specify settings for generating the + and generate constructors. Specify settings for generating the functions either globally for all projects or separately for each project - in the \l{Overriding Global Preferences}{build and run} settings of the - project. + in the \l{Configuring Projects}{build and run} settings of the project. - \section2 Implementing Member Functions + \section2 Implement member functions - You can apply the \uicontrol {Create Implementations for Member Functions} - refactoring action to create implementations for all member functions in - one go. In the \uicontrol {Member Function Implementations} dialog, you can + Apply the \uicontrol {Create Implementations for Member Functions} + quick fix to create implementations for all member functions in + one go. In the \uicontrol {Member Function Implementations} dialog, specify whether the member functions are generated inline or outside the class. \image qtcreator-refactoring-member-function-implementations.png "Implement Member Functions dialog" - \section2 Inserting Virtual Functions + \section2 Insert virtual functions - You can apply the \uicontrol {Insert Virtual Functions of Base Classes} - refactoring action to insert declarations and the corresponding definitions + Apply the \uicontrol {Insert Virtual Functions of Base Classes} + quick fix to insert declarations and the corresponding definitions inside or outside the class or in an implementation file (if it exists). \image qtcreator-refactoring-virtual-function-dialog.png "Insert Virtual Functions dialog" - Select the functions to insert in the list of available functions. You can - filter the list and hide reimplemented functions from it. + Select the functions to insert in the list of available functions. + Filter the list and hide reimplemented functions from it. You can add \e virtual or the \e override equivalent to the function declaration. - \section2 Creating Getters and Setters + \section2 Create getters and setters - You can apply the \uicontrol {Create Getter and Setter Member Functions} - refactoring action to create either both getter and setter member functions + Apply the \uicontrol {Create Getter and Setter Member Functions} + quick fix to create either both getter and setter member functions for member variables or only a getter or setter. \image qtcreator-refactoring-getters-and-setters.png "Getters and Setters dialog" - \section2 Generating Constructors + \section2 Generate constructors - You can apply the \uicontrol {Generate Constructor} refactoring action to + Apply the \uicontrol {Generate Constructor} quick fix to create a public, protected, or private constructor for a class. Select the - class members to initialize in the constructor. Drag and drop the parameters + class members to initialize in the constructor. Drag the parameters to specify their order in the constructor. \image qtcreator-refactoring-constructor.png "Constructor dialog" - \section1 Specifying Settings for Refactoring Actions - - You can specify settings for the refactoring actions either globally for - all projects or separately for each project. To specify global options, - select \preferences > \uicontrol C++ > \uicontrol {Quick Fixes}. - - To specify custom settings for a particular project, select - \uicontrol Projects > \uicontrol {Project Settings} > - \uicontrol {Quick Fixes}, and then deselect \uicontrol {Use global settings}. - - \image qtcreator-refactoring-options-locations.png "Quick Fixes settings" - - To revert to global settings, select \uicontrol {Reset to Global}. To - delete the custom settings, select \uicontrol {Use global settings}, and - then select \uicontrol {Delete Custom Settings File}. - - \section2 Function Locations - - In the \uicontrol {Generated Function Locations} group, you can determine - whether refactoring actions should generate getter and setter functions - in the header file (inside or outside the class) or in the implementation - file. - - \section2 Function Names and Attributes - - In the \uicontrol {Getter Setter Generation Properties} group, you can - specify additional settings for getter and setter names, attributes, and - parameters. You can specify that setter functions should be created as - \e slots and that signals should be generated with the new value as a - parameter. - - \image qtcreator-refactoring-options-generation.png "Getter and Setter generation settings" - - \section2 Namespace Handling - - In the \uicontrol {Missing Namespace Handling} group, select whether to - generate missing namespaces, add \c {using namespace} where necessary, or - rewrite types to match the existing namespaces. - - \image qtcreator-refactoring-options-namespaces.png "Namespace handling settings" - - \section2 Custom Parameter Types - - In the \uicontrol {Custom Getter Setter Templates} group, specify how the - code of a getter or setter function for a certain data type should look - like. This is necessary for types where assignment cannot use \c operator=, - as in the pre-defined settings for \c unique_ptr or where \c operator== is - not suitable for comparison, as in the pre-defined settings for - floating-point types. For example, if you have a special type \c MyClass, - you can specify that a function, \c myCompare, should be used for comparison - rather than the default of \c ==. - - To specify special handling for a custom parameter type, select - \uicontrol Add and set the parameter type, comparison, return expression, - and return type. In the \uicontrol {Return type} field, you can use \c - and \c to access the parameter and current value. Use \c to - access the type and \c for the template parameter. - - \image qtcreator-refactoring-options-templates.png "Settings for handling custom parameter types" - - Usually, arguments are passed by using a \c const reference. To pass - arguments of a particular type as values, list them in the - \uicontrol {Value types} field. Namespaces and template arguments are - removed. The real Type must contain the given Type. For example, \c int - matches \c int32_t but not \c vector, and \c vector matches - \c {std::pmr::vector} but not \c {std::optional>}. - - To return non-trivial objects by using a \c const reference, select the - \uicontrol {Return non-value types by const reference} check box. + \sa {Specify settings for quick fixes}, {Quick Fixes}, {C++ Quick Fixes} \endif - \section1 Summary of Refactoring Actions - - \if defined(qtcreator) - If you use the \l{Clang Code Model}{Clang code model} to parse the C++ files, - you will get \l{http://clang.llvm.org/diagnostics.html}{Clang fix-it hints} - that have been integrated into \QC. Use the standard ways of activating - refactoring actions or select the actions that are applicable on a line in - the context menu in the left margin of the code editor. - - \section2 Refactoring C++ Code - - You can apply the following types of refactoring actions to C++ code: - - \list - \li Change binary operands - \li Simplify if and while conditions (for example, move declarations out - of if conditions) - \li Modify strings (for example, set the encoding for a string to - Latin-1, mark strings translatable, and convert symbol names to - camel case) - \li Create variable declarations - \li Create function declarations and definitions - \endlist - - The following table summarizes the refactoring actions for C++ code. The - action is available when the cursor is in the position described in the - Activation column. - - \table - \header - \li Refactoring Action - \li Description - \li Activation - \row - \li Add Curly Braces - \li Adds curly braces to an if statement that does not have a - compound statement. For example, rewrites - - \code - if (a) - b; - \endcode - - as - - \code - if (a) { - b; - } - \endcode - \li \c if - \row - \li Move Declaration out of Condition - \li Moves a declaration out of an if or while condition to simplify - the condition. For example, rewrites - - \code - if (Type name = foo()) {} - \endcode - - as - - \code - Type name = foo; - if (name) {} - \endcode - \li Name of the introduced variable - \row - \li Rewrite Condition Using || - \li Rewrites the expression according to De Morgan's laws. For - example, rewrites: - \code - !a && !b - \endcode - - as - - \code - !(a || b) - \endcode - \li \c && - \row - \li Rewrite Using \e operator - \li Rewrites an expression negating it and using the inverse - operator. For example, rewrites: - - \list - - \li \code - a op b - \endcode - - as - - \code - !(a invop b) - \endcode - - \li \code - (a op b) - \endcode - - as - - \code - !(a invop b) - \endcode - - \li \code - !(a op b) - \endcode - - as - - \code - (a invob b) - \endcode - - \endlist - - \li \c {<=}, \c {<}, \c {>}, \c {>=}, \c {==} or \c {!=} - \row - \li Split Declaration - \li Splits a simple declaration into several declarations. For - example, rewrites: - \code - int *a, b; - \endcode - - as - - \code - int *a; - int b; - \endcode - \li Type name or variable name - \row - \li Split if Statement - \li Splits an if statement into several statements. For example, - rewrites: - - \code - if (something && something_else) { - } - \endcode - - as - - \code - if (something) { - if (something_else) { - } - } - \endcode - - and - - \code - if (something || something_else) - x; - \endcode - - with - - \code - if (something) - x; - else if (something_else) - x; - \endcode - - \li \c && or \c || - \row - \li Swap Operands - \li Rewrites an expression in the inverse order using the inverse - operator. For example, rewrites: - \code - a op b - \endcode - - as - \code - b flipop a - \endcode - \li \c {<=}, \c {<}, \c {>}, \c {>=}, \c {==}, \c {!=}, \c {&&} - or \c {||} - \row - \li Convert to Decimal - \li Converts an integer literal to decimal representation - \li Numeric literal - \row - \li Convert to Hexadecimal - \li Converts an integer literal to hexadecimal representation - \li Numeric literal - \row - \li Convert to Octal - \li Converts an integer literal to octal representation - \li Numeric literal - \row - \li Convert to Objective-C String Literal - \li Converts a string literal to an Objective-C string literal if - the file type is Objective-C(++). For example, rewrites the - following strings - - \code - "abcd" - QLatin1String("abcd") - QLatin1Literal("abcd") - \endcode - - as - - \code - @"abcd" - \endcode - \li String literal - \row - \li Enclose in QLatin1Char() - \li Sets the encoding for a character to Latin-1, unless the - character is already enclosed in QLatin1Char, QT_TRANSLATE_NOOP, - tr, trUtf8, QLatin1Literal, or QLatin1String. For example, - rewrites - - \code - 'a' - \endcode - - as - - \code - QLatin1Char('a') - \endcode - \li String literal - \row - \li Enclose in QLatin1String() - \li Sets the encoding for a string to Latin-1, unless the string is - already enclosed in QLatin1Char, QT_TRANSLATE_NOOP, tr, trUtf8, - QLatin1Literal, or QLatin1String. For example, rewrites - \code - "abcd" - \endcode - - as - - \code - QLatin1String("abcd") - \endcode - - \li String literal - - \row - \li Mark as Translatable - \li Marks a string translatable. For example, rewrites \c "abcd" - with one of the following options, depending on which of them is - available: - - \code - tr("abcd") - QCoreApplication::translate("CONTEXT", "abcd") - QT_TRANSLATE_NOOP("GLOBAL", "abcd") - \endcode - - \li String literal - - \row - \li Add Definition in ... - \li Inserts a definition stub for a function declaration either in - the header file (inside or outside the class) or in the - implementation file. For free functions, inserts the definition - after the declaration of the function or in the implementation - file. Qualified names are minimized when possible, instead of - always being fully expanded. - - For example, rewrites - - \code - Class Foo { - void bar(); - }; - \endcode - - as (inside class) - - \code - Class Foo { - void bar() { - - } - }; - \endcode - - as (outside class) - - \code - Class Foo { - void bar(); - }; - - void Foo::bar() - { - - } - \endcode - - as (in implementation file) - - \code - // Header file - Class Foo { - void bar(); - }; - - // Implementation file - void Foo::bar() - { - - } - \endcode - - \li Function name - \row - \li Add \c Function Declaration - \li Inserts the member function declaration that matches the member - function definition into the class declaration. The function can - be \c {public}, \c {protected}, \c {private}, \c {public slot}, - \c {protected slot}, or \c {private slot}. - \li Function name - \row - \li Add Class Member - \li Adds a member declaration for the class member being - initialized if it is not yet declared. If \QC cannot - automatically detect the data type of the member, you - must add it. - \li Identifier - \row - \li Create Implementations for Member Functions - \li Creates implementations for all member functions in one go. - In the \uicontrol {Member Function Implementations} dialog, - you can specify whether the member functions are generated - inline or outside the class. - \li Function name - \row - \li Switch with Next/Previous Parameter - \li Moves a parameter down or up one position in a parameter list. - \li Parameter in the declaration or definition of a function - \row - \li Extract Function - \li Moves the selected code to a new function and replaces the block - of code with a call to the new function. Enter a name for the - function in the \uicontrol {Extract Function Refactoring} - dialog. - \li Block of code selected - \row - \li Extract Constant as Function Parameter - \li Replaces the selected literal and all its occurrences with the - function parameter \c{newParameter}. The parameter - \c{newParameter} will have the original literal as the default - value. - \li Block of code selected - \row - \li Add Local Declaration - \li Adds the type of an assignee, if the type of the right-hand - side of the assignment is known. For example, rewrites - - \code - a = foo(); - \endcode - - as - - \code - Type a = foo(); - \endcode - - where Type is the return type of \c {foo()} - - \li Assignee - - \row - \li Convert to Camel Case - \li Converts a symbol name to camel case, where elements of the name - are joined without delimiter characters and the initial - character of each element is capitalized. For example, rewrites - \c an_example_symbol as \c anExampleSymbol and - \c AN_EXAMPLE_SYMBOL as \c AnExampleSymbol - \li Identifier - \row - \li Complete Switch Statement - \li Adds all possible cases to a switch statement of the type - \c enum - \li \c switch - \row - \li Generate Missing Q_PROPERTY Members - \li Adds missing members to a \c Q_PROPERTY: - \list - \li \c read function - \li \c write function, if there is a WRITE - \li \c {onChanged} signal, if there is a NOTIFY - \li data member with the name \c {m_} - \endlist - \li \c Q_PROPERTY - \row - \li Generate Q_PROPERTY and Missing Members - \li Generates a Q_PROPERTY and adds missing members to it, as - described above. - \li Class member - \row - \li Generate Constant Q_PROPERTY and Missing Members - \li Generates a constant Q_PROPERTY and adds missing members - to it, as described above. - \li Class member - \row - \li Generate Q_PROPERTY and Missing Members with Reset Function - \li Generates a Q_PROPERTY and adds missing members to it, as - described above, but with an additional \c reset function. - \li Class member - \row - \li Apply Changes - \li Keeps function declarations and definitions synchronized by - checking for the matching declaration or definition when you - edit a function signature and by applying the changes to the - matching code. - \li Function signature. When this action is available, a light bulb - icon appears: \inlineimage icons/refactormarker.png - \row - \li Add #include for undeclared or forward declared identifier - \li Adds an \c {#include} directive to the current file to make the - definition of a symbol available. - \li Undeclared identifier - \row - \li Add Forward Declaration - \li Adds a forward declaration for an undeclared identifier - operation. - \li Undeclared identifier - \row - \li Reformat Pointers or References - \li Reformats declarations with pointers or references according - to the code style settings for the current project. In case no - project is open, the current global code style settings are - used. - - For example, rewrites: - - \code - char*s; - \endcode - - as - - \code - char *s; - \endcode - - When applied to selections, all suitable declarations in the - selection are rewritten. - - \li Declarations with pointers or references and selections - that have such declarations - \row - \li Create Getter and Setter Member Functions - \li Creates either both getter and setter member functions for - member variables or only a getter or setter. - \li Member variable in class definition - \row - \li Generate Getter and Setter - \li Creates getter and setter member functions for a member - variable. - \li Member variable in class definition - \row - \li Generate Getter - \li Creates a getter member function for a member variable. - \li Member variable in class definition - \row - \li Generate Setter - \li Creates a setter member function for a member variable. - \li Member variable in class definition - \row - \li Generate Constructor - \li Creates a constructor for a class. - \li Class definition - \row - \li Move Function Definition - \li Moves a function definition to the implementation file, outside - the class or back to its declaration. For example, rewrites: - \code - class Foo - { - void bar() - { - // do stuff here - } - }; - \endcode - - as - \code - class Foo - { - void bar(); - }; - - void Foo::bar() { - // do stuff here - } - \endcode - - \li Function signature - \row - \li Move All Function Definitions - \li Moves all function definitions to the implementation file or - outside the class. For example, rewrites: - \code - class Foo - { - void bar() - { - // do stuff here - } - void baz() - { - // do stuff here - } - }; - \endcode - - as - - \code - class Foo - { - void bar(); - void baz(); - }; - - void Foo::bar() { - // do stuff here - } - - void Foo::baz() { - // do stuff here - } - \endcode - - \li Class name - \row - \li Assign to Local Variable - \li Adds a local variable which stores the return value of a - function call or a new expression. For example, rewrites: - - \code - QString s; - s.toLatin1(); - \endcode - - as - - \code - QString s; - QByteArray latin1 = s.toLatin1(); - \endcode - - and - - \code - new Foo; - \endcode - - as - - \code - Foo * localFoo = new Foo; - \endcode - - By default, \QC uses the \c auto variable type when creating the - variable. To label the variable with its actual type, select - \preferences > \uicontrol C++ > - \uicontrol {Quick Fixes}, and then deselect the - \uicontrol {Use type "auto" when creating new variables} check - box. - - \li Function call or class name - \row - \li Insert Virtual Functions of Base Classes - \li Inserts declarations and the corresponding definitions inside or - outside the class or in an implementation file (if it exists). - For more information, see \l{Inserting Virtual Functions}. - \li Class or base class name - \row - \li Optimize for-Loop - \li Rewrites post increment operators as pre increment operators and - post decrement operators as pre decrement operators. It also - moves other than string or numeric literals and id expressions - from the condition of a for loop to its initializer. For - example, rewrites: - - \code - for (int i = 0; i < 3 * 2; i++) - \endcode - - as - - \code - for (int i = 0, total = 3 * 2; i < total; ++i) - \endcode - \li \c for - - \row - \li Escape String Literal as UTF-8 - \li Escapes non-ASCII characters in a string literal to hexadecimal - escape sequences. String Literals are handled as UTF-8. - \li String literal - - \row - \li Unescape String Literal as UTF-8 - \li Unescapes octal or hexadecimal escape sequences in a string - literal. String Literals are handled as UTF-8. - \li String literal - - \row - \li Convert to Stack Variable - \li Converts the selected pointer to a stack variable. For example, - rewrites: - - \code - QByteArray *foo = new QByteArray("foo"); - foo->append("bar"); - \endcode - - as - - \code - QByteArray foo("foo"); - foo.append("bar"); - \endcode - - This operation is limited to work only within function scope. - Also, the coding style for pointers and references is not - respected yet. - \li Pointer Variable - - \row - \li Convert to Pointer - \li Converts the selected stack variable to a pointer. For example, - rewrites: - - \code - QByteArray foo = "foo"; - foo.append("bar"); - \endcode - - as - - \code - QByteArray *foo = new QByteArray("foo"); - foo->append("bar"); - \endcode - - This operation is limited to work only within function scope. - Also, the coding style for pointers and references is not - respected yet. - \li Stack Variable - \row - \li Remove \c {using namespace} and Adjust Type Names Accordingly - \li Remove occurrences of \c {using namespace} in the local scope - and adjust type names accordingly. - \li \c using directive - \row - \li Remove All Occurrences of \c {using namespace} in Global Scope - and Adjust Type Names Accordingly - \li Remove all occurrences of \c {using namespace} in the global - scope and adjust type names accordingly. - \li \c using directive - \row - \li Convert connect() to Qt 5 Style - \li Converts a Qt 4 QObject::connect() to Qt 5 style. - \li QObject::connect() (Qt 4 style) - \row - \li Convert Comment to C/C++ Style - \li Converts C-style comments into C++-style comments, and vice - versa. Tries to preserve \e pretty layout and takes Doxygen and - qdoc formatting into consideration, but you might need to clean - up the results. - \li Code comment - \row - \li Move Function Documentation to Declaration/Definition - \li Moves the documentation comment for a function between its - declaration and definition. - \li Documentation comment for a function - \endtable - - \section2 Refactoring QML Code + \sa {QML Quick Fixes}, {Refactoring} +*/ + +/*! + \page creator-reference-qml-quick-fixes.html + \if defined(qtdesignstudio) + \previouspage creator-editor-refactoring.html + \else + \previouspage creator-reference.html \endif - You can apply the following types of refactoring actions to QML code: + \ingroup creator-reference + + \title QML Quick Fixes + + \brief Summary of quick fixes for QML code. + + Apply the following types of quick fixes to QML code: \list \li Rename IDs @@ -851,13 +113,13 @@ \li Move a QML type into a separate file to reuse it in other .qml files \endlist - The following table summarizes the refactoring actions for QML code. The + The following table summarizes the quick fixes for QML code. The action is available when the cursor is in the position described in the Activation column. \table \header - \li Refactoring Action + \li Quick Fix \li Description \li Activation @@ -905,4 +167,11 @@ \li Error, warning or hint from static analysis \endtable - */ + + \sa {Apply quick fixes}, {Refactoring} + + \if defined(qtcreator) + \sa {Exclude files from to-do lists}, {Specify settings for quick fixes}, + {Quick Fixes}, {C++ Quick Fixes} + \endif +*/ diff --git a/doc/qtcreator/src/projects/creator-only/creator-projects-settings-overview.qdoc b/doc/qtcreator/src/projects/creator-only/creator-projects-settings-overview.qdoc index ee60f98b327..98706bdc0af 100644 --- a/doc/qtcreator/src/projects/creator-only/creator-projects-settings-overview.qdoc +++ b/doc/qtcreator/src/projects/creator-only/creator-projects-settings-overview.qdoc @@ -87,7 +87,7 @@ \li \l{Document code}{Documentation Comments} \li \l{Specify editor settings}{Editor} \li \l{Specify the environment for projects}{Environment} - \li \l{Applying Refactoring Actions}{Quick Fixes} + \li \l{Specify settings for quick fixes}{Quick Fixes} \li \l{Exclude files from to-do lists}{To-Do} (experimental) \endlist diff --git a/doc/qtcreator/src/qtcreator-toc.qdoc b/doc/qtcreator/src/qtcreator-toc.qdoc index 9409f1c7cd3..9bfc575567a 100644 --- a/doc/qtcreator/src/qtcreator-toc.qdoc +++ b/doc/qtcreator/src/qtcreator-toc.qdoc @@ -43,7 +43,6 @@ \li \l{Searching with the Locator} \endlist \li \l{Refactoring} - \li \l{Applying Refactoring Actions} \li \l{Beautifying Source Code} \li \l{Configuring the Editor} \list diff --git a/doc/qtdesignstudio/src/qtdesignstudio-toc.qdoc b/doc/qtdesignstudio/src/qtdesignstudio-toc.qdoc index 75cbeddf0a8..29ef0a9b240 100644 --- a/doc/qtdesignstudio/src/qtdesignstudio-toc.qdoc +++ b/doc/qtdesignstudio/src/qtdesignstudio-toc.qdoc @@ -216,7 +216,6 @@ \li \l{Jump to the Code} \endlist \li \l{Refactoring} - \li \l{Applying Refactoring Actions} \li \l{Configuring the Editor} \list \li \l{Font & Colors}