Doc: Split up Refactoring into how-to topics

- Move info about viewing search results to the Search Results View
  reference topic
- Remove the Refactoring top-level topic (the general info is now in
  the Overview topic)

Task-number: QTCREATORBUG-29361
Change-Id: I4072e628368905ed1d5006ececae1b9eaa02fa10
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Leena Miettinen
2024-02-19 11:32:11 +01:00
parent 51ca09c2d7
commit 642c4beac1
17 changed files with 155 additions and 123 deletions

View File

@@ -2,100 +2,35 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*! /*!
\page creator-editor-refactoring.html \page creator-how-to-rename-symbols.html
\previouspage creator-jump-to-the-code.html \if defined(qtdesignstudio)
\nextpage creator-editor-options.html \previouspage studio-finding.html
\title Refactoring
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 >
\uicontrol System > \uicontrol {Auto-save files after refactoring}.
\if defined(qtcreator)
\section1 Finding Symbols
To find instances of a specific symbol in your Qt C++ project, place the
cursor on the symbol in the editor and select \uicontrol Tools >
\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}
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 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
the code, such as include files.
\image qtcreator-search-cpp-symbols.png
\endif
\section1 Viewing Search Results
\QC searches from the following locations:
\list
\li Files listed as a part of the project
\li Files directly used by the project files (for example, generated
files)
\if defined(qtcreator)
\li Header files of used frameworks and libraries
\endif
\endlist
\l{Search Results View} shows the location and number of search hits in the
current project.
\if defined(qtcreator)
\image qtcreator-refactoring-find.png
\else \else
\image qml-find-usages.png \previouspage creator-how-tos.html
\endif \endif
Browse the search results in the following ways: \ingroup creator-how-to-search
\list \title Rename symbols
\li To go directly to an instance, double-click the instance in
\uicontrol {Search Results}.
\li To move between instances, click the \inlineimage icons/next.png
(\uicontrol {Next Item}) button and \inlineimage icons/prev.png
(\uicontrol {Previous Item}) button in \uicontrol {Search Results}.
\li To expand and collapse the list of all instances, click the
\inlineimage icons/qtcreator-expand.png
(\uicontrol {Expand All}) button.
\li To filter the search results for the usage of symbols according to
access type, such as read, write, or declaration, click the
\inlineimage icons/filtericon.png
(\uicontrol {Filter Tree}) button and select the access type.
\li To clear the search results, click the
\inlineimage icons/clean_pane_small.png
(\uicontrol Clear) button.
\li To start a new search, click the
\inlineimage icons/qtcreator-new-search-icon.png
(\uicontrol {New Search}) button.
\endlist
\section1 Renaming Symbols
You can rename symbols in all files in a project. You can rename symbols in all files in a project.
\if defined(qtcreator) \if defined(qtcreator)
When you rename a class, you can also change filenames that match the When you rename a class, you can also change filenames that match the
class name. class name.
To rename a C++ symbol in a project, place the cursor To rename a C++ symbol in a project:
on it and select \uicontrol Tools > \uicontrol {C++} >
\uicontrol {Rename Symbol Under Cursor} or press \key {Ctrl+Shift+R}. \list 1
\li Place the cursor on the symbol in the editor.
\li Go to \uicontrol Tools > \uicontrol {C++} >
\uicontrol {Rename Symbol Under Cursor}, or press \key {Ctrl+Shift+R}.
Use the keyboard shortcut to rename Python symbols. Use the keyboard shortcut to rename Python symbols.
\endlist
\endif \endif
To rename a QML type in a project, select \uicontrol Tools > To rename a QML type in a project, go to \uicontrol Tools >
\uicontrol {QML/JS} > \uicontrol {Rename Symbol Under Cursor} \uicontrol {QML/JS} > \uicontrol {Rename Symbol Under Cursor}
or press \key {Ctrl+Shift+R}. or press \key {Ctrl+Shift+R}.
@@ -109,23 +44,23 @@
\endif \endif
To replace all selected instances, enter the name of the new symbol To replace all selected instances, enter the name of the new symbol
in the \uicontrol {Replace with} text box, and select \uicontrol Replace. in \uicontrol {Replace with}, and select \uicontrol Replace.
To omit an instance, deselect the check box next to the instance. To omit an instance, clear the check box next to the instance.
\note This action replaces all selected instances of the symbol in \note This action replaces all selected instances of the symbol in
all files listed in \uicontrol {Search Results}. You cannot all files listed in \uicontrol {Search Results}. You cannot
undo this action. undo this action.
\if defined(qtcreator) \if defined(qtcreator)
If the symbol is a class, select the \uicontrol {Rename files} check If the symbol is a class, select \uicontrol {Rename files} to also change
box to also change the filenames that match the class name. the filenames that match the class name.
\note Renaming local symbols does not open \uicontrol {Search Results}. \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. the symbol. All instances of the local symbol are changed as you type.
\sa {Specify settings for quick fixes}, {Quick Fixes}, {C++ Quick Fixes} \sa {Find symbols}, {Specify settings for quick fixes}, {Quick Fixes},
{C++ Quick Fixes}
\endif \endif
\sa {Apply quick fixes}, {QML Quick Fixes} \sa {Apply quick fixes}, {QML Quick Fixes}

View File

@@ -46,13 +46,6 @@
and file systems. and file systems.
\endif \endif
\li \l{Refactoring}
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.
\li \l{Configuring the Editor} \li \l{Configuring the Editor}
You can change the fonts, colors, highlighting, and indentation. You can change the fonts, colors, highlighting, and indentation.
@@ -65,5 +58,7 @@
\if defined(qtcreator) \if defined(qtcreator)
\sa {Using GitHub Copilot} \sa {Using GitHub Copilot}
\else
\sa {Apply quick fixes}
\endif \endif
*/ */

View File

@@ -38,7 +38,9 @@
\li \l{View function tooltips}{Tooltips} \li \l{View function tooltips}{Tooltips}
\li \l{Finding Symbols}{Finding and renaming symbols} \li \l{Find symbols}{Finding symbols}
\li \l{Rename symbols}{Renaming symbols}
\li \l{Apply quick fixes}{Quick fixes} \li \l{Apply quick fixes}{Quick fixes}

View File

@@ -70,8 +70,8 @@
To return non-trivial objects by using a \c const reference, select the To return non-trivial objects by using a \c const reference, select the
\uicontrol {Return non-value types by const reference} check box. \uicontrol {Return non-value types by const reference} check box.
\sa {Apply quick fixes}, {Specify settings for quick fixes}, \sa {Apply quick fixes}, {Find symbols}, {Rename symbols},
{C++ Quick Fixes}, {QML Quick Fixes}, {Refactoring} {Specify settings for quick fixes}, {C++ Quick Fixes}, {QML Quick Fixes}
*/ */
/*! /*!
@@ -786,8 +786,8 @@
\li Documentation comment for a function \li Documentation comment for a function
\endtable \endtable
\sa {Apply quick fixes}, {Specify settings for quick fixes}, \sa {Apply quick fixes}, {Find symbols}, {Rename symbols},
{QML Quick Fixes}, {Quick Fixes}, {Refactoring} {Specify settings for quick fixes}, {QML Quick Fixes}, {Quick Fixes}
*/ */
/*! /*!
@@ -811,6 +811,6 @@
delete the custom settings, select \uicontrol {Use global settings}, and delete the custom settings, select \uicontrol {Use global settings}, and
then select \uicontrol {Delete Custom Settings File}. then select \uicontrol {Delete Custom Settings File}.
\sa {Apply quick fixes}, {C++ Quick Fixes}, {QML Quick Fixes}, {Quick Fixes}, \sa {Apply quick fixes}, {Find symbols}, {Rename symbols},
{Configuring Projects}, {Refactoring} {C++ Quick Fixes}, {QML Quick Fixes}, {Quick Fixes}, {Configuring Projects}
*/ */

View File

@@ -0,0 +1,60 @@
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page creator-editor-how-to-find-symbols.html
\previouspage creator-how-tos.html
\ingroup creator-how-to-search
\title Find symbols
You can search for references to a particular symbol or search for symbols
with a name that matches a pattern.
\section1 Find references to a symbol
To find instances of a particular symbol in your Qt C++ project:
\list 1
\li Place the cursor on the symbol in the editor.
\li Go to \uicontrol Tools > \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}
\endlist
\section2 Color-code access type
To view the same results color-coded according to the access type, such as
read, write, or declaration, go to \uicontrol Tools > \uicontrol {C++} >
\uicontrol {Find References with Access Type}.
\section1 Find symbols that match search criteria
Go to \uicontrol Edit > \uicontrol {Find/Replace} >
\uicontrol {Advanced Find} and select \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
the code, such as include files.
\image qtcreator-search-cpp-symbols.png
\QC searches from the following locations:
\list
\li Files listed as a part of the project
\li Files directly used by the project files (for example, generated
files)
\li Header files of used frameworks and libraries
\endlist
\section1 View found symbols
\l{Search Results View} shows the location and number of search hits in the
current project.
\image qtcreator-refactoring-find.png
\sa {Search}{How To: Search}, {Search Results View}
*/

View File

@@ -36,8 +36,8 @@
\l{Outline} view or in the \uicontrol Symbols list on the \l{Outline} view or in the \uicontrol Symbols list on the
\l{Edit Mode}{editor toolbar} \l{Edit Mode}{editor toolbar}
\li \l{Call Hierarchy}{Viewing the callers and callees of a function} \li \l{Call Hierarchy}{Viewing the callers and callees of a function}
\li \l{Finding Symbols}{Finding references to symbols} \li \l{Find references to a symbol}{Finding references to symbols}
\li \l{Renaming Symbols}{Renaming the symbol under cursor} \li \l{Rename symbols}{Renaming the symbol under the cursor}
\li Code actions \li Code actions
\li Displaying diagnostics from the language server as tooltips. You can \li Displaying diagnostics from the language server as tooltips. You can
also select a code range to display diagnostics for. also select a code range to display diagnostics for.

View File

@@ -4,12 +4,14 @@
/*! /*!
\page creator-editor-quick-fixes.html \page creator-editor-quick-fixes.html
\if defined(qtdesignstudio) \if defined(qtdesignstudio)
\previouspage creator-editor-refactoring.html \previouspage creator-jump-to-the-code.html
\nextpage creator-reference-qml-quick-fixes.html
\else \else
\previouspage creator-how-tos.html \previouspage creator-how-tos.html
\endif \endif
\ingroup creator-how-to-edit \ingroup creator-how-to-edit
\ingroup studio-code-view
\title Apply quick fixes \title Apply quick fixes
@@ -35,6 +37,10 @@
Or, press \key {Alt+Enter} to open a context menu that has Or, press \key {Alt+Enter} to open a context menu that has
quick fixes available in the current cursor position. quick fixes available in the current cursor position.
By default, the refactored files are saved automatically. To turn off
this feature, go to \preferences > \uicontrol Environment >
\uicontrol System and select \uicontrol {Auto-save files after refactoring}.
\if defined(qtcreator) \if defined(qtcreator)
\section1 Create functions \section1 Create functions
@@ -85,21 +91,24 @@
\image qtcreator-refactoring-constructor.png "Constructor dialog" \image qtcreator-refactoring-constructor.png "Constructor dialog"
\sa {Specify settings for quick fixes}, {Quick Fixes}, {C++ Quick Fixes} \sa {Find symbols}, {Specify settings for quick fixes}, {Quick Fixes},
{C++ Quick Fixes}
\endif \endif
\sa {QML Quick Fixes}, {Refactoring} \sa {Rename symbols}, {QML Quick Fixes}
*/ */
/*! /*!
\page creator-reference-qml-quick-fixes.html \page creator-reference-qml-quick-fixes.html
\if defined(qtdesignstudio) \if defined(qtdesignstudio)
\previouspage creator-editor-refactoring.html \previouspage creator-editor-quick-fixes.html
\nextpage creator-editor-options.html
\else \else
\previouspage creator-reference.html \previouspage creator-reference.html
\endif \endif
\ingroup creator-reference \ingroup creator-reference
\ingroup studio-code-view
\title QML Quick Fixes \title QML Quick Fixes
@@ -168,10 +177,10 @@
\endtable \endtable
\sa {Apply quick fixes}, {Refactoring} \sa {Apply quick fixes}, {Rename symbols}
\if defined(qtcreator) \if defined(qtcreator)
\sa {Exclude files from to-do lists}, {Specify settings for quick fixes}, \sa {Exclude files from to-do lists}, {Find symbols},
{Quick Fixes}, {C++ Quick Fixes} {Specify settings for quick fixes}, {Quick Fixes}, {C++ Quick Fixes}
\endif \endif
*/ */

View File

@@ -215,7 +215,7 @@
\l {Preserve case when replacing} apply here as well. \l {Preserve case when replacing} apply here as well.
\if defined(qtcreator) \if defined(qtcreator)
\sa {Search}{How To: Search}, {Finding Symbols}, {Turn on Silver Searcher} \sa {Search}{How To: Search}, {Find symbols}, {Turn on Silver Searcher}
\else \else
\sa {Search in current file} \sa {Search in current file}
\endif \endif

View File

@@ -36,7 +36,6 @@
\li \l{Using Text Editing Macros} \li \l{Using Text Editing Macros}
\li \l{Comparing Files} \li \l{Comparing Files}
\endlist \endlist
\li \l{Refactoring}
\li \l{Configuring the Editor} \li \l{Configuring the Editor}
\li \l{Using GitHub Copilot} \li \l{Using GitHub Copilot}
\endlist \endlist

View File

@@ -50,7 +50,6 @@
\li \b {\l{Coding}} \li \b {\l{Coding}}
\list \list
\li \l{Writing Code} \li \l{Writing Code}
\li \l{Refactoring}
\li \l{Configuring the Editor} \li \l{Configuring the Editor}
\endlist \endlist
\li \b {\l{Building and Running}} \li \b {\l{Building and Running}}

View File

@@ -49,7 +49,7 @@
automatically save changed files at the intervals specified in automatically save changed files at the intervals specified in
the \uicontrol Interval field. the \uicontrol Interval field.
\li Select the \uicontrol {Auto-save files after refactoring} check \li Select the \uicontrol {Auto-save files after refactoring} check
box to automatically save \l{Refactoring}{refactored files}. box to automatically save refactored files.
\li Select the \uicontrol {Auto-suspend unmodified files} check \li Select the \uicontrol {Auto-suspend unmodified files} check
box to automatically free the resources of open files after box to automatically free the resources of open files after
prolonged inactivity. The files are still listed in the prolonged inactivity. The files are still listed in the
@@ -62,4 +62,10 @@
field, set the number of recently opened files listed in field, set the number of recently opened files listed in
\uicontrol File > \uicontrol {Recent Files}. \uicontrol File > \uicontrol {Recent Files}.
\endlist \endlist
\sa {Apply quick fixes}, {Rename symbols}
\if defined(qtcreator)
\sa {Find symbols}
\endif
*/ */

View File

@@ -142,8 +142,14 @@
\list \list
\li To clear the search results, select \li To clear the search results, select
\inlineimage icons/clean_pane_small.png (\uicontrol Clear). \inlineimage icons/clean_pane_small.png (\uicontrol Clear).
\li To move between instances, select \inlineimage icons/next.png
(\uicontrol {Next Item}) and \inlineimage icons/prev.png
(\uicontrol {Previous Item}).
\li To expand and collapse the search results, select \li To expand and collapse the search results, select
\inlineimage icons/qtcreator-expand.png (\uicontrol {Expand All}). \inlineimage icons/qtcreator-expand.png (\uicontrol {Expand All}).
\li To filter the search results for the usage of symbols according to
access type, such as read, write, or declaration, select
\inlineimage icons/filtericon.png (\uicontrol {Filter Tree}).
\li To start a new search, select \li To start a new search, select
\inlineimage icons/qtcreator-new-search-icon.png \inlineimage icons/qtcreator-new-search-icon.png
(\uicontrol {New Search}). (\uicontrol {New Search}).

View File

@@ -4,7 +4,7 @@
/*! /*!
\previouspage creator-editor-locator.html \previouspage creator-editor-locator.html
\page creator-jump-to-the-code.html \page creator-jump-to-the-code.html
\nextpage creator-editor-refactoring.html \nextpage creator-editor-quick-fixes.html
\title Jump to the Code \title Jump to the Code

View File

@@ -20,6 +20,10 @@
With advanced search, you can search in currently open projects or With advanced search, you can search in currently open projects or
files on the file system. files on the file system.
\li \l{Rename symbols}
Search for QML types and rename them in all files in a project.
\li \l{Searching with the Locator} \li \l{Searching with the Locator}
Use the locator to browse Use the locator to browse

View File

@@ -109,7 +109,7 @@
However, you can rename symbols in all files within a project. To rename a However, you can rename symbols in all files within a project. To rename a
QML type in a project, select \uicontrol Tools > \uicontrol QML/JS > QML type in a project, select \uicontrol Tools > \uicontrol QML/JS >
\uicontrol {Rename Symbol Under Cursor} or press \key Ctrl+Shift+R. For more \uicontrol {Rename Symbol Under Cursor} or press \key Ctrl+Shift+R. For more
information, see \l {Renaming Symbols}. information, see \l {Rename symbols}.
\section2 How can I add .qml files to my project in Qt Creator? \section2 How can I add .qml files to my project in Qt Creator?

View File

@@ -213,10 +213,12 @@
\list \list
\li \l{Search in current file} \li \l{Search in current file}
\li \l{Search in projects or file systems} \li \l{Search in projects or file systems}
\li \l{Rename symbols}
\li \l{Searching with the Locator} \li \l{Searching with the Locator}
\li \l{Jump to the Code} \li \l{Jump to the Code}
\endlist \endlist
\li \l{Refactoring} \li \l{Apply quick fixes}
\li \l{QML quick fixes}
\li \l{Configuring the Editor} \li \l{Configuring the Editor}
\list \list
\li \l{Font & Colors} \li \l{Font & Colors}

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2021 The Qt Company Ltd. // Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*! /*!
@@ -17,10 +17,6 @@
You can also view and modify other types of text files. You can also view and modify other types of text files.
To open the search dialog in the \uicontrol {Code} view, go to
\uicontrol Edit > \uicontrol {Find/Replace} > \uicontrol {Find/Replace}.
You can also select \key Ctrl + \key {F}.
The view offers the following features: The view offers the following features:
\list \list
@@ -30,4 +26,23 @@
\li \l{Indent text or code} \li \l{Indent text or code}
\li \l{Using Qt Quick Toolbars} \li \l{Using Qt Quick Toolbars}
\endlist \endlist
\section1 Refactoring Code
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 quick fixes in the \uicontrol Code view to
refactor code.
\section1 Searching in Code
To open the search dialog in the \uicontrol {Code} view:
\list
\li Go to \uicontrol Edit > \uicontrol {Find/Replace} >
\uicontrol {Find/Replace}.
\li Select \key Ctrl + \key {F} (or \key Cmd + \key F on \macos).
\endlist
\sa {Finding}, {Apply quick fixes}, {QML Quick Fixes}
*/ */