aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dist/changes-4.8.2.md72
-rw-r--r--doc/images/qtcreator-generic-highlighter.pngbin12342 -> 0 bytes
-rw-r--r--doc/images/qtcreator-manage-definitions.pngbin10729 -> 0 bytes
-rw-r--r--doc/images/qtcreator-syntax-highlighter.pngbin0 -> 29169 bytes
-rw-r--r--doc/src/editors/creator-semantic-highlighting.qdoc69
-rw-r--r--qbs/modules/qtc/qtc.qbs2
-rw-r--r--qtcreator.pri2
-rw-r--r--qtcreator.pro3
-rw-r--r--src/app/app-Info.plist2
-rw-r--r--src/app/app.pro2
-rw-r--r--src/libs/3rdparty/syntax-highlighting/src/lib/repository.cpp17
-rw-r--r--src/libs/3rdparty/syntax-highlighting/src/lib/repository.h12
-rw-r--r--src/libs/clangsupport/commandlinebuilder.h17
-rw-r--r--src/libs/clangsupport/filepath.h4
-rw-r--r--src/libs/clangsupport/nativefilepath.h13
-rw-r--r--src/libs/languageserverprotocol/languagefeatures.cpp4
-rw-r--r--src/libs/libs.pro2
-rw-r--r--src/libs/utils/fancylineedit.cpp9
-rw-r--r--src/libs/utils/fancylineedit.h2
-rw-r--r--src/libs/utils/pathchooser.cpp13
-rw-r--r--src/libs/utils/smallstringview.h3
-rw-r--r--src/libs/utils/treemodel.h5
-rw-r--r--src/plugins/autotest/testresultmodel.cpp48
-rw-r--r--src/plugins/autotest/testresultmodel.h4
-rw-r--r--src/plugins/autotoolsprojectmanager/makefileparser.cpp23
-rw-r--r--src/plugins/clangcodemodel/clangbackendcommunicator.cpp6
-rw-r--r--src/plugins/clangcodemodel/clangtextmark.cpp1
-rw-r--r--src/plugins/clangtools/clangtidyclazytool.cpp7
-rw-r--r--src/plugins/clangtools/clangtidyclazytool.h2
-rw-r--r--src/plugins/clangtools/clangtool.h2
-rw-r--r--src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp117
-rw-r--r--src/plugins/clangtools/clangtoolsdiagnosticmodel.h2
-rw-r--r--src/plugins/coreplugin/infobar.cpp19
-rw-r--r--src/plugins/coreplugin/infobar.h4
-rw-r--r--src/plugins/cppeditor/cppautocompleter.h2
-rw-r--r--src/plugins/cppeditor/cppcodemodelinspectordialog.cpp143
-rw-r--r--src/plugins/cppeditor/cppcodemodelinspectordialog.h6
-rw-r--r--src/plugins/cppeditor/cppdocumentationcommenthelper.cpp2
-rw-r--r--src/plugins/cppeditor/cppeditordocument.cpp14
-rw-r--r--src/plugins/cppeditor/cppeditordocument.h10
-rw-r--r--src/plugins/cppeditor/cppeditorplugin.cpp2
-rw-r--r--src/plugins/cppeditor/cppeditorplugin.h2
-rw-r--r--src/plugins/cppeditor/cppeditorwidget.cpp22
-rw-r--r--src/plugins/cppeditor/cppfunctiondecldeflink.cpp40
-rw-r--r--src/plugins/cppeditor/cppfunctiondecldeflink.h2
-rw-r--r--src/plugins/cppeditor/cpphighlighter.h2
-rw-r--r--src/plugins/cppeditor/cppincludehierarchy.cpp12
-rw-r--r--src/plugins/cppeditor/cppincludehierarchy.h2
-rw-r--r--src/plugins/cppeditor/cppinsertvirtualmethods.cpp137
-rw-r--r--src/plugins/cppeditor/cppinsertvirtualmethods.h6
-rw-r--r--src/plugins/cppeditor/cppminimizableinfobars.h2
-rw-r--r--src/plugins/cppeditor/cpppreprocessordialog.h4
-rw-r--r--src/plugins/cppeditor/cppquickfix.cpp3
-rw-r--r--src/plugins/cppeditor/cppquickfix.h4
-rw-r--r--src/plugins/cppeditor/cppquickfixassistant.h2
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp371
-rw-r--r--src/plugins/cppeditor/cppquickfixes.h4
-rw-r--r--src/plugins/cppeditor/cpptypehierarchy.cpp14
-rw-r--r--src/plugins/cppeditor/cpptypehierarchy.h8
-rw-r--r--src/plugins/cppeditor/cppuseselectionsupdater.h2
-rw-r--r--src/plugins/cppeditor/resourcepreviewhoverhandler.cpp3
-rw-r--r--src/plugins/cpptools/builtincursorinfo.cpp20
-rw-r--r--src/plugins/cpptools/clangdiagnosticconfigswidget.cpp12
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp2
-rw-r--r--src/plugins/cpptools/cppcodemodelsettings.cpp4
-rw-r--r--src/plugins/cpptools/cppcodestylepreferences.cpp2
-rw-r--r--src/plugins/cpptools/cppcodestylesettings.cpp34
-rw-r--r--src/plugins/cpptools/cppcodestylesettings.h42
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp5
-rw-r--r--src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp8
-rw-r--r--src/plugins/cpptools/cppprojectfilecategorizer.cpp2
-rw-r--r--src/plugins/cpptools/cppqtstyleindenter.cpp2
-rw-r--r--src/plugins/cpptools/cpprefactoringchanges.cpp4
-rw-r--r--src/plugins/cpptools/cppselectionchanger.cpp12
-rw-r--r--src/plugins/cpptools/doxygengenerator.cpp7
-rw-r--r--src/plugins/cpptools/doxygengenerator.h8
-rw-r--r--src/plugins/cpptools/insertionpointlocator.cpp11
-rw-r--r--src/plugins/cpptools/insertionpointlocator.h4
-rw-r--r--src/plugins/cpptools/searchsymbols.h2
-rw-r--r--src/plugins/cpptools/symbolsfindfilter.cpp6
-rw-r--r--src/plugins/perfprofiler/perftracepointdialog.cpp28
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/plugins/projectexplorer/buildconfiguration.cpp2
-rw-r--r--src/plugins/projectexplorer/kitinformation.cpp7
-rw-r--r--src/plugins/projectexplorer/projectconfigurationaspects.cpp2
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp54
-rw-r--r--src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp6
-rw-r--r--src/plugins/qbsprojectmanager/qbsbuildconfiguration.h2
-rw-r--r--src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.cpp6
-rw-r--r--src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.cpp4
-rw-r--r--src/plugins/qtsupport/qtoutputformatter.cpp22
-rw-r--r--src/plugins/texteditor/codeassist/documentcontentcompletion.cpp17
-rw-r--r--src/plugins/texteditor/highlighter.cpp37
-rw-r--r--src/plugins/texteditor/highlighter.h12
-rw-r--r--src/plugins/texteditor/indenter.h7
-rw-r--r--src/plugins/texteditor/texteditor.cpp116
-rw-r--r--src/plugins/texteditor/texteditor.h1
-rw-r--r--src/shared/shared.pro28
-rw-r--r--src/src.pro32
-rw-r--r--src/tools/clangpchmanagerbackend/source/pchcreator.cpp42
-rw-r--r--src/tools/clangpchmanagerbackend/source/pchcreator.h5
-rw-r--r--src/tools/clangrefactoringbackend/source/clangquerygatherer.cpp7
-rw-r--r--src/tools/clangrefactoringbackend/source/clangtool.cpp67
-rw-r--r--src/tools/clangrefactoringbackend/source/clangtool.h48
-rw-r--r--src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp26
-rw-r--r--src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.h6
-rw-r--r--src/tools/clangrefactoringbackend/source/refactoringserver.cpp14
m---------src/tools/perfparser0
-rw-r--r--src/tools/tools.pro5
-rw-r--r--tests/system/objects.map12
-rw-r--r--tests/unit/unittest/clangquery-test.cpp33
-rw-r--r--tests/unit/unittest/clangquerygatherer-test.cpp15
-rw-r--r--tests/unit/unittest/commandlinebuilder-test.cpp38
-rw-r--r--tests/unit/unittest/filesystem-utilities.h31
-rw-r--r--tests/unit/unittest/gtest-creator-printing.cpp14
-rw-r--r--tests/unit/unittest/gtest-creator-printing.h8
-rw-r--r--tests/unit/unittest/nativefilepath-test.cpp1
-rw-r--r--tests/unit/unittest/pchcreator-test.cpp28
-rw-r--r--tests/unit/unittest/pchtaskgenerator-test.cpp72
-rw-r--r--tests/unit/unittest/refactoringcompilationdatabase-test.cpp56
-rw-r--r--tests/unit/unittest/refactoringserver-test.cpp23
-rw-r--r--tests/unit/unittest/sourcerangeextractor-test.cpp4
-rw-r--r--tests/unit/unittest/symbolfinder-test.cpp94
-rw-r--r--tests/unit/unittest/symbolindexer-test.cpp85
-rw-r--r--tests/unit/unittest/testclangtool.cpp9
-rw-r--r--tests/unit/unittest/testclangtool.h7
126 files changed, 1413 insertions, 1218 deletions
diff --git a/dist/changes-4.8.2.md b/dist/changes-4.8.2.md
new file mode 100644
index 0000000000..22a930d9a4
--- /dev/null
+++ b/dist/changes-4.8.2.md
@@ -0,0 +1,72 @@
+Qt Creator version 4.8.2 contains bug fixes.
+
+The most important changes are listed in this document. For a complete
+list of changes, see the Git log for the Qt Creator sources that
+you can check out from the public Git repository. For example:
+
+ git clone git://code.qt.io/qt-creator/qt-creator.git
+ git log --cherry-pick --pretty=oneline origin/v4.8.1..v4.8.2
+
+Editing
+
+* Fixed highlighting of search results of regular expression search
+ (QTCREATORBUG-21887)
+
+Autotools Projects
+
+* Fixed that includes, defines and flags of `SUBDIRS` were ignored
+ (QTCREATORBUG-21618)
+
+C++ Support
+
+* Fixed crash when expanding macros (QTCREATORBUG-21642)
+
+QML Support
+
+* Fixed auto-insertion of single quotes
+
+Debugging
+
+* GDB
+ * Fixed detaching from process (QTCREATORBUG-21908)
+* LLDB
+ * Fixed stopping at some breakpoints with newer LLDB (QTCREATORBUG-21615)
+ * Fixed `Attach to Process` and `Run in Terminal` with newer LLDB
+* CDB
+ * Fixed display of `QDateTime` (QTCREATORBUG-21864)
+
+Qt Quick Designer
+
+* Added support for more JavaScript functions in `.ui.qml` files
+
+Test Integration
+
+* Fixed handling of empty tests
+
+Platform Specific
+
+macOS
+
+* Fixed crash when file change dialog is triggered while another modal dialog
+ is open
+* Fixed running of user applications that need access to camera, microphone or
+ other restricted services on macOS 10.14 (QTCREATORBUG-21887)
+
+Android
+
+* Fixed upload of GDB server on some devices (QTCREATORBUG-21317)
+
+Credits for these changes go to:
+André Pönitz
+Christian Kandeler
+Christian Stenger
+David Schulz
+Eike Ziller
+Ivan Donchevskii
+Leena Miettinen
+Liang Qi
+Oliver Wolff
+Raoul Hecky
+Robert Löhning
+Thomas Hartmann
+Vikas Pachdha
diff --git a/doc/images/qtcreator-generic-highlighter.png b/doc/images/qtcreator-generic-highlighter.png
deleted file mode 100644
index 19ccebed2b..0000000000
--- a/doc/images/qtcreator-generic-highlighter.png
+++ /dev/null
Binary files differ
diff --git a/doc/images/qtcreator-manage-definitions.png b/doc/images/qtcreator-manage-definitions.png
deleted file mode 100644
index af3cafff29..0000000000
--- a/doc/images/qtcreator-manage-definitions.png
+++ /dev/null
Binary files differ
diff --git a/doc/images/qtcreator-syntax-highlighter.png b/doc/images/qtcreator-syntax-highlighter.png
new file mode 100644
index 0000000000..80ac3a7f25
--- /dev/null
+++ b/doc/images/qtcreator-syntax-highlighter.png
Binary files differ
diff --git a/doc/src/editors/creator-semantic-highlighting.qdoc b/doc/src/editors/creator-semantic-highlighting.qdoc
index 86e3dc0a58..28dc1a1763 100644
--- a/doc/src/editors/creator-semantic-highlighting.qdoc
+++ b/doc/src/editors/creator-semantic-highlighting.qdoc
@@ -51,49 +51,32 @@
\section1 Generic Highlighting
- Generic highlighting is based on highlight definition files that are
- provided by the
- \l{http://kate-editor.org/2005/03/24/writing-a-syntax-highlighting-file/}
- {Kate Editor}. You can download highlight definition files for use with \QC.
- For more information about the definition files, see
- \l{http://kde-files.org/index.php?xcontentmode=680}{KDE-Files.org}.
-
- If you have a Unix installation that comes with the Kate Editor, you might
- already have the definition files installed. Typically, the files are
- located in a read-only directory, and therefore, you cannot manage them. \QC
- can try to locate them and use them as fallback files, when the primary
- location does not contain the definition for the current file type. You can
- also specify the directory that contains preinstalled highlight
- definition files as the primary location.
-
- When you open a file for editing and the editor cannot find the highlight
- definition for it, an alert appears. To suppress the alerts, you can specify
- patterns for ignoring files.
-
- To download highlight definition files:
-
- \list 1
- \li Select \uicontrol Tools > \uicontrol Options >
- \uicontrol {Text Editor} > \uicontrol {Generic Highlighter}.
- \image qtcreator-generic-highlighter.png "Generic Highlighter options"
- \li In the \uicontrol Location field, specify the path to the primary
- location for highlight definition files.
- \li Click \uicontrol {Download Definitions} to open a list of highlight
- definition files available for download.
- \image qtcreator-manage-definitions.png "Download Definitions dialog"
- \li Select highlight definition files in the list and click
- \uicontrol {Download Selected Definitions}.
- \li Select the \uicontrol {Use fallback location} check box to specify
- the secondary location where the editor will look for highlight
- definition files.
- \li Click \uicontrol Autodetect to allow \QC to look for highlight
- definition files on your system, or click \uicontrol Browse to
- locate them in the file system yourself.
- \li In the \uicontrol {Ignored file patterns} field, specify file
- patterns to suppress alerts if the highlight definitions for the
- specified files are not found.
- \li Click \uicontrol OK to save your changes.
- \endlist
+ Generic highlighting is provided by
+ \l{https://api.kde.org/frameworks/syntax-highlighting/html/index.html}
+ {KSyntaxHighlighting}, which is the syntax highlighting engine for Kate
+ syntax definitions. \QC comes with most of the commonly used syntax files,
+ and you can download additional files. For more information about the
+ definition files, see
+ \l{https://docs.kde.org/stable5/en/applications/katepart/highlight.html}
+ {Working with Syntax Highlighting}.
+
+ If the editor cannot find the highlight definition for a file that you open
+ for editing, it prompts you to update the highlight definition files. Select
+ \uicontrol {Update Definitions} to update the files.
+
+ To suppress the message for a particular file pattern, select
+ \uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor}
+ > \uicontrol {Generic Highlighter} and add the pattern to the
+ \uicontrol {Ignored file patterns} field.
+
+ \image qtcreator-syntax-highlighter.png "Generic Highlighter options"
+
+ If you have written your own syntax definition files, you
+ can provide an additional definition search path in the
+ \uicontrol {User Highlight Definition Files} field.
+
+ To manually update the highlight definition files, select
+ \uicontrol {Update Definitions}.
\section1 Highlighting and Folding Blocks
diff --git a/qbs/modules/qtc/qtc.qbs b/qbs/modules/qtc/qtc.qbs
index 3c97f6c73d..cfa9839a78 100644
--- a/qbs/modules/qtc/qtc.qbs
+++ b/qbs/modules/qtc/qtc.qbs
@@ -17,7 +17,7 @@ Module {
property string qtcreator_compat_version: ide_compat_version_major + '.'
+ ide_compat_version_minor + '.' + ide_compat_version_release
- property string qtcreator_copyright_year: '2018'
+ property string qtcreator_copyright_year: '2019'
property string qtcreator_copyright_string: "(C) " + qtcreator_copyright_year + " The Qt Company Ltd"
property string ide_display_name: 'Qt Creator'
diff --git a/qtcreator.pri b/qtcreator.pri
index c89ac3fcca..407a18cbae 100644
--- a/qtcreator.pri
+++ b/qtcreator.pri
@@ -5,7 +5,7 @@ QTCREATOR_VERSION = 4.9.82
QTCREATOR_COMPAT_VERSION = 4.9.82
VERSION = $$QTCREATOR_VERSION
QTCREATOR_DISPLAY_VERSION = 4.10.0-beta1
-QTCREATOR_COPYRIGHT_YEAR = 2018
+QTCREATOR_COPYRIGHT_YEAR = 2019
BINARY_ARTIFACTS_BRANCH = master
isEmpty(IDE_DISPLAY_NAME): IDE_DISPLAY_NAME = Qt Creator
diff --git a/qtcreator.pro b/qtcreator.pro
index 214740353a..98a897aa2b 100644
--- a/qtcreator.pro
+++ b/qtcreator.pro
@@ -150,4 +150,7 @@ win32 {
bindist_installer.commands ~= s,/,\\\\,g
}
+deployqt.CONFIG += recursive
+deployqt.recurse = src
+
QMAKE_EXTRA_TARGETS += deployqt bindist bindist_installer bindist_debug
diff --git a/src/app/app-Info.plist b/src/app/app-Info.plist
index 5d7142a863..5893f062a8 100644
--- a/src/app/app-Info.plist
+++ b/src/app/app-Info.plist
@@ -274,3 +274,5 @@
<string>A user application wants to access the photo library.</string>
<key>NSRemindersUsageDescription</key>
<string>A user application wants to access the reminders.</string>
+</dict>
+</plist>
diff --git a/src/app/app.pro b/src/app/app.pro
index 08af263b47..89b9554a9f 100644
--- a/src/app/app.pro
+++ b/src/app/app.pro
@@ -52,3 +52,5 @@ DISTFILES += qtcreator.rc \
QMAKE_SUBSTITUTES += $$PWD/app_version.h.in
CONFIG += no_batch
+
+QMAKE_EXTRA_TARGETS += deployqt # dummy
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/repository.cpp b/src/libs/3rdparty/syntax-highlighting/src/lib/repository.cpp
index 6b2fabd07a..922225a7e1 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/repository.cpp
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/repository.cpp
@@ -78,7 +78,7 @@ Definition Repository::definitionForName(const QString& defName) const
return d->m_defs.value(defName);
}
-static Definition bestCandidate(QVector<Definition>& candidates)
+static Definition bestCandidate(QVector<Definition> &&candidates)
{
if (candidates.isEmpty())
return Definition();
@@ -92,6 +92,11 @@ static Definition bestCandidate(QVector<Definition>& candidates)
Definition Repository::definitionForFileName(const QString& fileName) const
{
+ return bestCandidate(definitionsForFileName(fileName));
+}
+
+QVector<Definition> Repository::definitionsForFileName(const QString &fileName) const
+{
QFileInfo fi(fileName);
const auto name = fi.fileName();
@@ -106,11 +111,16 @@ Definition Repository::definitionForFileName(const QString& fileName) const
}
}
- return bestCandidate(candidates);
+ return candidates;
}
Definition Repository::definitionForMimeType(const QString& mimeType) const
{
+ return bestCandidate(definitionsForMimeType(mimeType));
+}
+
+QVector<Definition> Repository::definitionsForMimeType(const QString &mimeType) const
+{
QVector<Definition> candidates;
for (auto it = d->m_defs.constBegin(); it != d->m_defs.constEnd(); ++it) {
auto def = it.value();
@@ -121,8 +131,7 @@ Definition Repository::definitionForMimeType(const QString& mimeType) const
}
}
}
-
- return bestCandidate(candidates);
+ return candidates;
}
QVector<Definition> Repository::definitions() const
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/repository.h b/src/libs/3rdparty/syntax-highlighting/src/lib/repository.h
index c35da5ec37..e4e9bed69f 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/repository.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/repository.h
@@ -167,6 +167,13 @@ public:
Definition definitionForFileName(const QString &fileName) const;
/**
+ * Returns all Definition%s for the file named @p fileName.
+ * The match is performed based on the \e extensions and @e mimetype of
+ * the definition files.
+ */
+ QVector<Definition> definitionsForFileName(const QString &fileName) const;
+
+ /**
* Returns the best matching Definition to the type named @p mimeType
*
* If no match is found, Definition::isValid() of the returned instance
@@ -177,6 +184,11 @@ public:
Definition definitionForMimeType(const QString &mimeType) const;
/**
+ * Returns all Definition%s to the type named @p mimeType
+ */
+ QVector<Definition> definitionsForMimeType(const QString &mimeType) const;
+
+ /**
* Returns all available Definition%s.
* Definition%ss are ordered by translated section and translated names,
* for consistent displaying.
diff --git a/src/libs/clangsupport/commandlinebuilder.h b/src/libs/clangsupport/commandlinebuilder.h
index 9b5bced932..03d042322d 100644
--- a/src/libs/clangsupport/commandlinebuilder.h
+++ b/src/libs/clangsupport/commandlinebuilder.h
@@ -25,7 +25,7 @@
#pragma once
-#include "filepathview.h"
+#include "filepath.h"
#include <compilermacro.h>
#include <includesearchpath.h>
@@ -35,7 +35,7 @@
namespace ClangBackEnd {
-template<typename ProjectInfo, typename OutputContainer = std::vector<std::string>>
+template<typename ProjectInfo, typename OutputContainer = Utils::SmallStringVector>
class CommandLineBuilder
{
public:
@@ -213,7 +213,7 @@ public:
{
for (const IncludeSearchPath &path : projectIncludeSearchPaths) {
commandLine.emplace_back("-I");
- commandLine.emplace_back(path.path);
+ commandLine.emplace_back(NativeFilePath(FilePathView(path.path)));
}
}
@@ -228,7 +228,7 @@ public:
for (const IncludeSearchPath &path : systemIncludeSearchPaths) {
if (path.type != IncludeSearchPathType::BuiltIn) {
commandLine.emplace_back(includeOption(path.type));
- commandLine.emplace_back(path.path);
+ commandLine.emplace_back(NativeFilePath(FilePathView(path.path)));
}
}
}
@@ -238,7 +238,7 @@ public:
for (const IncludeSearchPath &path : systemIncludeSearchPaths) {
if (path.type == IncludeSearchPathType::BuiltIn) {
commandLine.emplace_back(includeOption(path.type));
- commandLine.emplace_back(path.path);
+ commandLine.emplace_back(NativeFilePath(FilePathView(path.path)));
}
}
}
@@ -247,23 +247,24 @@ public:
{
if (!outputPath.isEmpty()) {
commandLine.emplace_back("-o");
- commandLine.emplace_back(outputPath);
+ commandLine.emplace_back(NativeFilePath(outputPath));
}
}
void addSourcePath(FilePathView sourcePath)
{
if (!sourcePath.isEmpty())
- commandLine.emplace_back(sourcePath);
+ commandLine.emplace_back(NativeFilePath(sourcePath));
}
void addIncludePchPath(FilePathView includePchPath)
{
+
if (!includePchPath.isEmpty()) {
commandLine.emplace_back("-Xclang");
commandLine.emplace_back("-include-pch");
commandLine.emplace_back("-Xclang");
- commandLine.emplace_back(includePchPath);
+ commandLine.emplace_back(NativeFilePath(includePchPath));
}
}
diff --git a/src/libs/clangsupport/filepath.h b/src/libs/clangsupport/filepath.h
index e08f3f4996..7207684194 100644
--- a/src/libs/clangsupport/filepath.h
+++ b/src/libs/clangsupport/filepath.h
@@ -28,7 +28,7 @@
#include "clangsupport_global.h"
#include "filepathview.h"
-#include "filepathview.h"
+#include "nativefilepath.h"
#include <utils/hostosinfo.h>
#include <utils/smallstringio.h>
@@ -37,6 +37,8 @@
namespace ClangBackEnd {
+class NativeFilePath;
+
class FilePath : public Utils::PathString
{
using size_type = Utils::PathString::size_type;
diff --git a/src/libs/clangsupport/nativefilepath.h b/src/libs/clangsupport/nativefilepath.h
index 31b6778ed0..fefaa9c205 100644
--- a/src/libs/clangsupport/nativefilepath.h
+++ b/src/libs/clangsupport/nativefilepath.h
@@ -26,13 +26,15 @@
#pragma once
#include "filepathview.h"
-#include "filepathview.h"
+#include "filepath.h"
#include <utils/hostosinfo.h>
#include <utils/smallstringio.h>
namespace ClangBackEnd {
+class FilePath;
+
class NativeFilePath
{
using size_type = Utils::PathString::size_type;
@@ -50,8 +52,13 @@ public:
NativeFilePath(NativeFilePathView filePathView)
: m_path(filePathView.toStringView()),
m_slashIndex(filePathView.slashIndex())
- {
- }
+ {}
+
+ explicit NativeFilePath(FilePathView filePathView) { *this = fromFilePath(filePathView); }
+
+ explicit NativeFilePath(const FilePath &filePath)
+ : NativeFilePath{FilePathView{filePath}}
+ {}
template<size_type Size>
NativeFilePath(const char(&string)[Size]) noexcept
diff --git a/src/libs/languageserverprotocol/languagefeatures.cpp b/src/libs/languageserverprotocol/languagefeatures.cpp
index 29d60dc7f7..6672bbc2b8 100644
--- a/src/libs/languageserverprotocol/languagefeatures.cpp
+++ b/src/libs/languageserverprotocol/languagefeatures.cpp
@@ -25,6 +25,8 @@
#include "languagefeatures.h"
+#include <cstddef>
+
namespace LanguageServerProtocol {
constexpr const char HoverRequest::methodName[];
@@ -406,7 +408,7 @@ CodeActionResult::CodeActionResult(const QJsonValue &val)
emplace<ResultArray>(result);
return;
}
- emplace<nullptr_t>(nullptr);
+ emplace<std::nullptr_t>(nullptr);
}
bool CodeAction::isValid(QStringList *error) const
diff --git a/src/libs/libs.pro b/src/libs/libs.pro
index 1ffb3bc9a4..8bc99461a7 100644
--- a/src/libs/libs.pro
+++ b/src/libs/libs.pro
@@ -48,3 +48,5 @@ win32: isEmpty(QTC_SKIP_CDBEXT) {
message("environment variable pointing to your CDB installation.")
}
}
+
+QMAKE_EXTRA_TARGETS += deployqt # dummy
diff --git a/src/libs/utils/fancylineedit.cpp b/src/libs/utils/fancylineedit.cpp
index 2cebbce64c..6b5b11995c 100644
--- a/src/libs/utils/fancylineedit.cpp
+++ b/src/libs/utils/fancylineedit.cpp
@@ -27,6 +27,7 @@
#include "fancylineedit.h"
#include "historycompleter.h"
#include "hostosinfo.h"
+#include "optional.h"
#include "qtcassert.h"
#include "stylehelper.h"
#include "utilsicons.h"
@@ -175,6 +176,14 @@ FancyLineEdit::~FancyLineEdit()
}
}
+void FancyLineEdit::setTextKeepingActiveCursor(const QString &text)
+{
+ optional<int> cursor = hasFocus() ? make_optional(cursorPosition()) : nullopt;
+ setText(text);
+ if (cursor)
+ setCursorPosition(*cursor);
+}
+
void FancyLineEdit::setButtonVisible(Side side, bool visible)
{
d->m_iconbutton[side]->setVisible(visible);
diff --git a/src/libs/utils/fancylineedit.h b/src/libs/utils/fancylineedit.h
index 3f40d93df2..fd0b121d88 100644
--- a/src/libs/utils/fancylineedit.h
+++ b/src/libs/utils/fancylineedit.h
@@ -82,6 +82,8 @@ public:
explicit FancyLineEdit(QWidget *parent = nullptr);
~FancyLineEdit() override;
+ void setTextKeepingActiveCursor(const QString &text);
+
QIcon buttonIcon(Side side) const;
void setButtonIcon(Side side, const QIcon &icon);
diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp
index 45600b7aa1..e29b0c7663 100644
--- a/src/libs/utils/pathchooser.cpp
+++ b/src/libs/utils/pathchooser.cpp
@@ -26,7 +26,6 @@
#include "pathchooser.h"
#include "environment.h"
-#include "optional.h"
#include "qtcassert.h"
#include "macroexpander.h"
@@ -348,22 +347,14 @@ QString PathChooser::expandedDirectory(const QString &input, const Environment &
return path;
}
-void setTextKeepingActiveCursor(QLineEdit *edit, const QString &text)
-{
- optional<int> cursor = edit->hasFocus() ? make_optional(edit->cursorPosition()) : nullopt;
- edit->setText(text);
- if (cursor)
- edit->setCursorPosition(*cursor);
-}
-
void PathChooser::setPath(const QString &path)
{
- setTextKeepingActiveCursor(d->m_lineEdit, QDir::toNativeSeparators(path));
+ d->m_lineEdit->setTextKeepingActiveCursor(QDir::toNativeSeparators(path));
}
void PathChooser::setFileName(const FileName &fn)
{
- setTextKeepingActiveCursor(d->m_lineEdit, fn.toUserOutput());
+ d->m_lineEdit->setTextKeepingActiveCursor(fn.toUserOutput());
}
void PathChooser::setErrorColor(const QColor &errorColor)
diff --git a/src/libs/utils/smallstringview.h b/src/libs/utils/smallstringview.h
index d821edbf9b..6052ff8777 100644
--- a/src/libs/utils/smallstringview.h
+++ b/src/libs/utils/smallstringview.h
@@ -90,8 +90,7 @@ public:
SmallStringView(const String &string) noexcept
: m_pointer(string.data()),
m_size(string.size())
- {
- }
+ {}
static
SmallStringView fromUtf8(const char *const characterPointer)
diff --git a/src/libs/utils/treemodel.h b/src/libs/utils/treemodel.h
index 92f501ff4a..7ab043032a 100644
--- a/src/libs/utils/treemodel.h
+++ b/src/libs/utils/treemodel.h
@@ -148,6 +148,11 @@ public:
};
TreeItem::insertOrderedChild(item, cmp0);
}
+
+ ChildType *reverseFindAnyChild(const std::function<bool(TreeItem *)> &pred) const
+ {
+ return static_cast<ChildType *>(TreeItem::reverseFindAnyChild(pred));
+ }
};
class QTCREATOR_UTILS_EXPORT StaticTreeItem : public TreeItem
diff --git a/src/plugins/autotest/testresultmodel.cpp b/src/plugins/autotest/testresultmodel.cpp
index 0a1ee0c616..99e1ee15ac 100644
--- a/src/plugins/autotest/testresultmodel.cpp
+++ b/src/plugins/autotest/testresultmodel.cpp
@@ -163,7 +163,7 @@ TestResultItem *TestResultItem::intermediateFor(const TestResultItem *item) cons
QTC_ASSERT(item, return nullptr);
const TestResult *otherResult = item->testResult();
for (int row = childCount() - 1; row >= 0; --row) {
- TestResultItem *child = static_cast<TestResultItem *>(childAt(row));
+ TestResultItem *child = childAt(row);
const TestResult *testResult = child->testResult();
if (testResult->result() != Result::MessageIntermediate)
continue;
@@ -186,7 +186,7 @@ TestResultItem *TestResultItem::createAndAddIntermediateFor(const TestResultItem
/********************************* TestResultModel *****************************************/
TestResultModel::TestResultModel(QObject *parent)
- : Utils::TreeModel<>(parent)
+ : Utils::TreeModel<TestResultItem>(new TestResultItem(TestResultPtr()), parent)
{
}
@@ -194,16 +194,15 @@ void TestResultModel::updateParent(const TestResultItem *item)
{
QTC_ASSERT(item, return);
QTC_ASSERT(item->testResult(), return);
- Utils::TreeItem *parentItem = item->parent();
+ TestResultItem *parentItem = item->parent();
if (parentItem == rootItem()) // do not update invisible root item
return;
bool changed = false;
- TestResultItem *parentResultItem = static_cast<TestResultItem *>(parentItem);
- parentResultItem->updateResult(changed, item->testResult()->result());
+ parentItem->updateResult(changed, item->testResult()->result());
if (!changed)
return;
emit dataChanged(parentItem->index(), parentItem->index());
- updateParent(parentResultItem);
+ updateParent(parentItem);
}
void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoExpand)
@@ -212,7 +211,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
if (testResult->result() == Result::MessageCurrentTest) {
// MessageCurrentTest should always be the last top level item
if (lastRow >= 0) {
- TestResultItem *current = static_cast<TestResultItem *>(rootItem()->childAt(lastRow));
+ TestResultItem *current = rootItem()->childAt(lastRow);
const TestResult *result = current->testResult();
if (result && result->result() == Result::MessageCurrentTest) {
current->updateDescription(testResult->description());
@@ -235,14 +234,11 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
if (AutotestPlugin::settings()->displayApplication) {
const QString application = testResult->id();
if (!application.isEmpty()) {
- for (int row = rootItem()->childCount() - 1; row >= 0; --row) {
- TestResultItem *tmp = static_cast<TestResultItem *>(rootItem()->childAt(row));
- auto tmpTestResult = tmp->testResult();
- if (tmpTestResult->id() == application) {
- root = tmp;
- break;
- }
- }
+ root = rootItem()->findFirstLevelChild([&application](TestResultItem *child) {
+ QTC_ASSERT(child, return false);
+ return child->testResult()->id() == application;
+ });
+
if (!root) {
TestResult *tmpAppResult = new TestResult(application, application);
tmpAppResult->setResult(Result::Application);
@@ -264,7 +260,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
updateParent(newItem);
} else {
if (lastRow >= 0) {
- TestResultItem *current = static_cast<TestResultItem *>(rootItem()->childAt(lastRow));
+ TestResultItem *current = rootItem()->childAt(lastRow);
const TestResult *result = current->testResult();
if (result && result->result() == Result::MessageCurrentTest) {
rootItem()->insertChild(current->index().row(), newItem);
@@ -278,15 +274,11 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
void TestResultModel::removeCurrentTestMessage()
{
- std::vector<Utils::TreeItem *> topLevelItems(rootItem()->begin(), rootItem()->end());
- auto end = topLevelItems.rend();
- for (auto it = topLevelItems.rbegin(); it != end; ++it) {
- TestResultItem *current = static_cast<TestResultItem *>(*it);
- if (current->testResult()->result() == Result::MessageCurrentTest) {
- destroyItem(current);
- break;
- }
- }
+ TestResultItem *currentMessageItem = rootItem()->findFirstLevelChild([](TestResultItem *it) {
+ return (it->testResult()->result() == Result::MessageCurrentTest);
+ });
+ if (currentMessageItem)
+ destroyItem(currentMessageItem);
}
void TestResultModel::clearTestResults()
@@ -302,7 +294,7 @@ void TestResultModel::clearTestResults()
const TestResult *TestResultModel::testResult(const QModelIndex &idx)
{
if (idx.isValid())
- return static_cast<TestResultItem *>(itemForIndex(idx))->testResult();
+ return itemForIndex(idx)->testResult();
return nullptr;
}
@@ -353,7 +345,7 @@ TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item,
if (root == nullptr && !name.isEmpty()) {
for (int row = rootItem()->childCount() - 1; row >= 0; --row) {
- TestResultItem *tmp = static_cast<TestResultItem *>(rootItem()->childAt(row));
+ TestResultItem *tmp = rootItem()->childAt(row);
auto tmpTestResult = tmp->testResult();
if (tmpTestResult->id() == id && tmpTestResult->name() == name) {
root = tmp;
@@ -369,7 +361,7 @@ TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item,
TestResultItem *currentItem = static_cast<TestResultItem *>(it);
return currentItem->testResult()->isDirectParentOf(result, &needsIntermediate);
};
- TestResultItem *parent = static_cast<TestResultItem *>(root->reverseFindAnyChild(predicate));
+ TestResultItem *parent = root->reverseFindAnyChild(predicate);
if (parent) {
if (needsIntermediate) {
// check if the intermediate is present already
diff --git a/src/plugins/autotest/testresultmodel.h b/src/plugins/autotest/testresultmodel.h
index de48db5a0d..0366e8e089 100644
--- a/src/plugins/autotest/testresultmodel.h
+++ b/src/plugins/autotest/testresultmodel.h
@@ -37,7 +37,7 @@
namespace Autotest {
namespace Internal {
-class TestResultItem : public Utils::TreeItem
+class TestResultItem : public Utils::TypedTreeItem<TestResultItem, TestResultItem>
{
public:
explicit TestResultItem(const TestResultPtr &testResult);
@@ -53,7 +53,7 @@ private:
TestResultPtr m_testResult;
};
-class TestResultModel : public Utils::TreeModel<>
+class TestResultModel : public Utils::TreeModel<TestResultItem>
{
public:
explicit TestResultModel(QObject *parent = nullptr);
diff --git a/src/plugins/autotoolsprojectmanager/makefileparser.cpp b/src/plugins/autotoolsprojectmanager/makefileparser.cpp
index 4587f7bacf..39596a724e 100644
--- a/src/plugins/autotoolsprojectmanager/makefileparser.cpp
+++ b/src/plugins/autotoolsprojectmanager/makefileparser.cpp
@@ -291,12 +291,27 @@ void MakefileParser::parseSubDirs()
foreach (const QString& source, parser.sources())
m_sources.append(subDir + slash + source);
- // Duplicates might be possible in combination with several
- // "..._SUBDIRS" targets
- m_makefiles.removeDuplicates();
- m_sources.removeDuplicates();
+ // Append the include paths of the sub directory
+ m_includePaths.append(parser.includePaths());
+
+ // Append the flags of the sub directory
+ m_cflags.append(parser.cflags());
+ m_cxxflags.append(parser.cxxflags());
+
+ // Append the macros of the sub directory
+ foreach (const auto& m, parser.macros())
+ {
+ if (!m_macros.contains(m))
+ m_macros.append(m);
+ }
+
}
+ // Duplicates might be possible in combination with several
+ // "..._SUBDIRS" targets
+ m_makefiles.removeDuplicates();
+ m_sources.removeDuplicates();
+
if (subDirs.isEmpty())
m_success = false;
}
diff --git a/src/plugins/clangcodemodel/clangbackendcommunicator.cpp b/src/plugins/clangcodemodel/clangbackendcommunicator.cpp
index 31e8a85266..28a31f0553 100644
--- a/src/plugins/clangcodemodel/clangbackendcommunicator.cpp
+++ b/src/plugins/clangcodemodel/clangbackendcommunicator.cpp
@@ -63,9 +63,7 @@ enum { backEndStartTimeOutInMs = 10000 };
static QString backendProcessPath()
{
- return Core::ICore::libexecPath()
- + QStringLiteral("/clangbackend")
- + QStringLiteral(QTC_HOST_EXE_SUFFIX);
+ return Core::ICore::libexecPath() + "/clangbackend" + QTC_HOST_EXE_SUFFIX;
}
namespace ClangCodeModel {
@@ -121,7 +119,7 @@ BackendCommunicator::~BackendCommunicator()
void BackendCommunicator::initializeBackend()
{
const QString clangBackEndProcessPath = backendProcessPath();
- if (!QFileInfo(clangBackEndProcessPath).exists()) {
+ if (!QFileInfo::exists(clangBackEndProcessPath)) {
logExecutableDoesNotExist();
return;
}
diff --git a/src/plugins/clangcodemodel/clangtextmark.cpp b/src/plugins/clangcodemodel/clangtextmark.cpp
index 41ee4c1533..61a4c7716c 100644
--- a/src/plugins/clangcodemodel/clangtextmark.cpp
+++ b/src/plugins/clangcodemodel/clangtextmark.cpp
@@ -133,7 +133,6 @@ void disableDiagnosticInCurrentProjectConfig(const ClangBackEnd::DiagnosticConta
currentConfigId = globalSettings->clangDiagnosticConfigId();
// Get config
- const ClangDiagnosticConfigs originalConfigs = globalSettings->clangCustomDiagnosticConfigs();
ClangDiagnosticConfigsModel configsModel(globalSettings->clangCustomDiagnosticConfigs());
QTC_ASSERT(configsModel.hasConfigWithId(currentConfigId), return );
ClangDiagnosticConfig config = configsModel.configWithId(currentConfigId);
diff --git a/src/plugins/clangtools/clangtidyclazytool.cpp b/src/plugins/clangtools/clangtidyclazytool.cpp
index 233f6d87eb..aa9853825c 100644
--- a/src/plugins/clangtools/clangtidyclazytool.cpp
+++ b/src/plugins/clangtools/clangtidyclazytool.cpp
@@ -471,6 +471,13 @@ QList<Diagnostic> ClangTidyClazyTool::read(const QString &filePath,
return readSerializedDiagnostics(filePath, projectRootDir, logFilePath, errorMessage);
}
+void ClangTidyClazyTool::onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics)
+{
+ ClangTool::onNewDiagnosticsAvailable(diagnostics);
+ if (!m_diagnosticFilterModel->filterRegExp().pattern().isEmpty())
+ m_diagnosticFilterModel->invalidateFilter();
+}
+
} // namespace Internal
} // namespace ClangTools
diff --git a/src/plugins/clangtools/clangtidyclazytool.h b/src/plugins/clangtools/clangtidyclazytool.h
index 7cde29f89d..24aac6673b 100644
--- a/src/plugins/clangtools/clangtidyclazytool.h
+++ b/src/plugins/clangtools/clangtidyclazytool.h
@@ -58,6 +58,8 @@ public:
const QString &logFilePath,
QString *errorMessage) const final;
+ void onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics) override;
+
private:
void handleStateUpdate() final;
diff --git a/src/plugins/clangtools/clangtool.h b/src/plugins/clangtools/clangtool.h
index de4d08ceb9..65dde58009 100644
--- a/src/plugins/clangtools/clangtool.h
+++ b/src/plugins/clangtools/clangtool.h
@@ -62,7 +62,7 @@ public:
const QString &name() const;
- void onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics);
+ virtual void onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics);
signals:
void finished(bool success); // For testing.
diff --git a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp
index 00bf9112b9..6e16cc6eec 100644
--- a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp
+++ b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp
@@ -57,6 +57,8 @@ QVariant FilePathItem::data(int column, int role) const
return m_filePath;
case Qt::DecorationRole:
return Core::FileIconProvider::icon(m_filePath);
+ case Debugger::DetailedErrorView::FullTextRole:
+ return m_filePath;
default:
return QVariant();
}
@@ -68,12 +70,14 @@ QVariant FilePathItem::data(int column, int role) const
class ExplainingStepItem : public Utils::TreeItem
{
public:
- ExplainingStepItem(const ExplainingStep &step);
+ ExplainingStepItem(const ExplainingStep &step, int index);
+ int index() const { return m_index; }
private:
QVariant data(int column, int role) const override;
const ExplainingStep m_step;
+ const int m_index = 0;
};
ClangToolsDiagnosticModel::ClangToolsDiagnosticModel(QObject *parent)
@@ -295,15 +299,24 @@ static QString createExplainingStepString(const ExplainingStep &explainingStep,
{
return createExplainingStepNumberString(number)
+ QLatin1Char(' ')
- + explainingStep.extendedMessage
+ + explainingStep.message
+ QLatin1Char(' ')
+ createLocationString(explainingStep.location);
}
+
+static QString lineColumnString(const Debugger::DiagnosticLocation &location)
+{
+ return QString("%1:%2").arg(QString::number(location.line), QString::number(location.column));
+}
+
static QString fullText(const Diagnostic &diagnostic)
{
- // Summary.
- QString text = diagnostic.category + QLatin1String(": ") + diagnostic.type;
+ QString text = diagnostic.location.filePath + QLatin1Char(':');
+ text += lineColumnString(diagnostic.location) + QLatin1String(": ");
+ if (!diagnostic.category.isEmpty())
+ text += diagnostic.category + QLatin1String(": ");
+ text += diagnostic.type;
if (diagnostic.type != diagnostic.description)
text += QLatin1String(": ") + diagnostic.description;
text += QLatin1Char('\n');
@@ -339,8 +352,8 @@ DiagnosticItem::DiagnosticItem(const Diagnostic &diag,
if (!diag.explainingSteps.isEmpty())
m_parentModel->stepsToItemsCache[diag.explainingSteps].push_back(this);
- foreach (const ExplainingStep &s, diag.explainingSteps)
- appendChild(new ExplainingStepItem(s));
+ for (int i = 0; i < diag.explainingSteps.size(); ++i )
+ appendChild(new ExplainingStepItem(diag.explainingSteps[i], i));
}
DiagnosticItem::~DiagnosticItem()
@@ -380,11 +393,6 @@ static QVariant iconData(const QString &type)
return QVariant();
}
-static QString lineColumnString(const Debugger::DiagnosticLocation &location)
-{
- return QString("%1:%2").arg(QString::number(location.line), QString::number(location.column));
-}
-
QVariant DiagnosticItem::data(int column, int role) const
{
if (column == DiagnosticView::FixItColumn) {
@@ -481,9 +489,10 @@ bool DiagnosticItem::hasNewFixIts() const
return m_parentModel->stepsToItemsCache[m_diagnostic.explainingSteps].front() == this;
}
-ExplainingStepItem::ExplainingStepItem(const ExplainingStep &step) : m_step(step)
-{
-}
+ExplainingStepItem::ExplainingStepItem(const ExplainingStep &step, int index)
+ : m_step(step)
+ , m_index(index)
+{}
// We expect something like "note: ..."
static QVariant iconForExplainingStepMessage(const QString &message)
@@ -509,28 +518,37 @@ QVariant ExplainingStepItem::data(int column, int role) const
switch (role) {
case Debugger::DetailedErrorView::LocationRole:
return QVariant::fromValue(m_step.location);
- case Debugger::DetailedErrorView::FullTextRole:
- return fullText(static_cast<DiagnosticItem *>(parent())->diagnostic());
+ case Debugger::DetailedErrorView::FullTextRole: {
+ return QString("%1:%2: %3")
+ .arg(m_step.location.filePath, lineColumnString(m_step.location), m_step.message);
+ }
case ClangToolsDiagnosticModel::TextRole:
return m_step.message;
case ClangToolsDiagnosticModel::DiagnosticRole:
return QVariant::fromValue(static_cast<DiagnosticItem *>(parent())->diagnostic());
case Qt::DisplayRole: {
+ const QString mainFilePath = static_cast<DiagnosticItem *>(parent())->diagnostic().location.filePath;
+ const QString locationString
+ = m_step.location.filePath == mainFilePath
+ ? lineColumnString(m_step.location)
+ : QString("%1:%2").arg(QFileInfo(m_step.location.filePath).fileName(),
+ lineColumnString(m_step.location));
+
if (m_step.isFixIt) {
if (m_step.ranges[0] == m_step.ranges[1]) {
return QString("%1: Insertion of \"%2\".")
- .arg(lineColumnString(m_step.location), m_step.message);
+ .arg(locationString, m_step.message);
}
if (m_step.message.isEmpty()) {
return QString("%1: Removal of %2.")
- .arg(lineColumnString(m_step.location), rangeString(m_step.ranges));
+ .arg(locationString, rangeString(m_step.ranges));
}
return QString("%1: Replacement of %2 with: \"%3\".")
- .arg(lineColumnString(m_step.location),
+ .arg(locationString,
rangeString(m_step.ranges),
m_step.message);
}
- return QString("%1: %2").arg(lineColumnString(m_step.location), m_step.message);
+ return QString("%1: %2").arg(locationString, m_step.message);
}
case Qt::ToolTipRole:
return createExplainingStepToolTipString(m_step);
@@ -546,7 +564,6 @@ QVariant ExplainingStepItem::data(int column, int role) const
return QVariant();
}
-
DiagnosticFilterModel::DiagnosticFilterModel(QObject *parent)
: QSortFilterProxyModel(parent)
{
@@ -584,14 +601,32 @@ void DiagnosticFilterModel::addSuppressedDiagnostic(
invalidate();
}
+void DiagnosticFilterModel::invalidateFilter()
+{
+ QSortFilterProxyModel::invalidateFilter();
+}
+
bool DiagnosticFilterModel::filterAcceptsRow(int sourceRow,
const QModelIndex &sourceParent) const
{
auto model = static_cast<ClangToolsDiagnosticModel *>(sourceModel());
- Utils::TreeItem *item = model->itemForIndex(sourceParent);
+
+ // FilePathItem - hide if no diagnostics match
+ if (!sourceParent.isValid()) {
+ const QModelIndex filePathIndex = model->index(sourceRow, 0);
+ const int rowCount = model->rowCount(filePathIndex);
+ if (rowCount == 0)
+ return true; // Children not yet added.
+ for (int row = 0; row < rowCount; ++row) {
+ if (filterAcceptsRow(row, filePathIndex))
+ return true;
+ }
+ return false;
+ }
// DiagnosticItem
- if (auto filePathItem = dynamic_cast<FilePathItem *>(item)) {
+ Utils::TreeItem *parentItem = model->itemForIndex(sourceParent);
+ if (auto filePathItem = dynamic_cast<FilePathItem *>(parentItem)) {
auto diagnosticItem = dynamic_cast<DiagnosticItem *>(filePathItem->childAt(sourceRow));
QTC_ASSERT(diagnosticItem, return false);
@@ -612,7 +647,7 @@ bool DiagnosticFilterModel::filterAcceptsRow(int sourceRow,
return diag.description.contains(filterRegExp());
}
- return true;
+ return true; // ExplainingStepItem
}
bool DiagnosticFilterModel::lessThan(const QModelIndex &l, const QModelIndex &r) const
@@ -622,22 +657,34 @@ bool DiagnosticFilterModel::lessThan(const QModelIndex &l, const QModelIndex &r)
const bool isComparingDiagnostics = !dynamic_cast<FilePathItem *>(itemLeft);
if (sortColumn() == Debugger::DetailedErrorView::DiagnosticColumn && isComparingDiagnostics) {
- using Debugger::DiagnosticLocation;
- const int role = Debugger::DetailedErrorView::LocationRole;
-
- const auto leftLoc = sourceModel()->data(l, role).value<DiagnosticLocation>();
- const auto leftText = sourceModel()->data(l, ClangToolsDiagnosticModel::TextRole).toString();
-
- const auto rightLoc = sourceModel()->data(r, role).value<DiagnosticLocation>();
- const auto rightText = sourceModel()->data(r, ClangToolsDiagnosticModel::TextRole).toString();
+ bool result = false;
+ if (dynamic_cast<DiagnosticItem *>(itemLeft)) {
+ using Debugger::DiagnosticLocation;
+ const int role = Debugger::DetailedErrorView::LocationRole;
+
+ const auto leftLoc = sourceModel()->data(l, role).value<DiagnosticLocation>();
+ const auto leftText
+ = sourceModel()->data(l, ClangToolsDiagnosticModel::TextRole).toString();
+
+ const auto rightLoc = sourceModel()->data(r, role).value<DiagnosticLocation>();
+ const auto rightText
+ = sourceModel()->data(r, ClangToolsDiagnosticModel::TextRole).toString();
+
+ result = std::tie(leftLoc.line, leftLoc.column, leftText)
+ < std::tie(rightLoc.line, rightLoc.column, rightText);
+ } else if (auto left = dynamic_cast<ExplainingStepItem *>(itemLeft)) {
+ const auto right = dynamic_cast<ExplainingStepItem *>(model->itemForIndex(r));
+ result = left->index() < right->index();
+ } else {
+ QTC_CHECK(false && "Unexpected item");
+ }
- const int result = std::tie(leftLoc.line, leftLoc.column, leftText)
- < std::tie(rightLoc.line, rightLoc.column, rightText);
if (sortOrder() == Qt::DescendingOrder)
- return !result; // Ensure that we always sort location from top to bottom.
+ return !result; // Do not change the order of these item as this might be confusing.
return result;
}
+ // FilePathItem
return QSortFilterProxyModel::lessThan(l, r);
}
diff --git a/src/plugins/clangtools/clangtoolsdiagnosticmodel.h b/src/plugins/clangtools/clangtoolsdiagnosticmodel.h
index 8a69e9def7..22d0699201 100644
--- a/src/plugins/clangtools/clangtoolsdiagnosticmodel.h
+++ b/src/plugins/clangtools/clangtoolsdiagnosticmodel.h
@@ -146,6 +146,8 @@ public:
void addSuppressedDiagnostic(const SuppressedDiagnostic &diag);
ProjectExplorer::Project *project() const { return m_project; }
+ void invalidateFilter();
+
private:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan(const QModelIndex &l, const QModelIndex &r) const override;
diff --git a/src/plugins/coreplugin/infobar.cpp b/src/plugins/coreplugin/infobar.cpp
index 827f1e8337..a81a8834d5 100644
--- a/src/plugins/coreplugin/infobar.cpp
+++ b/src/plugins/coreplugin/infobar.cpp
@@ -36,6 +36,7 @@
#include <QVBoxLayout>
#include <QLabel>
#include <QToolButton>
+#include <QComboBox>
static const char C_SUPPRESSED_WARNINGS[] = "SuppressedWarnings";
@@ -73,6 +74,12 @@ void InfoBarEntry::setCancelButtonInfo(const QString &_cancelButtonText, CallBac
m_cancelButtonCallBack = callBack;
}
+void InfoBarEntry::setComboInfo(const QStringList &list, InfoBarEntry::ComboCallBack callBack)
+{
+ m_comboCallBack = callBack;
+ m_comboInfo = list;
+}
+
void InfoBarEntry::removeCancelButton()
{
m_useCancelButton = false;
@@ -242,7 +249,7 @@ void InfoBarDisplay::update()
QLabel *infoWidgetLabel = new QLabel(info.m_infoText);
infoWidgetLabel->setWordWrap(true);
- hbox->addWidget(infoWidgetLabel);
+ hbox->addWidget(infoWidgetLabel, 1);
if (info.m_detailsWidgetCreator) {
if (m_isShowingDetailsWidget) {
@@ -270,6 +277,16 @@ void InfoBarDisplay::update()
m_isShowingDetailsWidget = false;
}
+ if (!info.m_comboInfo.isEmpty()) {
+ auto cb = new QComboBox();
+ cb->addItems(info.m_comboInfo);
+ connect(cb, &QComboBox::currentTextChanged, [info](const QString &text) {
+ info.m_comboCallBack(text);
+ });
+
+ hbox->addWidget(cb);
+ }
+
if (!info.m_buttonText.isEmpty()) {
auto infoWidgetButton = new QToolButton;
infoWidgetButton->setText(info.m_buttonText);
diff --git a/src/plugins/coreplugin/infobar.h b/src/plugins/coreplugin/infobar.h
index ccd235cedc..b65a821bcf 100644
--- a/src/plugins/coreplugin/infobar.h
+++ b/src/plugins/coreplugin/infobar.h
@@ -61,6 +61,8 @@ public:
void setCustomButtonInfo(const QString &_buttonText, CallBack callBack);
void setCancelButtonInfo(CallBack callBack);
void setCancelButtonInfo(const QString &_cancelButtonText, CallBack callBack);
+ using ComboCallBack = std::function<void(const QString &)>;
+ void setComboInfo(const QStringList &list, ComboCallBack callBack);
void removeCancelButton();
using DetailsWidgetCreator = std::function<QWidget*()>;
@@ -76,6 +78,8 @@ private:
GlobalSuppressionMode m_globalSuppression;
DetailsWidgetCreator m_detailsWidgetCreator;
bool m_useCancelButton = true;
+ ComboCallBack m_comboCallBack;
+ QStringList m_comboInfo;
friend class InfoBar;
friend class InfoBarDisplay;
};
diff --git a/src/plugins/cppeditor/cppautocompleter.h b/src/plugins/cppeditor/cppautocompleter.h
index 5c90d73dca..eb90c15b48 100644
--- a/src/plugins/cppeditor/cppautocompleter.h
+++ b/src/plugins/cppeditor/cppautocompleter.h
@@ -33,8 +33,6 @@ namespace Internal {
class CppAutoCompleter : public TextEditor::AutoCompleter
{
public:
- CppAutoCompleter() {}
-
bool contextAllowsAutoBrackets(const QTextCursor &cursor,
const QString &textToInsert = QString()) const override;
bool contextAllowsAutoQuotes(const QTextCursor &cursor,
diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
index 30e0b0e169..1cedfbfd9d 100644
--- a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
+++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
@@ -85,8 +85,6 @@ QSizePolicy sizePolicyWithStretchFactor(int stretchFactor)
class DepthFinder : public SymbolVisitor {
public:
- DepthFinder() : m_symbol(0), m_depth(-1), m_foundDepth(-1), m_stop(false) {}
-
int operator()(const Document::Ptr &document, Symbol *symbol)
{
m_symbol = symbol;
@@ -94,7 +92,7 @@ public:
return m_foundDepth;
}
- bool preVisit(Symbol *symbol)
+ bool preVisit(Symbol *symbol) override
{
if (m_stop)
return false;
@@ -111,17 +109,17 @@ public:
return false;
}
- void postVisit(Symbol *symbol)
+ void postVisit(Symbol *symbol) override
{
if (symbol->asScope())
--m_depth;
}
private:
- Symbol *m_symbol;
- int m_depth;
- int m_foundDepth;
- bool m_stop;
+ Symbol *m_symbol = nullptr;
+ int m_depth = -1;
+ int m_foundDepth = -1;
+ bool m_stop = false;
};
} // anonymous namespace
@@ -169,12 +167,12 @@ FilterableView::FilterableView(QWidget *parent)
QPushButton *clearButton = new QPushButton(QLatin1String("&Clear"), this);
QObject::connect(clearButton, &QAbstractButton::clicked, this, &FilterableView::clearFilter);
- QHBoxLayout *filterBarLayout = new QHBoxLayout();
+ auto filterBarLayout = new QHBoxLayout();
filterBarLayout->addWidget(label);
filterBarLayout->addWidget(lineEdit);
filterBarLayout->addWidget(clearButton);
- QVBoxLayout *mainLayout = new QVBoxLayout();
+ auto mainLayout = new QVBoxLayout();
mainLayout->addWidget(view);
mainLayout->addLayout(filterBarLayout);
@@ -222,10 +220,10 @@ public:
enum Columns { FileKindColumn, FilePathColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
ProjectFiles m_files;
@@ -305,10 +303,10 @@ public:
enum Columns { TypeColumn, PathColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
ProjectExplorer::HeaderPaths m_paths;
@@ -377,7 +375,7 @@ class KeyValueModel : public QAbstractListModel
{
Q_OBJECT
public:
- typedef QList<QPair<QString, QString> > Table;
+ using Table = QList<QPair<QString, QString>>;
KeyValueModel(QObject *parent);
void configure(const Table &table);
@@ -385,10 +383,10 @@ public:
enum Columns { KeyColumn, ValueColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
Table m_table;
@@ -465,10 +463,10 @@ public:
enum Columns { SymbolCountColumn, SharedColumn, FilePathColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
QList<Document::Ptr> m_documents;
@@ -498,7 +496,7 @@ QModelIndex SnapshotModel::indexForDocument(const QString &filePath)
if (document->fileName() == filePath)
return index(i, FilePathColumn);
}
- return QModelIndex();
+ return {};
}
int SnapshotModel::rowCount(const QModelIndex &/*parent*/) const
@@ -565,10 +563,10 @@ public:
enum Columns { ResolvedOrNotColumn, LineNumberColumn, FilePathsColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
QList<Document::Include> m_includes;
@@ -667,10 +665,10 @@ public:
enum Columns { LevelColumn, LineColumnNumberColumn, MessageColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
QList<Document::DiagnosticMessage> m_messages;
@@ -716,8 +714,7 @@ QVariant DiagnosticMessagesModel::data(const QModelIndex &index, int role) const
static const QBrush darkRedBrushQColor(QColor(139, 0, 0));
const Document::DiagnosticMessage message = m_messages.at(index.row());
- const Document::DiagnosticMessage::Level level
- = static_cast<Document::DiagnosticMessage::Level>(message.level());
+ const auto level = static_cast<Document::DiagnosticMessage::Level>(message.level());
if (role == Qt::DisplayRole) {
const int column = index.column();
@@ -775,10 +772,10 @@ public:
enum Columns { LineNumberColumn, MacroColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
QList<CPlusPlus::Macro> m_macros;
@@ -854,12 +851,12 @@ public:
enum Columns { SymbolColumn, LineNumberColumn, ColumnCount };
- QModelIndex index(int row, int column, const QModelIndex &parent) const;
- QModelIndex parent(const QModelIndex &child) const;
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent) const override;
+ QModelIndex parent(const QModelIndex &child) const override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
Document::Ptr m_document;
@@ -886,21 +883,19 @@ void SymbolsModel::clear()
static Symbol *indexToSymbol(const QModelIndex &index)
{
- if (Symbol *symbol = static_cast<Symbol*>(index.internalPointer()))
- return symbol;
- return 0;
+ return static_cast<Symbol*>(index.internalPointer());
}
static Scope *indexToScope(const QModelIndex &index)
{
if (Symbol *symbol = indexToSymbol(index))
return symbol->asScope();
- return 0;
+ return nullptr;
}
QModelIndex SymbolsModel::index(int row, int column, const QModelIndex &parent) const
{
- Scope *scope = 0;
+ Scope *scope = nullptr;
if (parent.isValid())
scope = indexToScope(parent);
else if (m_document)
@@ -911,13 +906,13 @@ QModelIndex SymbolsModel::index(int row, int column, const QModelIndex &parent)
return createIndex(row, column, scope->memberAt(row));
}
- return QModelIndex();
+ return {};
}
QModelIndex SymbolsModel::parent(const QModelIndex &child) const
{
if (!child.isValid())
- return QModelIndex();
+ return {};
if (Symbol *symbol = indexToSymbol(child)) {
if (Scope *scope = symbol->enclosingScope()) {
@@ -926,7 +921,7 @@ QModelIndex SymbolsModel::parent(const QModelIndex &child) const
}
}
- return QModelIndex();
+ return {};
}
int SymbolsModel::rowCount(const QModelIndex &parent) const
@@ -994,10 +989,10 @@ public:
BytesAndCodePointsColumn, GeneratedColumn, ExpandedColumn, WhiteSpaceColumn,
NewlineColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
struct TokenInfo {
@@ -1126,10 +1121,10 @@ public:
enum Columns { PartNameColumn, PartFilePathColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
QList<ProjectPart::Ptr> m_projectPartsList;
@@ -1161,7 +1156,7 @@ void ProjectPartsModel::configure(const QList<ProjectInfo> &projectInfos,
QModelIndex ProjectPartsModel::indexForCurrentEditorsProjectPart() const
{
if (m_currentEditorsProjectPartIndex == -1)
- return QModelIndex();
+ return {};
return createIndex(m_currentEditorsProjectPartIndex, PartFilePathColumn);
}
@@ -1232,10 +1227,10 @@ public:
enum Columns { RevisionColumn, FilePathColumn, ColumnCount };
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
private:
struct WorkingCopyEntry {
@@ -1275,7 +1270,7 @@ QModelIndex WorkingCopyModel::indexForFile(const QString &filePath)
if (entry.filePath == filePath)
return index(i, FilePathColumn);
}
- return QModelIndex();
+ return {};
}
int WorkingCopyModel::rowCount(const QModelIndex &/*parent*/) const
@@ -1542,11 +1537,11 @@ void CppCodeModelInspectorDialog::refresh()
dumper.dumpSnapshot(globalSnapshot, globalSnapshotTitle, /*isGlobalSnapshot=*/ true);
TextEditor::BaseTextEditor *editor = currentEditor();
- CppTools::CppEditorDocumentHandle *cppEditorDocument = 0;
+ CppTools::CppEditorDocumentHandle *cppEditorDocument = nullptr;
if (editor) {
const QString editorFilePath = editor->document()->filePath().toString();
cppEditorDocument = cmmi->cppEditorDocument(editorFilePath);
- if (auto *documentProcessor = CppToolsBridge::baseEditorDocumentProcessor(editorFilePath)) {
+ if (auto documentProcessor = CppToolsBridge::baseEditorDocumentProcessor(editorFilePath)) {
const Snapshot editorSnapshot = documentProcessor->snapshot();
m_snapshotInfos->append(SnapshotInfo(editorSnapshot, SnapshotInfo::EditorSnapshot));
const QString editorSnapshotTitle
@@ -1555,7 +1550,7 @@ void CppCodeModelInspectorDialog::refresh()
dumper.dumpSnapshot(editorSnapshot, editorSnapshotTitle);
m_ui->snapshotSelector->addItem(editorSnapshotTitle);
}
- CppEditorWidget *cppEditorWidget = qobject_cast<CppEditorWidget *>(editor->editorWidget());
+ auto cppEditorWidget = qobject_cast<CppEditorWidget *>(editor->editorWidget());
if (cppEditorWidget) {
SemanticInfo semanticInfo = cppEditorWidget->semanticInfo();
Snapshot snapshot;
@@ -1855,7 +1850,7 @@ void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr &
bool CppCodeModelInspectorDialog::event(QEvent *e)
{
if (e->type() == QEvent::ShortcutOverride) {
- QKeyEvent *ke = static_cast<QKeyEvent *>(e);
+ auto ke = static_cast<QKeyEvent *>(e);
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
close();
diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.h b/src/plugins/cppeditor/cppcodemodelinspectordialog.h
index 01d24ea0b8..7faf93da84 100644
--- a/src/plugins/cppeditor/cppcodemodelinspectordialog.h
+++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.h
@@ -65,8 +65,8 @@ class CppCodeModelInspectorDialog : public QDialog
Q_OBJECT
public:
- explicit CppCodeModelInspectorDialog(QWidget *parent = 0);
- ~CppCodeModelInspectorDialog();
+ explicit CppCodeModelInspectorDialog(QWidget *parent = nullptr);
+ ~CppCodeModelInspectorDialog() override;
private:
void onRefreshRequested();
@@ -90,7 +90,7 @@ private:
void clearProjectPartData();
void updateProjectPartData(const CppTools::ProjectPart::Ptr &part);
- bool event(QEvent *e);
+ bool event(QEvent *e) override;
private:
Ui::CppCodeModelInspectorDialog *m_ui;
diff --git a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp
index 0fb67c9b22..65c3dc9769 100644
--- a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp
+++ b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp
@@ -173,7 +173,7 @@ bool handleDoxygenCppStyleContinuation(QTextCursor &cursor)
return false;
QString newLine(QLatin1Char('\n'));
- newLine.append(text.left(offset)); // indent correctly
+ newLine.append(text.leftRef(offset)); // indent correctly
newLine.append(commentMarker);
newLine.append(QLatin1Char(' '));
diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp
index d18735c750..c157742457 100644
--- a/src/plugins/cppeditor/cppeditordocument.cpp
+++ b/src/plugins/cppeditor/cppeditordocument.cpp
@@ -80,7 +80,10 @@ public:
mm()->registerCppEditorDocument(this);
}
- ~CppEditorDocumentHandleImpl() { mm()->unregisterCppEditorDocument(m_registrationFilePath); }
+ ~CppEditorDocumentHandleImpl() override
+ {
+ mm()->unregisterCppEditorDocument(m_registrationFilePath);
+ }
QString filePath() const override { return m_cppEditorDocument->filePath().toString(); }
QByteArray contents() const override { return m_cppEditorDocument->contentsText(); }
@@ -100,12 +103,7 @@ private:
};
CppEditorDocument::CppEditorDocument()
- : m_fileIsBeingReloaded(false)
- , m_isObjCEnabled(false)
- , m_cachedContentsRevision(-1)
- , m_processorRevision(0)
- , m_completionAssistProvider(0)
- , m_minimizableInfoBars(*infoBar())
+ : m_minimizableInfoBars(*infoBar())
{
setId(CppEditor::Constants::CPPEDITOR_ID);
setSyntaxHighlighter(new CppHighlighter);
@@ -352,7 +350,7 @@ unsigned CppEditorDocument::contentsRevision() const
void CppEditorDocument::releaseResources()
{
if (m_processor)
- disconnect(m_processor.data(), 0, this, 0);
+ disconnect(m_processor.data(), nullptr, this, nullptr);
m_processor.reset();
}
diff --git a/src/plugins/cppeditor/cppeditordocument.h b/src/plugins/cppeditor/cppeditordocument.h
index 26cff2043a..5055b2654a 100644
--- a/src/plugins/cppeditor/cppeditordocument.h
+++ b/src/plugins/cppeditor/cppeditordocument.h
@@ -115,19 +115,19 @@ private:
void initializeTimer();
private:
- bool m_fileIsBeingReloaded;
- bool m_isObjCEnabled;
+ bool m_fileIsBeingReloaded = false;
+ bool m_isObjCEnabled = false;
// Caching contents
mutable QMutex m_cachedContentsLock;
mutable QByteArray m_cachedContents;
- mutable int m_cachedContentsRevision;
+ mutable int m_cachedContentsRevision = -1;
- unsigned m_processorRevision;
+ unsigned m_processorRevision = 0;
QTimer m_processorTimer;
QScopedPointer<CppTools::BaseEditorDocumentProcessor> m_processor;
- CppTools::CppCompletionAssistProvider *m_completionAssistProvider;
+ CppTools::CppCompletionAssistProvider *m_completionAssistProvider = nullptr;
// (Un)Registration in CppModelManager
QScopedPointer<CppTools::CppEditorDocumentHandle> m_editorDocumentHandle;
diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp
index bf533f038f..f46c3db17d 100644
--- a/src/plugins/cppeditor/cppeditorplugin.cpp
+++ b/src/plugins/cppeditor/cppeditorplugin.cpp
@@ -310,7 +310,7 @@ static CppEditorWidget *currentCppEditorWidget()
{
if (IEditor *currentEditor = EditorManager::currentEditor())
return qobject_cast<CppEditorWidget*>(currentEditor->widget());
- return 0;
+ return nullptr;
}
void CppEditorPlugin::switchDeclarationDefinition()
diff --git a/src/plugins/cppeditor/cppeditorplugin.h b/src/plugins/cppeditor/cppeditorplugin.h
index 263af42a12..f4d024f33f 100644
--- a/src/plugins/cppeditor/cppeditorplugin.h
+++ b/src/plugins/cppeditor/cppeditorplugin.h
@@ -40,7 +40,7 @@ class CppEditorPlugin : public ExtensionSystem::IPlugin
public:
CppEditorPlugin();
- ~CppEditorPlugin();
+ ~CppEditorPlugin() override;
static CppEditorPlugin *instance();
diff --git a/src/plugins/cppeditor/cppeditorwidget.cpp b/src/plugins/cppeditor/cppeditorwidget.cpp
index 286ef4cdf9..df37a22d29 100644
--- a/src/plugins/cppeditor/cppeditorwidget.cpp
+++ b/src/plugins/cppeditor/cppeditorwidget.cpp
@@ -261,7 +261,7 @@ void CppEditorWidget::finalizeInitialization()
void CppEditorWidget::finalizeInitializationAfterDuplication(TextEditorWidget *other)
{
QTC_ASSERT(other, return);
- CppEditorWidget *cppEditorWidget = qobject_cast<CppEditorWidget *>(other);
+ auto cppEditorWidget = qobject_cast<CppEditorWidget *>(other);
QTC_ASSERT(cppEditorWidget, return);
if (cppEditorWidget->isSemanticInfoValidExceptLocalUses())
@@ -278,10 +278,7 @@ void CppEditorWidget::finalizeInitializationAfterDuplication(TextEditorWidget *o
d->m_cppEditorDocument->parseContextModel().areMultipleAvailable());
}
-CppEditorWidget::~CppEditorWidget()
-{
- // non-inline destructor, see section "Forward Declared Pointers" of QScopedPointer.
-}
+CppEditorWidget::~CppEditorWidget() = default;
CppEditorDocument *CppEditorWidget::cppEditorDocument() const
{
@@ -357,7 +354,7 @@ static QString getDocumentLine(const QTextDocument &document, int line)
static QString getFileLine(const QString &path, int line)
{
const IDocument *document = DocumentModel::documentForFilePath(path);
- const TextDocument *textDocument = qobject_cast<const TextDocument *>(document);
+ const auto textDocument = qobject_cast<const TextDocument *>(document);
if (textDocument)
return getDocumentLine(*textDocument->document(), line);
@@ -543,7 +540,7 @@ ProjectPart *findProjectPartForCurrentProject(const QList<ProjectPart::Ptr> &pro
if (found != projectParts.cend())
return (*found).data();
- return 0;
+ return nullptr;
}
} // namespace
@@ -551,7 +548,7 @@ ProjectPart *findProjectPartForCurrentProject(const QList<ProjectPart::Ptr> &pro
ProjectPart *CppEditorWidget::projectPart() const
{
if (!d->m_modelManager)
- return 0;
+ return nullptr;
auto projectParts = fetchProjectParts(d->m_modelManager, textDocument()->filePath());
@@ -668,14 +665,13 @@ void CppEditorWidget::switchDeclarationDefinition(bool inNextSplit)
return;
// Find function declaration or definition under cursor
- Function *functionDefinitionSymbol = 0;
- Symbol *functionDeclarationSymbol = 0;
+ Function *functionDefinitionSymbol = nullptr;
+ Symbol *functionDeclarationSymbol = nullptr;
ASTPath astPathFinder(d->m_lastSemanticInfo.doc);
const QList<AST *> astPath = astPathFinder(textCursor());
- for (int i = 0, size = astPath.size(); i < size; ++i) {
- AST *ast = astPath.at(i);
+ for (AST *ast : astPath) {
if (FunctionDefinitionAST *functionDefinitionAST = ast->asFunctionDefinition()) {
if ((functionDefinitionSymbol = functionDefinitionAST->symbol))
break; // Function definition found!
@@ -999,7 +995,7 @@ AssistInterface *CppEditorWidget::createAssistInterface(AssistKind kind, AssistR
} else {
return TextEditorWidget::createAssistInterface(kind, reason);
}
- return 0;
+ return nullptr;
}
QSharedPointer<FunctionDeclDefLink> CppEditorWidget::declDefLink() const
diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
index a1af83596f..2a53648b31 100644
--- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
+++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
@@ -96,19 +96,17 @@ static bool findDeclOrDef(const Document::Ptr &doc, int line, int column,
// by CompoundStatement/CtorInitializer
// for function declarations, look for SimpleDeclarations with a single Declarator
// with a FunctionDeclarator postfix
- FunctionDefinitionAST *funcDef = 0;
- SimpleDeclarationAST *simpleDecl = 0;
- *decl = 0;
+ *decl = nullptr;
for (int i = path.size() - 1; i > 0; --i) {
AST *ast = path.at(i);
if (ast->asCompoundStatement() || ast->asCtorInitializer())
break;
- if ((funcDef = ast->asFunctionDefinition()) != 0) {
+ if (FunctionDefinitionAST *funcDef = ast->asFunctionDefinition()) {
*parent = funcDef;
*decl = funcDef->declarator;
break;
}
- if ((simpleDecl = ast->asSimpleDeclaration()) != 0) {
+ if (SimpleDeclarationAST *simpleDecl = ast->asSimpleDeclaration()) {
*parent = simpleDecl;
if (!simpleDecl->declarator_list || !simpleDecl->declarator_list->value)
break;
@@ -142,12 +140,12 @@ static void declDefLinkStartEnd(const CppRefactoringFileConstPtr &file,
static DeclaratorIdAST *getDeclaratorId(DeclaratorAST *declarator)
{
if (!declarator || !declarator->core_declarator)
- return 0;
+ return nullptr;
if (DeclaratorIdAST *id = declarator->core_declarator->asDeclaratorId())
return id;
if (NestedDeclaratorAST *nested = declarator->core_declarator->asNestedDeclarator())
return getDeclaratorId(nested->declarator);
- return 0;
+ return nullptr;
}
static QSharedPointer<FunctionDeclDefLink> findLinkHelper(QSharedPointer<FunctionDeclDefLink> link, CppRefactoringChanges changes)
@@ -156,7 +154,7 @@ static QSharedPointer<FunctionDeclDefLink> findLinkHelper(QSharedPointer<Functio
const Snapshot &snapshot = changes.snapshot();
// find the matching decl/def symbol
- Symbol *target = 0;
+ Symbol *target = nullptr;
SymbolFinder finder;
if (FunctionDefinitionAST *funcDef = link->sourceDeclaration->asFunctionDefinition()) {
QList<Declaration *> nameMatch, argumentCountMatch, typeMatch;
@@ -178,9 +176,9 @@ static QSharedPointer<FunctionDeclDefLink> findLinkHelper(QSharedPointer<Functio
if (!targetFile->isValid())
return noResult;
- DeclarationAST *targetParent = 0;
- FunctionDeclaratorAST *targetFuncDecl = 0;
- DeclaratorAST *targetDeclarator = 0;
+ DeclarationAST *targetParent = nullptr;
+ FunctionDeclaratorAST *targetFuncDecl = nullptr;
+ DeclaratorAST *targetDeclarator = nullptr;
if (!findDeclOrDef(targetFile->cppDocument(), target->line(), target->column(),
&targetParent, &targetDeclarator, &targetFuncDecl))
return noResult;
@@ -213,9 +211,9 @@ void FunctionDeclDefLinkFinder::startFindLinkAt(
QTextCursor cursor, const Document::Ptr &doc, const Snapshot &snapshot)
{
// check if cursor is on function decl/def
- DeclarationAST *parent = 0;
- FunctionDeclaratorAST *funcDecl = 0;
- DeclaratorAST *declarator = 0;
+ DeclarationAST *parent = nullptr;
+ FunctionDeclaratorAST *funcDecl = nullptr;
+ DeclaratorAST *declarator = nullptr;
if (!findDeclOrDef(doc, cursor.blockNumber() + 1, cursor.columnNumber() + 1,
&parent, &declarator, &funcDecl))
return;
@@ -455,10 +453,10 @@ static SpecifierAST *findFirstReplaceableSpecifier(TranslationUnit *translationU
if (canReplaceSpecifier(translationUnit, it->value))
return it->value;
}
- return 0;
+ return nullptr;
}
-typedef QVarLengthArray<int, 10> IndicesList;
+using IndicesList = QVarLengthArray<int, 10>;
template <class IndicesListType>
static int findUniqueTypeMatch(int sourceParamIndex, Function *sourceFunction, Function *newFunction,
@@ -597,8 +595,8 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse
Control *control = sourceContext.bindings()->control().data();
// get return type start position and declarator info from declaration
- DeclaratorAST *declarator = 0;
- SpecifierAST *firstReplaceableSpecifier = 0;
+ DeclaratorAST *declarator = nullptr;
+ SpecifierAST *firstReplaceableSpecifier = nullptr;
TranslationUnit *targetTranslationUnit = targetFile->cppDocument()->translationUnit();
if (SimpleDeclarationAST *simple = targetDeclaration->asSimpleDeclaration()) {
declarator = simple->declarator_list->value;
@@ -790,7 +788,7 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse
if (hasCommentedName(targetFile->cppDocument()->translationUnit(),
QString::fromUtf8(targetFile->cppDocument()->utf8Source()),
targetFunctionDeclarator, existingParamIndex))
- replacementName = 0;
+ replacementName = nullptr;
// track renames
if (replacementName != targetParam->name() && replacementName)
@@ -914,8 +912,8 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse
changes.insert(targetFile->endOf(targetFunctionDeclarator->rparen_token), cvString);
// modify/remove existing specifiers
} else {
- SimpleSpecifierAST *constSpecifier = 0;
- SimpleSpecifierAST *volatileSpecifier = 0;
+ SimpleSpecifierAST *constSpecifier = nullptr;
+ SimpleSpecifierAST *volatileSpecifier = nullptr;
for (SpecifierListAST *it = targetFunctionDeclarator->cv_qualifier_list; it; it = it->next) {
if (SimpleSpecifierAST *simple = it->value->asSimpleSpecifier()) {
unsigned kind = targetFile->tokenAt(simple->specifier_token).kind();
diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.h b/src/plugins/cppeditor/cppfunctiondecldeflink.h
index 4d6437965d..136e069449 100644
--- a/src/plugins/cppeditor/cppfunctiondecldeflink.h
+++ b/src/plugins/cppeditor/cppfunctiondecldeflink.h
@@ -45,7 +45,7 @@ class FunctionDeclDefLinkFinder : public QObject
{
Q_OBJECT
public:
- FunctionDeclDefLinkFinder(QObject *parent = 0);
+ FunctionDeclDefLinkFinder(QObject *parent = nullptr);
void startFindLinkAt(QTextCursor cursor,
const CPlusPlus::Document::Ptr &doc,
diff --git a/src/plugins/cppeditor/cpphighlighter.h b/src/plugins/cppeditor/cpphighlighter.h
index 2e4b870b04..e43ce63172 100644
--- a/src/plugins/cppeditor/cpphighlighter.h
+++ b/src/plugins/cppeditor/cpphighlighter.h
@@ -41,7 +41,7 @@ class CppHighlighter : public TextEditor::SyntaxHighlighter
Q_OBJECT
public:
- CppHighlighter(QTextDocument *document = 0);
+ CppHighlighter(QTextDocument *document = nullptr);
void setLanguageFeatures(const CPlusPlus::LanguageFeatures &languageFeatures);
void highlightBlock(const QString &text) override;
diff --git a/src/plugins/cppeditor/cppincludehierarchy.cpp b/src/plugins/cppeditor/cppincludehierarchy.cpp
index 5f8084ad62..eaa1b064c8 100644
--- a/src/plugins/cppeditor/cppincludehierarchy.cpp
+++ b/src/plugins/cppeditor/cppincludehierarchy.cpp
@@ -80,7 +80,7 @@ static Snapshot globalSnapshot()
struct FileAndLine
{
- FileAndLine() {}
+ FileAndLine() = default;
FileAndLine(const QString &f, int l) : file(f), line(l) {}
QString file;
@@ -122,7 +122,7 @@ class CppIncludeHierarchyItem
{
public:
enum SubTree { RootItem, InIncludes, InIncludedBy };
- CppIncludeHierarchyItem() {}
+ CppIncludeHierarchyItem() = default;
void createChild(const QString &filePath, SubTree subTree,
int line = 0, bool definitelyNoChildren = false)
@@ -348,7 +348,7 @@ class CppIncludeHierarchyWidget : public QWidget
public:
CppIncludeHierarchyWidget();
- ~CppIncludeHierarchyWidget() { delete m_treeView; }
+ ~CppIncludeHierarchyWidget() override { delete m_treeView; }
void perform();
@@ -509,9 +509,9 @@ void CppIncludeHierarchyWidget::syncFromEditorManager()
// Use cppDocumentUpdated to catch parsing finished and later file updates.
// The timer limits the amount of hierarchy updates.
- connect(document, &CppEditorDocument::cppDocumentUpdated, this, [this]() {
- m_timer->start();
- }, Qt::UniqueConnection);
+ connect(document, &CppEditorDocument::cppDocumentUpdated,
+ m_timer, QOverload<>::of(&QTimer::start),
+ Qt::UniqueConnection);
}
// CppIncludeHierarchyFactory
diff --git a/src/plugins/cppeditor/cppincludehierarchy.h b/src/plugins/cppeditor/cppincludehierarchy.h
index 4b9a867215..99310a8904 100644
--- a/src/plugins/cppeditor/cppincludehierarchy.h
+++ b/src/plugins/cppeditor/cppincludehierarchy.h
@@ -38,7 +38,7 @@ class CppIncludeHierarchyItem;
class CppIncludeHierarchyModel : public Utils::TreeModel<CppIncludeHierarchyItem>
{
Q_OBJECT
- typedef Utils::TreeModel<CppIncludeHierarchyItem> base_type;
+ using base_type = Utils::TreeModel<CppIncludeHierarchyItem>;
public:
CppIncludeHierarchyModel();
diff --git a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp
index 260fa5235b..748c48cf0b 100644
--- a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp
+++ b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp
@@ -92,8 +92,8 @@ public:
ModeImplementationFile = 0x00000008
};
- InsertVirtualMethodsDialog(QWidget *parent = 0);
- ~InsertVirtualMethodsDialog();
+ InsertVirtualMethodsDialog(QWidget *parent = nullptr);
+ ~InsertVirtualMethodsDialog() override;
void initGui();
void initData();
virtual void saveSettings();
@@ -113,20 +113,20 @@ private:
void updateOverrideReplacementsComboBox();
private:
- QTreeView *m_view;
- QLineEdit *m_filter;
- QCheckBox *m_hideReimplementedFunctions;
- QComboBox *m_insertMode;
- QCheckBox *m_virtualKeyword;
- QCheckBox *m_overrideReplacementCheckBox;
- QComboBox *m_overrideReplacementComboBox;
- QToolButton *m_clearUserAddedReplacementsButton;
- QDialogButtonBox *m_buttons;
+ QTreeView *m_view = nullptr;
+ QLineEdit *m_filter = nullptr;
+ QCheckBox *m_hideReimplementedFunctions = nullptr;
+ QComboBox *m_insertMode = nullptr;
+ QCheckBox *m_virtualKeyword = nullptr;
+ QCheckBox *m_overrideReplacementCheckBox = nullptr;
+ QComboBox *m_overrideReplacementComboBox = nullptr;
+ QToolButton *m_clearUserAddedReplacementsButton = nullptr;
+ QDialogButtonBox *m_buttons = nullptr;
QList<bool> m_expansionStateNormal;
QList<bool> m_expansionStateReimp;
QStringList m_availableOverrideReplacements;
- bool m_hasImplementationFile;
- bool m_hasReimplementedFunctions;
+ bool m_hasImplementationFile = false;
+ bool m_hasReimplementedFunctions = false;
protected:
VirtualMethodsSettings *m_settings;
@@ -149,15 +149,11 @@ namespace {
class InsertVirtualMethodsItem
{
public:
- InsertVirtualMethodsItem(InsertVirtualMethodsItem *parent) :
- row(-1),
- m_parent(parent)
- {
- }
+ InsertVirtualMethodsItem(InsertVirtualMethodsItem *parent)
+ : m_parent(parent)
+ {}
- virtual ~InsertVirtualMethodsItem()
- {
- }
+ virtual ~InsertVirtualMethodsItem() = default;
virtual QString description() const = 0;
virtual Qt::ItemFlags flags() const = 0;
@@ -165,10 +161,10 @@ public:
InsertVirtualMethodsItem *parent() { return m_parent; }
- int row;
+ int row = -1;
private:
- InsertVirtualMethodsItem *m_parent;
+ InsertVirtualMethodsItem *m_parent = nullptr;
};
class FunctionItem;
@@ -177,11 +173,11 @@ class ClassItem : public InsertVirtualMethodsItem
{
public:
ClassItem(const QString &className, const Class *clazz);
- ~ClassItem();
+ ~ClassItem() override;
- QString description() const { return name; }
- Qt::ItemFlags flags() const;
- Qt::CheckState checkState() const;
+ QString description() const override { return name; }
+ Qt::ItemFlags flags() const override;
+ Qt::CheckState checkState() const override;
void removeFunction(int row);
const Class *klass;
@@ -193,9 +189,9 @@ class FunctionItem : public InsertVirtualMethodsItem
{
public:
FunctionItem(const Function *func, const QString &functionName, ClassItem *parent);
- QString description() const;
- Qt::ItemFlags flags() const;
- Qt::CheckState checkState() const { return checked ? Qt::Checked : Qt::Unchecked; }
+ QString description() const override;
+ Qt::ItemFlags flags() const override;
+ Qt::CheckState checkState() const override { return checked ? Qt::Checked : Qt::Unchecked; }
const Function *function = nullptr;
InsertionPointLocator::AccessSpec accessSpec = InsertionPointLocator::Invalid;
@@ -209,7 +205,7 @@ private:
};
ClassItem::ClassItem(const QString &className, const Class *clazz) :
- InsertVirtualMethodsItem(0),
+ InsertVirtualMethodsItem(nullptr),
klass(clazz),
name(className)
{
@@ -339,7 +335,7 @@ public:
bool insertOverrideReplacement = false;
private:
- typedef QLatin1String _;
+ using _ = QLatin1String;
static QString group() { return _("QuickFix/InsertVirtualMethods"); }
static QString insertVirtualKeywordKey() { return _("insertKeywordVirtual"); }
static QString insertOverrideReplacementKey() { return _("insertOverrideReplacement"); }
@@ -352,13 +348,13 @@ private:
class InsertVirtualMethodsModel : public QAbstractItemModel
{
public:
- InsertVirtualMethodsModel(QObject *parent = 0) : QAbstractItemModel(parent)
+ InsertVirtualMethodsModel(QObject *parent = nullptr) : QAbstractItemModel(parent)
{
const FontSettings &fs = TextEditorSettings::fontSettings();
formatReimpFunc = fs.formatFor(C_DISABLED_CODE);
}
- ~InsertVirtualMethodsModel()
+ ~InsertVirtualMethodsModel() override
{
clear();
}
@@ -371,26 +367,26 @@ public:
endResetModel();
}
- QModelIndex index(int row, int column, const QModelIndex &parent) const
+ QModelIndex index(int row, int column, const QModelIndex &parent) const override
{
if (column != 0)
- return QModelIndex();
+ return {};
if (parent.isValid()) {
- ClassItem *classItem = static_cast<ClassItem *>(parent.internalPointer());
+ auto classItem = static_cast<ClassItem *>(parent.internalPointer());
return createIndex(row, column, classItem->functions.at(row));
}
return createIndex(row, column, classes.at(row));
}
- QModelIndex parent(const QModelIndex &child) const
+ QModelIndex parent(const QModelIndex &child) const override
{
if (!child.isValid())
- return QModelIndex();
+ return {};
InsertVirtualMethodsItem *parent = itemForIndex(child)->parent();
return parent ? createIndex(parent->row, 0, parent) : QModelIndex();
}
- int rowCount(const QModelIndex &parent) const
+ int rowCount(const QModelIndex &parent) const override
{
if (!parent.isValid())
return classes.count();
@@ -400,7 +396,7 @@ public:
return static_cast<ClassItem *>(item)->functions.count();
}
- int columnCount(const QModelIndex &) const
+ int columnCount(const QModelIndex &) const override
{
return 1;
}
@@ -416,13 +412,13 @@ public:
void removeFunction(FunctionItem *funcItem)
{
- ClassItem *classItem = static_cast<ClassItem *>(funcItem->parent());
+ auto classItem = static_cast<ClassItem *>(funcItem->parent());
beginRemoveRows(createIndex(classItem->row, 0, classItem), funcItem->row, funcItem->row);
classItem->removeFunction(funcItem->row);
endRemoveRows();
}
- QVariant data(const QModelIndex &index, int role) const
+ QVariant data(const QModelIndex &index, int role) const override
{
if (!index.isValid())
return QVariant();
@@ -446,7 +442,7 @@ public:
break;
case InsertVirtualMethodsDialog::Reimplemented:
if (item->parent()) {
- FunctionItem *function = static_cast<FunctionItem *>(item);
+ auto function = static_cast<FunctionItem *>(item);
return QVariant(function->alreadyFound);
}
@@ -454,7 +450,7 @@ public:
return QVariant();
}
- bool setData(const QModelIndex &index, const QVariant &value, int role)
+ bool setData(const QModelIndex &index, const QVariant &value, int role) override
{
if (!index.isValid())
return false;
@@ -464,7 +460,7 @@ public:
case Qt::CheckStateRole: {
bool checked = value.toInt() == Qt::Checked;
if (item->parent()) {
- FunctionItem *funcItem = static_cast<FunctionItem *>(item);
+ auto funcItem = static_cast<FunctionItem *>(item);
while (funcItem->checked != checked) {
funcItem->checked = checked;
const QModelIndex funcIndex = createIndex(funcItem->row, 0, funcItem);
@@ -475,7 +471,7 @@ public:
funcItem = funcItem->nextOverride;
}
} else {
- ClassItem *classItem = static_cast<ClassItem *>(item);
+ auto classItem = static_cast<ClassItem *>(item);
foreach (FunctionItem *funcItem, classItem->functions) {
if (funcItem->alreadyFound || funcItem->checked == checked)
continue;
@@ -489,7 +485,7 @@ public:
return QAbstractItemModel::setData(index, value, role);
}
- Qt::ItemFlags flags(const QModelIndex &index) const
+ Qt::ItemFlags flags(const QModelIndex &index) const override
{
if (!index.isValid())
return Qt::NoItemFlags;
@@ -586,7 +582,7 @@ public:
if (!name || name->asDestructorNameId())
continue;
- const Function *firstVirtual = 0;
+ const Function *firstVirtual = nullptr;
const bool isVirtual = FunctionUtils::isVirtualFunction(
func, interface.context(), &firstVirtual);
if (!isVirtual)
@@ -594,7 +590,7 @@ public:
if (func->isFinal()) {
if (FunctionItem *first = virtualFunctions[firstVirtual]) {
- FunctionItem *next = 0;
+ FunctionItem *next = nullptr;
for (FunctionItem *removed = first; next != first; removed = next) {
next = removed->nextOverride;
m_factory->classFunctionModel->removeFunction(removed);
@@ -643,7 +639,7 @@ public:
itemName += QLatin1String(" : ") + itemReturnTypeString;
if (isReimplemented)
itemName += QLatin1String(" (redeclared)");
- FunctionItem *funcItem = new FunctionItem(func, itemName, itemBase);
+ auto funcItem = new FunctionItem(func, itemName, itemBase);
if (isReimplemented) {
factory->setHasReimplementedFunctions(true);
funcItem->reimplemented = true;
@@ -734,7 +730,7 @@ public:
return spec;
}
- void perform()
+ void perform() override
{
if (!m_factory->gather())
return;
@@ -897,12 +893,11 @@ class InsertVirtualMethodsFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
- InsertVirtualMethodsFilterModel(QObject *parent = 0)
+ InsertVirtualMethodsFilterModel(QObject *parent = nullptr)
: QSortFilterProxyModel(parent)
- , m_hideReimplemented(false)
{}
- bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+ bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
@@ -941,22 +936,11 @@ public:
}
private:
- bool m_hideReimplemented;
+ bool m_hideReimplemented = false;
};
InsertVirtualMethodsDialog::InsertVirtualMethodsDialog(QWidget *parent)
: QDialog(parent)
- , m_view(0)
- , m_filter(0)
- , m_hideReimplementedFunctions(0)
- , m_insertMode(0)
- , m_virtualKeyword(0)
- , m_overrideReplacementCheckBox(0)
- , m_overrideReplacementComboBox(0)
- , m_clearUserAddedReplacementsButton(0)
- , m_buttons(0)
- , m_hasImplementationFile(false)
- , m_hasReimplementedFunctions(false)
, m_settings(new VirtualMethodsSettings)
, classFunctionModel(new InsertVirtualMethodsModel(this))
, classFunctionFilterModel(new InsertVirtualMethodsFilterModel(this))
@@ -976,11 +960,11 @@ void InsertVirtualMethodsDialog::initGui()
return;
setWindowTitle(tr("Insert Virtual Functions"));
- QVBoxLayout *globalVerticalLayout = new QVBoxLayout;
+ auto globalVerticalLayout = new QVBoxLayout;
// View
QGroupBox *groupBoxView = new QGroupBox(tr("&Functions to insert:"), this);
- QVBoxLayout *groupBoxViewLayout = new QVBoxLayout(groupBoxView);
+ auto groupBoxViewLayout = new QVBoxLayout(groupBoxView);
m_filter = new QLineEdit(this);
m_filter->setClearButtonEnabled(true);
m_filter->setPlaceholderText(tr("Filter"));
@@ -995,7 +979,7 @@ void InsertVirtualMethodsDialog::initGui()
// Insertion options
QGroupBox *groupBoxImplementation = new QGroupBox(tr("&Insertion options:"), this);
- QVBoxLayout *groupBoxImplementationLayout = new QVBoxLayout(groupBoxImplementation);
+ auto groupBoxImplementationLayout = new QVBoxLayout(groupBoxImplementation);
m_insertMode = new QComboBox(this);
m_insertMode->addItem(tr("Insert only declarations"), ModeOnlyDeclarations);
m_insertMode->addItem(tr("Insert definitions inside class"), ModeInsideClass);
@@ -1012,7 +996,7 @@ void InsertVirtualMethodsDialog::initGui()
connect(m_overrideReplacementCheckBox, &QCheckBox::clicked,
m_overrideReplacementComboBox, &QComboBox::setEnabled);
- QAction *clearUserAddedReplacements = new QAction(this);
+ auto clearUserAddedReplacements = new QAction(this);
clearUserAddedReplacements->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon());
clearUserAddedReplacements->setText(tr("Clear Added \"override\" Equivalents"));
connect(clearUserAddedReplacements, &QAction::triggered, [this]() {
@@ -1023,7 +1007,7 @@ void InsertVirtualMethodsDialog::initGui()
m_clearUserAddedReplacementsButton = new QToolButton(this);
m_clearUserAddedReplacementsButton->setDefaultAction(clearUserAddedReplacements);
- QHBoxLayout *overrideWidgetsLayout = new QHBoxLayout(this);
+ auto overrideWidgetsLayout = new QHBoxLayout(this);
overrideWidgetsLayout->setSpacing(0);
overrideWidgetsLayout->setMargin(0);
overrideWidgetsLayout->addWidget(m_overrideReplacementCheckBox);
@@ -1145,8 +1129,7 @@ void InsertVirtualMethodsDialog::setHasReimplementedFunctions(bool functions)
void InsertVirtualMethodsDialog::setHideReimplementedFunctions(bool hide)
{
- InsertVirtualMethodsFilterModel *model =
- qobject_cast<InsertVirtualMethodsFilterModel *>(classFunctionFilterModel);
+ auto model = qobject_cast<InsertVirtualMethodsFilterModel *>(classFunctionFilterModel);
if (m_expansionStateNormal.isEmpty() && m_expansionStateReimp.isEmpty()) {
model->setHideReimplementedFunctions(hide);
@@ -1172,8 +1155,7 @@ void InsertVirtualMethodsDialog::updateOverrideReplacementsComboBox()
void InsertVirtualMethodsDialog::saveExpansionState()
{
- InsertVirtualMethodsFilterModel *model =
- qobject_cast<InsertVirtualMethodsFilterModel *>(classFunctionFilterModel);
+ auto model = qobject_cast<InsertVirtualMethodsFilterModel *>(classFunctionFilterModel);
QList<bool> &state = model->hideReimplemented() ? m_expansionStateReimp
: m_expansionStateNormal;
@@ -1184,8 +1166,7 @@ void InsertVirtualMethodsDialog::saveExpansionState()
void InsertVirtualMethodsDialog::restoreExpansionState()
{
- InsertVirtualMethodsFilterModel *model =
- qobject_cast<InsertVirtualMethodsFilterModel *>(classFunctionFilterModel);
+ auto model = qobject_cast<InsertVirtualMethodsFilterModel *>(classFunctionFilterModel);
const QList<bool> &state = model->hideReimplemented() ? m_expansionStateReimp
: m_expansionStateNormal;
diff --git a/src/plugins/cppeditor/cppinsertvirtualmethods.h b/src/plugins/cppeditor/cppinsertvirtualmethods.h
index cc48fede93..c185ec90dd 100644
--- a/src/plugins/cppeditor/cppinsertvirtualmethods.h
+++ b/src/plugins/cppeditor/cppinsertvirtualmethods.h
@@ -36,9 +36,9 @@ class InsertVirtualMethods : public CppQuickFixFactory
{
Q_OBJECT
public:
- InsertVirtualMethods(InsertVirtualMethodsDialog *dialog = 0);
- ~InsertVirtualMethods();
- void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result);
+ InsertVirtualMethods(InsertVirtualMethodsDialog *dialog = nullptr);
+ ~InsertVirtualMethods() override;
+ void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
#ifdef WITH_TESTS
static InsertVirtualMethods *createTestFactory();
#endif
diff --git a/src/plugins/cppeditor/cppminimizableinfobars.h b/src/plugins/cppeditor/cppminimizableinfobars.h
index 624433d86f..f53c43c084 100644
--- a/src/plugins/cppeditor/cppminimizableinfobars.h
+++ b/src/plugins/cppeditor/cppminimizableinfobars.h
@@ -51,7 +51,7 @@ public:
static Actions createShowInfoBarActions(const ActionCreator &actionCreator);
public:
- explicit MinimizableInfoBars(Core::InfoBar &infoBar, QObject *parent = 0);
+ explicit MinimizableInfoBars(Core::InfoBar &infoBar, QObject *parent = nullptr);
// Expected call order: processHasProjectPart(), processHeaderDiagnostics()
void processHasProjectPart(bool hasProjectPart);
diff --git a/src/plugins/cppeditor/cpppreprocessordialog.h b/src/plugins/cppeditor/cpppreprocessordialog.h
index 2bca50f401..8194306933 100644
--- a/src/plugins/cppeditor/cpppreprocessordialog.h
+++ b/src/plugins/cppeditor/cpppreprocessordialog.h
@@ -38,9 +38,9 @@ class CppPreProcessorDialog : public QDialog
public:
explicit CppPreProcessorDialog(const QString &filePath, QWidget *parent);
- ~CppPreProcessorDialog();
+ ~CppPreProcessorDialog() override;
- int exec();
+ int exec() override;
QString extraPreprocessorDirectives() const;
diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp
index c91c4dccb8..a22b85f5e4 100644
--- a/src/plugins/cppeditor/cppquickfix.cpp
+++ b/src/plugins/cppeditor/cppquickfix.cpp
@@ -39,5 +39,4 @@ CppQuickFixOperation::CppQuickFixOperation(const CppQuickFixInterface &interface
: QuickFixOperation(priority), CppQuickFixInterface(interface)
{}
-CppQuickFixOperation::~CppQuickFixOperation()
-{}
+CppQuickFixOperation::~CppQuickFixOperation() = default;
diff --git a/src/plugins/cppeditor/cppquickfix.h b/src/plugins/cppeditor/cppquickfix.h
index 48ba6ece66..3fe054f8a0 100644
--- a/src/plugins/cppeditor/cppquickfix.h
+++ b/src/plugins/cppeditor/cppquickfix.h
@@ -39,7 +39,7 @@ class CPPEDITOR_EXPORT CppQuickFixOperation
{
public:
explicit CppQuickFixOperation(const CppQuickFixInterface &interface, int priority = -1);
- ~CppQuickFixOperation();
+ ~CppQuickFixOperation() override;
};
/*!
@@ -60,7 +60,7 @@ class CPPEDITOR_EXPORT CppQuickFixFactory : public QObject
public:
CppQuickFixFactory();
- ~CppQuickFixFactory();
+ ~CppQuickFixFactory() override;
using QuickFixOperations = TextEditor::QuickFixOperations;
diff --git a/src/plugins/cppeditor/cppquickfixassistant.h b/src/plugins/cppeditor/cppquickfixassistant.h
index 89aa798aa4..bc9fc41542 100644
--- a/src/plugins/cppeditor/cppquickfixassistant.h
+++ b/src/plugins/cppeditor/cppquickfixassistant.h
@@ -35,7 +35,7 @@
namespace CppTools {
class CppRefactoringFile;
-typedef QSharedPointer<CppRefactoringFile> CppRefactoringFilePtr;
+using CppRefactoringFilePtr = QSharedPointer<CppRefactoringFile>;
}
namespace CppEditor {
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index eeba204dba..c17850662f 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -173,23 +173,23 @@ inline bool isQtFuzzyComparable(const QString &typeName)
Class *isMemberFunction(const LookupContext &context, Function *function)
{
- QTC_ASSERT(function, return 0);
+ QTC_ASSERT(function, return nullptr);
Scope *enclosingScope = function->enclosingScope();
while (!(enclosingScope->isNamespace() || enclosingScope->isClass()))
enclosingScope = enclosingScope->enclosingScope();
- QTC_ASSERT(enclosingScope != 0, return 0);
+ QTC_ASSERT(enclosingScope != nullptr, return nullptr);
const Name *functionName = function->name();
if (!functionName)
- return 0;
+ return nullptr;
if (!functionName->isQualifiedNameId())
- return 0; // trying to add a declaration for a global function
+ return nullptr; // trying to add a declaration for a global function
const QualifiedNameId *q = functionName->asQualifiedNameId();
if (!q->base())
- return 0;
+ return nullptr;
if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) {
foreach (Symbol *s, binding->symbols()) {
@@ -198,23 +198,23 @@ Class *isMemberFunction(const LookupContext &context, Function *function)
}
}
- return 0;
+ return nullptr;
}
Namespace *isNamespaceFunction(const LookupContext &context, Function *function)
{
- QTC_ASSERT(function, return 0);
+ QTC_ASSERT(function, return nullptr);
if (isMemberFunction(context, function))
- return 0;
+ return nullptr;
Scope *enclosingScope = function->enclosingScope();
while (!(enclosingScope->isNamespace() || enclosingScope->isClass()))
enclosingScope = enclosingScope->enclosingScope();
- QTC_ASSERT(enclosingScope != 0, return 0);
+ QTC_ASSERT(enclosingScope != nullptr, return nullptr);
const Name *functionName = function->name();
if (!functionName)
- return 0;
+ return nullptr;
// global namespace
if (!functionName->isQualifiedNameId()) {
@@ -222,12 +222,12 @@ Namespace *isNamespaceFunction(const LookupContext &context, Function *function)
if (Namespace *matchingNamespace = s->asNamespace())
return matchingNamespace;
}
- return 0;
+ return nullptr;
}
const QualifiedNameId *q = functionName->asQualifiedNameId();
if (!q->base())
- return 0;
+ return nullptr;
if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) {
foreach (Symbol *s, binding->symbols()) {
@@ -236,7 +236,7 @@ Namespace *isNamespaceFunction(const LookupContext &context, Function *function)
}
}
- return 0;
+ return nullptr;
}
// Given include is e.g. "afile.h" or <afile.h> (quotes/angle brackets included!).
@@ -308,10 +308,12 @@ namespace {
class InverseLogicalComparisonOp: public CppQuickFixOperation
{
public:
- InverseLogicalComparisonOp(const CppQuickFixInterface &interface, int priority,
- BinaryExpressionAST *binary, Kind invertToken)
+ InverseLogicalComparisonOp(const CppQuickFixInterface &interface,
+ int priority,
+ BinaryExpressionAST *binary,
+ Kind invertToken)
: CppQuickFixOperation(interface, priority)
- , binary(binary), nested(0), negation(0)
+ , binary(binary)
{
Token tok;
tok.f.kind = invertToken;
@@ -324,19 +326,17 @@ public:
// check for ! before parentheses
if (nested && priority - 2 >= 0) {
negation = interface.path()[priority - 2]->asUnaryExpression();
- if (negation
- && !interface.currentFile()->tokenAt(negation->unary_op_token).is(T_EXCLAIM)) {
- negation = 0;
- }
+ if (negation && !interface.currentFile()->tokenAt(negation->unary_op_token).is(T_EXCLAIM))
+ negation = nullptr;
}
}
- QString description() const
+ QString description() const override
{
return QApplication::translate("CppTools::QuickFix", "Rewrite Using %1").arg(replacement);
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -357,9 +357,9 @@ public:
}
private:
- BinaryExpressionAST *binary;
- NestedExpressionAST *nested;
- UnaryExpressionAST *negation;
+ BinaryExpressionAST *binary = nullptr;
+ NestedExpressionAST *nested = nullptr;
+ UnaryExpressionAST *negation = nullptr;
QString replacement;
};
@@ -420,7 +420,7 @@ public:
setPriority(priority);
}
- QString description() const
+ QString description() const override
{
if (replacement.isEmpty())
return QApplication::translate("CppTools::QuickFix", "Swap Operands");
@@ -428,7 +428,7 @@ public:
return QApplication::translate("CppTools::QuickFix", "Rewrite Using %1").arg(replacement);
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -515,7 +515,7 @@ public:
pattern = mk->BinaryExpression(left, right);
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -539,7 +539,7 @@ public:
void RewriteLogicalAnd::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
{
- BinaryExpressionAST *expression = 0;
+ BinaryExpressionAST *expression = nullptr;
const QList<AST *> &path = interface.path();
CppRefactoringFilePtr file = interface.currentFile();
@@ -582,10 +582,10 @@ static bool checkDeclarationForSplit(SimpleDeclarationAST *declaration)
for (SpecifierListAST *it = declaration->decl_specifier_list; it; it = it->next) {
SpecifierAST *specifier = it->value;
- if (specifier->asEnumSpecifier() != 0)
+ if (specifier->asEnumSpecifier() != nullptr)
return false;
- else if (specifier->asClassSpecifier() != 0)
+ else if (specifier->asClassSpecifier() != nullptr)
return false;
}
@@ -612,7 +612,7 @@ public:
"Split Declaration"));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -655,7 +655,7 @@ private:
void SplitSimpleDeclaration::match(const CppQuickFixInterface &interface,
QuickFixOperations &result)
{
- CoreDeclaratorAST *core_declarator = 0;
+ CoreDeclaratorAST *core_declarator = nullptr;
const QList<AST *> &path = interface.path();
CppRefactoringFilePtr file = interface.currentFile();
const int cursorPosition = file->cursor().selectionStart();
@@ -702,7 +702,7 @@ public:
setDescription(QApplication::translate("CppTools::QuickFix", "Add Curly Braces"));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -775,7 +775,7 @@ public:
pattern = mk.IfStatement(condition);
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -806,7 +806,7 @@ void MoveDeclarationOutOfIf::match(const CppQuickFixInterface &interface,
QuickFixOperations &result)
{
const QList<AST *> &path = interface.path();
- typedef QSharedPointer<MoveDeclarationOutOfIfOp> Ptr;
+ using Ptr = QSharedPointer<MoveDeclarationOutOfIfOp>;
Ptr op(new MoveDeclarationOutOfIfOp(interface));
int index = path.size() - 1;
@@ -849,7 +849,7 @@ public:
pattern = mk.WhileStatement(condition);
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -928,7 +928,7 @@ public:
"Split if Statement"));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -997,7 +997,7 @@ private:
void SplitIfStatement::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
{
- IfStatementAST *pattern = 0;
+ IfStatementAST *pattern = nullptr;
const QList<AST *> &path = interface.path();
int index = path.size() - 1;
@@ -1118,10 +1118,10 @@ static ExpressionAST *analyzeStringLiteral(const QList<AST *> &path,
if (enclosingFunction)
enclosingFunction->clear();
if (enclosingFunctionCall)
- *enclosingFunctionCall = 0;
+ *enclosingFunctionCall = nullptr;
if (path.isEmpty())
- return 0;
+ return nullptr;
ExpressionAST *literal = path.last()->asExpression();
if (literal) {
@@ -1167,7 +1167,7 @@ public:
setDescription(description);
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -1371,7 +1371,7 @@ public:
"Convert to Objective-C String Literal"));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -1414,7 +1414,7 @@ void ConvertCStringToNSString::match(const CppQuickFixInterface &interface,
if (!literal || type != TypeString)
return;
if (!isQtStringLiteral(enclosingFunction))
- qlatin1Call = 0;
+ qlatin1Call = nullptr;
result << new ConvertCStringToNSStringOp(interface, path.size() - 1, literal->asStringLiteral(),
qlatin1Call);
@@ -1433,7 +1433,7 @@ public:
, replacement(replacement)
{}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -1595,7 +1595,7 @@ public:
setDescription(QApplication::translate("CppTools::QuickFix", "Add Local Declaration"));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -1652,10 +1652,10 @@ void AddLocalDeclaration::match(const CppQuickFixInterface &interface, QuickFixO
&& file->tokenAt(binary->binary_op_token).is(T_EQUAL)) {
IdExpressionAST *idExpr = binary->left_expression->asIdExpression();
if (interface.isCursorOn(binary->left_expression) && idExpr
- && idExpr->name->asSimpleName() != 0) {
+ && idExpr->name->asSimpleName() != nullptr) {
SimpleNameAST *nameAST = idExpr->name->asSimpleName();
const QList<LookupItem> results = interface.context().lookup(nameAST->name, file->scopeAt(nameAST->firstToken()));
- Declaration *decl = 0;
+ Declaration *decl = nullptr;
foreach (const LookupItem &r, results) {
if (!r.declaration())
continue;
@@ -1689,7 +1689,7 @@ public:
setDescription(QApplication::translate("CppTools::QuickFix", "Convert to Camel Case"));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -1727,7 +1727,7 @@ void ConvertToCamelCase::match(const CppQuickFixInterface &interface, QuickFixOp
return;
AST * const ast = path.last();
- const Name *name = 0;
+ const Name *name = nullptr;
if (const NameAST * const nameAst = ast->asName()) {
if (nameAst->name && nameAst->name->asNameId())
name = nameAst->name;
@@ -1832,9 +1832,9 @@ ProjectExplorer::HeaderPaths relevantHeaderPaths(const QString &filePath)
NameAST *nameUnderCursor(const QList<AST *> &path)
{
if (path.isEmpty())
- return 0;
+ return nullptr;
- NameAST *nameAst = 0;
+ NameAST *nameAst = nullptr;
for (int i = path.size() - 1; i >= 0; --i) {
AST * const ast = path.at(i);
if (SimpleNameAST *simpleName = ast->asSimpleName()) {
@@ -2037,7 +2037,7 @@ public:
setDescription(targetString);
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -2063,7 +2063,7 @@ void RearrangeParamDeclarationList::match(const CppQuickFixInterface &interface,
{
const QList<AST *> path = interface.path();
- ParameterDeclarationAST *paramDecl = 0;
+ ParameterDeclarationAST *paramDecl = nullptr;
int index = path.size() - 1;
for (; index != -1; --index) {
paramDecl = path.at(index)->asParameterDeclaration();
@@ -2078,7 +2078,7 @@ void RearrangeParamDeclarationList::match(const CppQuickFixInterface &interface,
QTC_ASSERT(paramDeclClause && paramDeclClause->parameter_declaration_list, return);
ParameterDeclarationListAST *paramListNode = paramDeclClause->parameter_declaration_list;
- ParameterDeclarationListAST *prevParamListNode = 0;
+ ParameterDeclarationListAST *prevParamListNode = nullptr;
while (paramListNode) {
if (paramDecl == paramListNode->value)
break;
@@ -2117,7 +2117,7 @@ public:
setDescription(description);
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -2135,15 +2135,6 @@ private:
class ReformatPointerDeclarationASTPathResultsFilter
{
public:
- ReformatPointerDeclarationASTPathResultsFilter()
- : m_hasSimpleDeclaration(false)
- , m_hasFunctionDefinition(false)
- , m_hasParameterDeclaration(false)
- , m_hasIfStatement(false)
- , m_hasWhileStatement(false)
- , m_hasForStatement(false)
- , m_hasForeachStatement(false) {}
-
QList<AST*> filter(const QList<AST*> &astPathList)
{
QList<AST*> filtered;
@@ -2179,13 +2170,13 @@ public:
}
private:
- bool m_hasSimpleDeclaration;
- bool m_hasFunctionDefinition;
- bool m_hasParameterDeclaration;
- bool m_hasIfStatement;
- bool m_hasWhileStatement;
- bool m_hasForStatement;
- bool m_hasForeachStatement;
+ bool m_hasSimpleDeclaration = false;
+ bool m_hasFunctionDefinition = false;
+ bool m_hasParameterDeclaration = false;
+ bool m_hasIfStatement = false;
+ bool m_hasWhileStatement = false;
+ bool m_hasForStatement = false;
+ bool m_hasForeachStatement = false;
};
} // anonymous namespace
@@ -2248,7 +2239,7 @@ public:
return values;
}
- bool preVisit(AST *ast) {
+ bool preVisit(AST *ast) override {
if (CaseStatementAST *cs = ast->asCaseStatement()) {
foundCaseStatementLevel = true;
if (ExpressionAST *csExpression = cs->expression) {
@@ -2288,7 +2279,7 @@ public:
"Complete Switch Statement"));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -2335,7 +2326,7 @@ static Enum *findEnum(const QList<LookupItem> &results, const LookupContext &ctx
}
}
- return 0;
+ return nullptr;
}
Enum *conditionEnum(const CppQuickFixInterface &interface, SwitchStatementAST *statement)
@@ -2418,7 +2409,7 @@ public:
.arg(InsertionPointLocator::accessSpecToString(xsSpec)));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
@@ -2478,7 +2469,7 @@ void InsertDeclFromDef::match(const CppQuickFixInterface &interface, QuickFixOpe
const QList<AST *> &path = interface.path();
CppRefactoringFilePtr file = interface.currentFile();
- FunctionDefinitionAST *funDef = 0;
+ FunctionDefinitionAST *funDef = nullptr;
int idx = 0;
for (; idx < path.size(); ++idx) {
AST *node = path.at(idx);
@@ -2593,7 +2584,7 @@ public:
}
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
if (!m_loc.isValid())
@@ -2714,7 +2705,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
// Insert Position: Implementation File
DeclaratorAST *declAST = simpleDecl->declarator_list->value;
- InsertDefOperation *op = 0;
+ InsertDefOperation *op = nullptr;
ProjectFile::Kind kind = ProjectFile::classify(interface.fileName());
const bool isHeaderFile = ProjectFile::isHeader(kind);
if (isHeaderFile) {
@@ -2752,7 +2743,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
}
// Determine if we are dealing with a free function
- const bool isFreeFunction = func->enclosingClass() == 0;
+ const bool isFreeFunction = func->enclosingClass() == nullptr;
// Insert Position: Outside Class
if (!isFreeFunction) {
@@ -2817,15 +2808,6 @@ public:
GenerateGetterSetterOperation(const CppQuickFixInterface &interface)
: CppQuickFixOperation(interface)
- , m_type(InvalidType)
- , m_variableName(0)
- , m_declaratorId(0)
- , m_declarator(0)
- , m_variableDecl(0)
- , m_classSpecifier(0)
- , m_classDecl(0)
- , m_symbol(0)
- , m_offerQuickFix(true)
{
const QList<AST *> &path = interface.path();
// We expect something like
@@ -3037,7 +3019,7 @@ public:
&& m_offerQuickFix;
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -3101,13 +3083,13 @@ public:
const QString declarationGetterTypeAndNameString = oo.prettyType(getterType, m_getterName);
const QString declarationGetter = QString::fromLatin1("%1%2()%3;\n")
- .arg(isStatic ? QLatin1String("static ") : QString())
- .arg(declarationGetterTypeAndNameString)
- .arg(isStatic ? QString() : QLatin1String(" const"));
+ .arg(isStatic ? QLatin1String("static ") : QString(),
+ declarationGetterTypeAndNameString,
+ isStatic ? QString() : QLatin1String(" const"));
const QString declarationSetter = QString::fromLatin1("%1void %2(%3);\n")
- .arg(isStatic ? QLatin1String("static ") : QString())
- .arg(m_setterName)
- .arg(paramString);
+ .arg(isStatic ? QLatin1String("static ") : QString(),
+ m_setterName,
+ paramString);
if (generateGetter())
declaration += declarationGetter;
@@ -3118,22 +3100,22 @@ public:
// Construct implementation strings
const QString implementationGetterTypeAndNameString = oo.prettyType(
getterType, QString::fromLatin1("%1::%2").arg(classString, m_getterName));
- const QString implementationGetter = QString::fromLatin1(
- "%1()%2\n"
- "{\n"
- "return %3;\n"
- "}")
- .arg(implementationGetterTypeAndNameString)
- .arg(isStatic ? QString() : QLatin1String(" const"))
- .arg(m_variableString);
- const QString implementationSetter = QString::fromLatin1(
- "void %1::%2(%3)\n"
- "{\n"
- "%4 = %5;\n"
- "}")
- .arg(classString).arg(m_setterName)
- .arg(paramString).arg(m_variableString)
- .arg(paramName);
+ const QString implementationGetter = QString::fromLatin1("%1()%2\n"
+ "{\n"
+ "return %3;\n"
+ "}")
+ .arg(implementationGetterTypeAndNameString,
+ isStatic ? QString() : QLatin1String(" const"),
+ m_variableString);
+ const QString implementationSetter = QString::fromLatin1("void %1::%2(%3)\n"
+ "{\n"
+ "%4 = %5;\n"
+ "}")
+ .arg(classString,
+ m_setterName,
+ paramString,
+ m_variableString,
+ paramName);
QString implementation;
if (generateGetter())
@@ -3175,20 +3157,20 @@ public:
currentFile->apply();
}
- OperationType m_type;
- SimpleNameAST *m_variableName;
- DeclaratorIdAST *m_declaratorId;
- DeclaratorAST *m_declarator;
- SimpleDeclarationAST *m_variableDecl;
- ClassSpecifierAST *m_classSpecifier;
- SimpleDeclarationAST *m_classDecl;
- Symbol *m_symbol;
+ OperationType m_type = InvalidType;
+ SimpleNameAST *m_variableName = nullptr;
+ DeclaratorIdAST *m_declaratorId = nullptr;
+ DeclaratorAST *m_declarator = nullptr;
+ SimpleDeclarationAST *m_variableDecl = nullptr;
+ ClassSpecifierAST *m_classSpecifier = nullptr;
+ SimpleDeclarationAST *m_classDecl = nullptr;
+ Symbol *m_symbol = nullptr;
QString m_baseName;
QString m_getterName;
QString m_setterName;
QString m_variableString;
- bool m_offerQuickFix;
+ bool m_offerQuickFix = true;
};
} // anonymous namespace
@@ -3196,7 +3178,7 @@ public:
void GenerateGetterSetter::match(const CppQuickFixInterface &interface,
QuickFixOperations &result)
{
- GenerateGetterSetterOperation *op = new GenerateGetterSetterOperation(interface);
+ auto op = new GenerateGetterSetterOperation(interface);
if (op->m_type != GenerateGetterSetterOperation::InvalidType) {
result << op;
if (op->m_type == GenerateGetterSetterOperation::GetterSetterType) {
@@ -3215,9 +3197,6 @@ namespace {
class ExtractFunctionOptions
{
public:
- ExtractFunctionOptions() : access(InsertionPointLocator::Public)
- {}
-
static bool isValidFunctionName(const QString &name)
{
return !name.isEmpty() && isValidIdentifier(name);
@@ -3229,7 +3208,7 @@ public:
}
QString funcName;
- InsertionPointLocator::AccessSpec access;
+ InsertionPointLocator::AccessSpec access = InsertionPointLocator::Public;
};
class ExtractFunctionOperation : public CppQuickFixOperation
@@ -3254,7 +3233,7 @@ public:
setDescription(QCoreApplication::translate("QuickFix::ExtractFunction", "Extract Function"));
}
- void perform()
+ void perform() override
{
QTC_ASSERT(!m_funcReturn || !m_relevantDecls.isEmpty(), return);
CppRefactoringChanges refactoring(snapshot());
@@ -3524,7 +3503,7 @@ public:
return !m_failed;
}
- bool preVisit(AST *)
+ bool preVisit(AST *) override
{
if (m_done)
return false;
@@ -3553,13 +3532,13 @@ public:
accept(stmt);
}
- bool visit(CaseStatementAST *stmt)
+ bool visit(CaseStatementAST *stmt) override
{
statement(stmt->statement);
return false;
}
- bool visit(CompoundStatementAST *stmt)
+ bool visit(CompoundStatementAST *stmt) override
{
for (StatementListAST *it = stmt->statement_list; it; it = it->next) {
statement(it->value);
@@ -3569,25 +3548,25 @@ public:
return false;
}
- bool visit(DoStatementAST *stmt)
+ bool visit(DoStatementAST *stmt) override
{
statement(stmt->statement);
return false;
}
- bool visit(ForeachStatementAST *stmt)
+ bool visit(ForeachStatementAST *stmt) override
{
statement(stmt->statement);
return false;
}
- bool visit(RangeBasedForStatementAST *stmt)
+ bool visit(RangeBasedForStatementAST *stmt) override
{
statement(stmt->statement);
return false;
}
- bool visit(ForStatementAST *stmt)
+ bool visit(ForStatementAST *stmt) override
{
statement(stmt->initializer);
if (!m_done)
@@ -3595,7 +3574,7 @@ public:
return false;
}
- bool visit(IfStatementAST *stmt)
+ bool visit(IfStatementAST *stmt) override
{
statement(stmt->statement);
if (!m_done)
@@ -3603,7 +3582,7 @@ public:
return false;
}
- bool visit(TryBlockStatementAST *stmt)
+ bool visit(TryBlockStatementAST *stmt) override
{
statement(stmt->statement);
for (CatchClauseListAST *it = stmt->catch_clause_list; it; it = it->next) {
@@ -3614,13 +3593,13 @@ public:
return false;
}
- bool visit(WhileStatementAST *stmt)
+ bool visit(WhileStatementAST *stmt) override
{
statement(stmt->statement);
return false;
}
- bool visit(DeclarationStatementAST *declStmt)
+ bool visit(DeclarationStatementAST *declStmt) override
{
// We need to collect the declarations we see before the extraction or even inside it.
// They might need to be used as either a parameter or return value. Actually, we could
@@ -3649,7 +3628,7 @@ public:
return false;
}
- bool visit(ReturnStatementAST *)
+ bool visit(ReturnStatementAST *) override
{
if (m_extractionStart) {
m_done = true;
@@ -3686,7 +3665,7 @@ void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOpera
return;
const QList<AST *> &path = interface.path();
- FunctionDefinitionAST *refFuncDef = 0; // The "reference" function, which we will extract from.
+ FunctionDefinitionAST *refFuncDef = nullptr; // The "reference" function, which we will extract from.
for (int i = path.size() - 1; i >= 0; --i) {
refFuncDef = path.at(i)->asFunctionDefinition();
if (refFuncDef)
@@ -3751,7 +3730,7 @@ void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOpera
}
// Identify what would be parameters for the new function and its return value, if any.
- Symbol *funcReturn = 0;
+ Symbol *funcReturn = nullptr;
QList<QPair<QString, QString> > relevantDecls;
SemanticInfo::LocalUseIterator it(interface.semanticInfo().localUses);
while (it.hasNext()) {
@@ -3853,7 +3832,7 @@ public:
}
private:
- bool visit(T *ast)
+ bool visit(T *ast) override
{
if (ast != m_literal
&& strcmp(m_file->tokenAt(ast->firstToken()).spell(), m_literalTokenText) != 0) {
@@ -3887,11 +3866,7 @@ public:
struct FoundDeclaration
{
- FoundDeclaration()
- : ast(0)
- {}
-
- FunctionDeclaratorAST *ast;
+ FunctionDeclaratorAST *ast = nullptr;
CppRefactoringFilePtr file;
};
@@ -3920,8 +3895,7 @@ public:
ASTPath astPath(result.file->cppDocument());
const QList<AST *> path = astPath(s->line(), s->column());
SimpleDeclarationAST *simpleDecl = nullptr;
- for (int idx = 0; idx < path.size(); ++idx) {
- AST *node = path.at(idx);
+ for (AST *node : path) {
simpleDecl = node->asSimpleDeclaration();
if (simpleDecl) {
if (simpleDecl->symbols && !simpleDecl->symbols->next) {
@@ -3945,13 +3919,12 @@ public:
return FoundDeclaration();
const LookupContext lc(result.file->cppDocument(), snapshot());
const QList<LookupItem> candidates = lc.lookup(func->name(), matchingNamespace);
- for (int i = 0; i < candidates.size(); ++i) {
- if (Symbol *s = candidates.at(i).declaration()) {
+ for (const LookupItem &candidate : candidates) {
+ if (Symbol *s = candidate.declaration()) {
if (s->asDeclaration()) {
ASTPath astPath(result.file->cppDocument());
const QList<AST *> path = astPath(s->line(), s->column());
- for (int idx = 0; idx < path.size(); ++idx) {
- AST *node = path.at(idx);
+ for (AST *node : path) {
SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration();
if (simpleDecl) {
result.ast = functionDeclarator(simpleDecl);
@@ -3965,7 +3938,7 @@ public:
return result;
}
- void perform()
+ void perform() override
{
FunctionDeclaratorAST *functionDeclaratorOfDefinition
= functionDeclarator(m_functionDefinition);
@@ -4045,7 +4018,7 @@ private:
if (functionDeclaratorAST)
return functionDeclaratorAST;
}
- return 0;
+ return nullptr;
}
FunctionDeclaratorAST *functionDeclarator(DeclaratorAST *ast) const
@@ -4055,7 +4028,7 @@ private:
if (funcdecl)
return funcdecl;
}
- return 0;
+ return nullptr;
}
FunctionDeclaratorAST *functionDeclarator(FunctionDefinitionAST *ast) const
@@ -4199,7 +4172,7 @@ private:
{
ExpressionListParenAST *exprlist = newExprAST->new_initializer
? newExprAST->new_initializer->asExpressionListParen()
- : 0;
+ : nullptr;
if (exprlist && exprlist->expression_list) {
// remove 'new' keyword and type before initializer
@@ -4405,8 +4378,8 @@ void ConvertFromAndToPointer::match(const CppQuickFixInterface &interface,
SimpleNameAST *identifier = path.last()->asSimpleName();
if (!identifier)
return;
- SimpleDeclarationAST *simpleDeclaration = 0;
- DeclaratorAST *declarator = 0;
+ SimpleDeclarationAST *simpleDeclaration = nullptr;
+ DeclaratorAST *declarator = nullptr;
bool isFunctionLocal = false;
bool isClassLocal = false;
ConvertFromAndToPointerOp::Mode mode = ConvertFromAndToPointerOp::FromVariable;
@@ -4428,7 +4401,7 @@ void ConvertFromAndToPointer::match(const CppQuickFixInterface &interface,
if (!isFunctionLocal || !simpleDeclaration || !declarator)
return;
- Symbol *symbol = 0;
+ Symbol *symbol = nullptr;
for (List<Symbol *> *lst = simpleDeclaration->symbols; lst; lst = lst->next) {
if (lst->value->name() == identifier->name) {
symbol = lst->value;
@@ -4501,7 +4474,7 @@ public:
setDescription(CppQuickFixFactory::tr("Generate Missing Q_PROPERTY Members"));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr file = refactoring.file(fileName());
@@ -4603,7 +4576,7 @@ void InsertQtPropertyMembers::match(const CppQuickFixInterface &interface,
if (!qtPropertyDeclaration || !qtPropertyDeclaration->type_id)
return;
- ClassSpecifierAST *klass = 0;
+ ClassSpecifierAST *klass = nullptr;
for (int i = path.size() - 2; i >= 0; --i) {
klass = path.at(i)->asClassSpecifier();
if (klass)
@@ -4675,7 +4648,7 @@ public:
, m_link(link)
{}
- void perform()
+ void perform() override
{
if (editor()->declDefLink() == m_link)
editor()->applyDeclDefLinkChanges(/*don't jump*/false);
@@ -4842,7 +4815,7 @@ public:
}
}
- void perform()
+ void perform() override
{
MoveFuncDefRefactoringHelper helper(this, m_type, m_headerFileName, m_cppFileName);
helper.performMove(m_funcDef);
@@ -4861,8 +4834,8 @@ private:
void MoveFuncDefOutside::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
{
const QList<AST *> &path = interface.path();
- SimpleDeclarationAST *classAST = 0;
- FunctionDefinitionAST *funcAST = 0;
+ SimpleDeclarationAST *classAST = nullptr;
+ FunctionDefinitionAST *funcAST = nullptr;
bool moveOutsideMemberDefinition = false;
const int pathSize = path.size();
@@ -4885,7 +4858,7 @@ void MoveFuncDefOutside::match(const CppQuickFixInterface &interface, QuickFixOp
break;
}
}
- funcAST = 0;
+ funcAST = nullptr;
}
}
@@ -4935,7 +4908,7 @@ public:
}
}
- void perform()
+ void perform() override
{
MoveFuncDefRefactoringHelper helper(this, m_type, m_headerFileName, m_cppFileName);
for (DeclarationListAST *it = m_classDef->member_specifier_list; it; it = it->next) {
@@ -5026,7 +4999,7 @@ public:
}
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr fromFile = refactoring.file(m_fromFileName);
@@ -5067,8 +5040,8 @@ private:
void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
{
const QList<AST *> &path = interface.path();
- AST *completeDefAST = 0;
- FunctionDefinitionAST *funcAST = 0;
+ AST *completeDefAST = nullptr;
+ FunctionDefinitionAST *funcAST = nullptr;
const int pathSize = path.size();
for (int idx = 1; idx < pathSize; ++idx) {
@@ -5084,7 +5057,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
completeDefAST = enclosingAST->asTemplateDeclaration() ? enclosingAST : funcAST;
break;
}
- funcAST = 0;
+ funcAST = nullptr;
}
}
@@ -5154,13 +5127,12 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
const CppRefactoringFilePtr declFile = refactoring.file(declFileName);
const LookupContext lc(declFile->cppDocument(), interface.snapshot());
const QList<LookupItem> candidates = lc.lookup(func->name(), matchingNamespace);
- for (int i = 0; i < candidates.size(); ++i) {
- if (Symbol *s = candidates.at(i).declaration()) {
+ for (const LookupItem &candidate : candidates) {
+ if (Symbol *s = candidate.declaration()) {
if (s->asDeclaration()) {
ASTPath astPath(declFile->cppDocument());
const QList<AST *> path = astPath(s->line(), s->column());
- for (int idx = 0; idx < path.size(); ++idx) {
- AST *node = path.at(idx);
+ for (AST *node : path) {
if (SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration()) {
declRange = declFile->range(simpleDecl);
declText = declFile->textOf(simpleDecl);
@@ -5199,7 +5171,7 @@ public:
setDescription(QApplication::translate("CppTools::QuickFix", "Assign to Local Variable"));
}
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr file = refactoring.file(fileName());
@@ -5274,8 +5246,8 @@ private:
void AssignToLocalVariable::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
{
const QList<AST *> &path = interface.path();
- AST *outerAST = 0;
- SimpleNameAST *nameAST = 0;
+ AST *outerAST = nullptr;
+ SimpleNameAST *nameAST = nullptr;
for (int i = path.size() - 3; i >= 0; --i) {
if (CallAST *callAST = path.at(i)->asCall()) {
@@ -5407,7 +5379,7 @@ public:
setDescription(QApplication::translate("CppTools::QuickFix", "Optimize for-Loop"));
}
- void perform()
+ void perform() override
{
QTC_ASSERT(m_forAst, return);
@@ -5494,7 +5466,7 @@ private:
void OptimizeForLoop::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
{
const QList<AST *> path = interface.path();
- ForStatementAST *forAst = 0;
+ ForStatementAST *forAst = nullptr;
if (!path.isEmpty())
forAst = path.last()->asForStatement();
if (!forAst || !interface.isCursorOn(forAst))
@@ -5514,7 +5486,7 @@ void OptimizeForLoop::match(const CppQuickFixInterface &interface, QuickFixOpera
// Check for optimizing condition
bool optimizeCondition = false;
FullySpecifiedType conditionType;
- ExpressionAST *conditionExpression = 0;
+ ExpressionAST *conditionExpression = nullptr;
if (forAst->initializer && forAst->condition) {
if (BinaryExpressionAST *binary = forAst->condition->asBinaryExpression()) {
// Get the expression against which we should evaluate
@@ -5566,7 +5538,7 @@ void OptimizeForLoop::match(const CppQuickFixInterface &interface, QuickFixOpera
if (optimizePostcrement || optimizeCondition) {
result << new OptimizeForLoopOperation(interface, forAst, optimizePostcrement,
- (optimizeCondition) ? conditionExpression : 0,
+ optimizeCondition ? conditionExpression : nullptr,
conditionType);
}
}
@@ -5604,8 +5576,7 @@ private:
static QByteArray escapeString(const QByteArray &contents)
{
QByteArray newContents;
- for (int i = 0; i < contents.length(); ++i) {
- quint8 c = contents.at(i);
+ for (const quint8 c : contents) {
if (isascii(c) && isprint(c)) {
newContents += c;
} else {
@@ -5665,7 +5636,7 @@ private:
// QuickFixOperation interface
public:
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -5752,7 +5723,7 @@ public:
}
private:
- void perform()
+ void perform() override
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
@@ -5770,7 +5741,7 @@ Symbol *skipForwardDeclarations(const QList<Symbol *> &symbols)
return symbol;
}
- return 0;
+ return nullptr;
}
bool findRawAccessFunction(Class *klass, PointerType *pointerType, QString *objAccessFunction)
@@ -5788,7 +5759,7 @@ bool findRawAccessFunction(Class *klass, PointerType *pointerType, QString *objA
}
}
}
- const Name *funcName = 0;
+ const Name *funcName = nullptr;
switch (candidates.size()) {
case 0:
return false;
@@ -5815,7 +5786,7 @@ PointerType *determineConvertedType(NamedType *namedType, const LookupContext &c
Scope *scope, QString *objAccessFunction)
{
if (!namedType)
- return 0;
+ return nullptr;
if (ClassOrNamespace *binding = context.lookupType(namedType->name(), scope)) {
if (Symbol *objectClassSymbol = skipForwardDeclarations(binding->symbols())) {
if (Class *klass = objectClassSymbol->asClass()) {
@@ -5834,7 +5805,7 @@ PointerType *determineConvertedType(NamedType *namedType, const LookupContext &c
}
}
- return 0;
+ return nullptr;
}
Class *senderOrReceiverClass(const CppQuickFixInterface &interface,
@@ -5856,33 +5827,33 @@ Class *senderOrReceiverClass(const CppQuickFixInterface &interface,
toe.init(interface.semanticInfo().doc, interface.snapshot(), context.bindings());
const QList<LookupItem> objectPointerExpressions = toe(objectPointerExpression,
objectPointerScope, TypeOfExpression::Preprocess);
- QTC_ASSERT(objectPointerExpressions.size() == 1, return 0);
+ QTC_ASSERT(objectPointerExpressions.size() == 1, return nullptr);
Type *objectPointerTypeBase = objectPointerExpressions.first().type().type();
- QTC_ASSERT(objectPointerTypeBase, return 0);
+ QTC_ASSERT(objectPointerTypeBase, return nullptr);
PointerType *objectPointerType = objectPointerTypeBase->asPointerType();
if (!objectPointerType) {
objectPointerType = determineConvertedType(objectPointerTypeBase->asNamedType(), context,
objectPointerScope, objAccessFunction);
}
- QTC_ASSERT(objectPointerType, return 0);
+ QTC_ASSERT(objectPointerType, return nullptr);
Type *objectTypeBase = objectPointerType->elementType().type(); // Dereference
- QTC_ASSERT(objectTypeBase, return 0);
+ QTC_ASSERT(objectTypeBase, return nullptr);
NamedType *objectType = objectTypeBase->asNamedType();
- QTC_ASSERT(objectType, return 0);
+ QTC_ASSERT(objectType, return nullptr);
ClassOrNamespace *objectClassCON = context.lookupType(objectType->name(), objectPointerScope);
if (!objectClassCON) {
objectClassCON = objectPointerExpressions.first().binding();
- QTC_ASSERT(objectClassCON, return 0);
+ QTC_ASSERT(objectClassCON, return nullptr);
}
- QTC_ASSERT(!objectClassCON->symbols().isEmpty(), return 0);
+ QTC_ASSERT(!objectClassCON->symbols().isEmpty(), return nullptr);
Symbol *objectClassSymbol = skipForwardDeclarations(objectClassCON->symbols());
- QTC_ASSERT(objectClassSymbol, return 0);
+ QTC_ASSERT(objectClassSymbol, return nullptr);
return objectClassSymbol->asClass();
}
@@ -5996,7 +5967,7 @@ bool collectConnectArguments(const ExpressionListAST *arguments,
// Take care of three-arg version, with 'this' receiver.
if (QtMethodAST *receiverMethod = arguments->value->asQtMethod()) {
- *arg3 = 0; // Means 'this'
+ *arg3 = nullptr; // Means 'this'
*arg4 = receiverMethod;
return true;
}
diff --git a/src/plugins/cppeditor/cppquickfixes.h b/src/plugins/cppeditor/cppquickfixes.h
index 21dadf0d0f..20e3c87563 100644
--- a/src/plugins/cppeditor/cppquickfixes.h
+++ b/src/plugins/cppeditor/cppquickfixes.h
@@ -65,7 +65,7 @@ class AddIncludeForUndefinedIdentifierOp: public CppQuickFixOperation
public:
AddIncludeForUndefinedIdentifierOp(const CppQuickFixInterface &interface, int priority,
const QString &include);
- void perform();
+ void perform() override;
private:
QString m_include;
@@ -383,7 +383,7 @@ public:
class ExtractFunction : public CppQuickFixFactory
{
public:
- typedef std::function<QString ()> FunctionNameGetter;
+ using FunctionNameGetter = std::function<QString()>;
ExtractFunction(FunctionNameGetter functionNameGetter = FunctionNameGetter());
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
diff --git a/src/plugins/cppeditor/cpptypehierarchy.cpp b/src/plugins/cppeditor/cpptypehierarchy.cpp
index 1b9d51851a..822ec44ff9 100644
--- a/src/plugins/cppeditor/cpptypehierarchy.cpp
+++ b/src/plugins/cppeditor/cpptypehierarchy.cpp
@@ -59,7 +59,7 @@ enum ItemRole {
QStandardItem *itemForClass(const CppClass &cppClass)
{
- QStandardItem *item = new QStandardItem;
+ auto item = new QStandardItem;
item->setFlags(item->flags() | Qt::ItemIsDragEnabled);
item->setData(cppClass.name, Qt::DisplayRole);
if (cppClass.name != cppClass.qualifiedName)
@@ -88,8 +88,7 @@ namespace CppEditor {
namespace Internal {
// CppTypeHierarchyWidget
-CppTypeHierarchyWidget::CppTypeHierarchyWidget() :
- QWidget(0)
+CppTypeHierarchyWidget::CppTypeHierarchyWidget()
{
m_inspectedClass = new TextEditor::TextEditorLinkLabel(this);
m_inspectedClass->setMargin(5);
@@ -114,7 +113,7 @@ CppTypeHierarchyWidget::CppTypeHierarchyWidget() :
m_noTypeHierarchyAvailableLabel->setBackgroundRole(QPalette::Base);
m_hierarchyWidget = new QWidget(this);
- QVBoxLayout *layout = new QVBoxLayout;
+ auto layout = new QVBoxLayout;
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(m_inspectedClass);
@@ -130,18 +129,17 @@ CppTypeHierarchyWidget::CppTypeHierarchyWidget() :
connect(CppEditorPlugin::instance(), &CppEditorPlugin::typeHierarchyRequested, this, &CppTypeHierarchyWidget::perform);
}
-CppTypeHierarchyWidget::~CppTypeHierarchyWidget()
-{}
+CppTypeHierarchyWidget::~CppTypeHierarchyWidget() = default;
void CppTypeHierarchyWidget::perform()
{
showNoTypeHierarchyLabel();
- CppEditor *editor = qobject_cast<CppEditor *>(Core::EditorManager::currentEditor());
+ auto editor = qobject_cast<CppEditor *>(Core::EditorManager::currentEditor());
if (!editor)
return;
- CppEditorWidget *widget = qobject_cast<CppEditorWidget *>(editor->widget());
+ auto widget = qobject_cast<CppEditorWidget *>(editor->widget());
if (!widget)
return;
diff --git a/src/plugins/cppeditor/cpptypehierarchy.h b/src/plugins/cppeditor/cpptypehierarchy.h
index e99d8a180e..24e7bb95ae 100644
--- a/src/plugins/cppeditor/cpptypehierarchy.h
+++ b/src/plugins/cppeditor/cpptypehierarchy.h
@@ -61,9 +61,9 @@ class CppTypeHierarchyModel : public QStandardItemModel
public:
CppTypeHierarchyModel(QObject *parent);
- Qt::DropActions supportedDragActions() const;
- QStringList mimeTypes() const;
- QMimeData *mimeData(const QModelIndexList &indexes) const;
+ Qt::DropActions supportedDragActions() const override;
+ QStringList mimeTypes() const override;
+ QMimeData *mimeData(const QModelIndexList &indexes) const override;
};
class CppTypeHierarchyWidget : public QWidget
@@ -71,7 +71,7 @@ class CppTypeHierarchyWidget : public QWidget
Q_OBJECT
public:
CppTypeHierarchyWidget();
- virtual ~CppTypeHierarchyWidget();
+ ~CppTypeHierarchyWidget() override;
void perform();
diff --git a/src/plugins/cppeditor/cppuseselectionsupdater.h b/src/plugins/cppeditor/cppuseselectionsupdater.h
index ec18b222f4..b031420e93 100644
--- a/src/plugins/cppeditor/cppuseselectionsupdater.h
+++ b/src/plugins/cppeditor/cppuseselectionsupdater.h
@@ -44,7 +44,7 @@ class CppUseSelectionsUpdater : public QObject
public:
explicit CppUseSelectionsUpdater(TextEditor::TextEditorWidget *editorWidget);
- ~CppUseSelectionsUpdater();
+ ~CppUseSelectionsUpdater() override;
void scheduleUpdate();
void abortSchedule();
diff --git a/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp b/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp
index a454361d30..72fb74f087 100644
--- a/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp
+++ b/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp
@@ -204,8 +204,7 @@ QString ResourcePreviewHoverHandler::makeTooltip() const
ret += QString("<img src=\"file:///%1\" /><br/>").arg(m_resPath);
ret += QString("<a href=\"file:///%1\">%2</a>")
- .arg(m_resPath)
- .arg(QDir::toNativeSeparators(m_resPath));
+ .arg(m_resPath, QDir::toNativeSeparators(m_resPath));
return ret;
}
diff --git a/src/plugins/cpptools/builtincursorinfo.cpp b/src/plugins/cpptools/builtincursorinfo.cpp
index ffbe196760..486db2c503 100644
--- a/src/plugins/cpptools/builtincursorinfo.cpp
+++ b/src/plugins/cpptools/builtincursorinfo.cpp
@@ -50,7 +50,7 @@ namespace {
CursorInfo::Range toRange(const SemanticInfo::Use &use)
{
- return CursorInfo::Range(use.line, use.column, use.length);
+ return {use.line, use.column, use.length};
}
CursorInfo::Range toRange(int tokenIndex, TranslationUnit *translationUnit)
@@ -60,10 +60,9 @@ CursorInfo::Range toRange(int tokenIndex, TranslationUnit *translationUnit)
if (column)
--column; // adjust the column position.
- return CursorInfo::Range(
- line,
- column +1,
- translationUnit->tokenAt(static_cast<unsigned>(tokenIndex)).utf16chars());
+ return {line,
+ column + 1,
+ translationUnit->tokenAt(static_cast<unsigned>(tokenIndex)).utf16chars()};
}
CursorInfo::Range toRange(const QTextCursor &textCursor,
@@ -74,10 +73,9 @@ CursorInfo::Range toRange(const QTextCursor &textCursor,
cursor.setPosition(static_cast<int>(utf16offset));
const QTextBlock textBlock = cursor.block();
- return CursorInfo::Range(
- static_cast<unsigned>(textBlock.blockNumber() + 1),
- static_cast<unsigned>(cursor.position() - textBlock.position() + 1),
- length);
+ return {static_cast<unsigned>(textBlock.blockNumber() + 1),
+ static_cast<unsigned>(cursor.position() - textBlock.position() + 1),
+ length};
}
CursorInfo::Ranges toRanges(const SemanticUses &uses)
@@ -216,8 +214,8 @@ private:
bool good = false;
foreach (const CppTools::SemanticInfo::Use &use, uses) {
- unsigned l = static_cast<unsigned>(m_line);
- unsigned c = static_cast<unsigned>(m_column);
+ const auto l = static_cast<unsigned>(m_line);
+ const auto c = static_cast<unsigned>(m_column);
if (l == use.line && c >= use.column && c <= (use.column + use.length)) {
good = true;
break;
diff --git a/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp b/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp
index 6d45b428be..e5ff4cd9f5 100644
--- a/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp
+++ b/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp
@@ -51,6 +51,8 @@
#include <QStringListModel>
#include <QUuid>
+#include <memory>
+
namespace CppTools {
using namespace Constants;
@@ -383,7 +385,7 @@ private:
}
}
- QVariant data(const QModelIndex &fullIndex, int role = Qt::DisplayRole) const override final
+ QVariant data(const QModelIndex &fullIndex, int role = Qt::DisplayRole) const final
{
if (!fullIndex.isValid() || role == Qt::DecorationRole)
return QVariant();
@@ -447,7 +449,7 @@ private:
QModelIndex indexForTree(const ClazyChecksTree *tree) const {
if (!tree)
- return QModelIndex();
+ return {};
QModelIndex result;
traverse(index(0, 0, QModelIndex()), [&](const QModelIndex &index){
@@ -989,11 +991,11 @@ static void setupTreeView(QTreeView *view, QAbstractItemModel *model, int expand
void ClangDiagnosticConfigsWidget::setupTabs()
{
- m_clangBaseChecks.reset(new CppTools::Ui::ClangBaseChecks);
+ m_clangBaseChecks = std::make_unique<CppTools::Ui::ClangBaseChecks>();
m_clangBaseChecksWidget = new QWidget();
m_clangBaseChecks->setupUi(m_clangBaseChecksWidget);
- m_clazyChecks.reset(new CppTools::Ui::ClazyChecks);
+ m_clazyChecks = std::make_unique<CppTools::Ui::ClazyChecks>();
m_clazyChecksWidget = new QWidget();
m_clazyChecks->setupUi(m_clazyChecksWidget);
m_clazySortFilterProxyModel = new ClazyChecksSortFilterModel(this);
@@ -1030,7 +1032,7 @@ void ClangDiagnosticConfigsWidget::setupTabs()
= codeModelSettings()->enableLowerClazyLevels() ? Qt::Checked : Qt::Unchecked;
m_clazyChecks->enableLowerLevelsCheckBox->setCheckState(checkEnableLowerClazyLevels);
- m_tidyChecks.reset(new CppTools::Ui::TidyChecks);
+ m_tidyChecks = std::make_unique<CppTools::Ui::TidyChecks>();
m_tidyChecksWidget = new QWidget();
m_tidyChecks->setupUi(m_tidyChecksWidget);
setupTreeView(m_tidyChecks->checksPrefixesTree, m_tidyTreeModel.get());
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index 03a7da9180..069359d869 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -666,7 +666,7 @@ CodeFormatter::State CodeFormatter::state(int belowTop) const
if (belowTop < m_currentState.size())
return m_currentState.at(m_currentState.size() - 1 - belowTop);
else
- return State();
+ return {};
}
int CodeFormatter::tokenIndex() const
diff --git a/src/plugins/cpptools/cppcodemodelsettings.cpp b/src/plugins/cpptools/cppcodemodelsettings.cpp
index 35b81a9b7a..2f8d0b3d42 100644
--- a/src/plugins/cpptools/cppcodemodelsettings.cpp
+++ b/src/plugins/cpptools/cppcodemodelsettings.cpp
@@ -36,7 +36,7 @@
using namespace CppTools;
static Core::Id initialClangDiagnosticConfigId()
-{ return Core::Id(Constants::CPP_CLANG_BUILTIN_CONFIG_ID_EVERYTHING_WITH_EXCEPTIONS); }
+{ return {Constants::CPP_CLANG_BUILTIN_CONFIG_ID_EVERYTHING_WITH_EXCEPTIONS}; }
static CppCodeModelSettings::PCHUsage initialPchUsage()
{ return CppCodeModelSettings::PchUse_BuildSystem; }
@@ -90,7 +90,7 @@ static QString convertToNewClazyChecksFormat(const QString &checks)
if (checks.size() == 6 && checks.startsWith("level")) {
bool ok = false;
- const int level = checks.mid(5).toInt(&ok);
+ const int level = checks.midRef(5).toInt(&ok);
QTC_ASSERT(ok, return QString());
return clazyChecksForLevel(level);
}
diff --git a/src/plugins/cpptools/cppcodestylepreferences.cpp b/src/plugins/cpptools/cppcodestylepreferences.cpp
index 6a49086d6b..ea7f100a59 100644
--- a/src/plugins/cpptools/cppcodestylepreferences.cpp
+++ b/src/plugins/cpptools/cppcodestylepreferences.cpp
@@ -76,7 +76,7 @@ CppCodeStyleSettings CppCodeStylePreferences::currentCodeStyleSettings() const
QVariant v = currentValue();
if (!v.canConvert<CppCodeStyleSettings>()) {
// warning
- return CppCodeStyleSettings();
+ return {};
}
return v.value<CppCodeStyleSettings>();
}
diff --git a/src/plugins/cpptools/cppcodestylesettings.cpp b/src/plugins/cpptools/cppcodestylesettings.cpp
index 745ea3ab62..5b07d84334 100644
--- a/src/plugins/cpptools/cppcodestylesettings.cpp
+++ b/src/plugins/cpptools/cppcodestylesettings.cpp
@@ -67,30 +67,7 @@ using namespace CppTools;
// ------------------ CppCodeStyleSettingsWidget
-CppCodeStyleSettings::CppCodeStyleSettings() :
- indentBlockBraces(false)
- , indentBlockBody(true)
- , indentClassBraces(false)
- , indentEnumBraces(false)
- , indentNamespaceBraces(false)
- , indentNamespaceBody(false)
- , indentAccessSpecifiers(false)
- , indentDeclarationsRelativeToAccessSpecifiers(true)
- , indentFunctionBody(true)
- , indentFunctionBraces(false)
- , indentSwitchLabels(false)
- , indentStatementsRelativeToSwitchLabels(true)
- , indentBlocksRelativeToSwitchLabels(false)
- , indentControlFlowRelativeToSwitchLabels(true)
- , bindStarToIdentifier(true)
- , bindStarToTypeName(false)
- , bindStarToLeftSpecifier(false)
- , bindStarToRightSpecifier(false)
- , extraPaddingForConditionsIfConfusingAlign(true)
- , alignAssignments(false)
- , preferGetterNameWithoutGetPrefix(true)
-{
-}
+CppCodeStyleSettings::CppCodeStyleSettings() = default;
void CppCodeStyleSettings::toSettings(const QString &category, QSettings *s) const
{
@@ -203,21 +180,20 @@ bool CppCodeStyleSettings::equals(const CppCodeStyleSettings &rhs) const
Utils::optional<CppCodeStyleSettings> CppCodeStyleSettings::currentProjectCodeStyle()
{
ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
- using OptSettings = Utils::optional<CppCodeStyleSettings>;
if (!project)
- return OptSettings();
+ return {};
ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();
- QTC_ASSERT(editorConfiguration, return OptSettings());
+ QTC_ASSERT(editorConfiguration, return {});
TextEditor::ICodeStylePreferences *codeStylePreferences
= editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
- QTC_ASSERT(codeStylePreferences, return OptSettings());
+ QTC_ASSERT(codeStylePreferences, return {});
auto cppCodeStylePreferences =
dynamic_cast<const CppCodeStylePreferences *>(codeStylePreferences);
if (!cppCodeStylePreferences)
- return OptSettings();
+ return {};
return cppCodeStylePreferences->currentCodeStyleSettings();
}
diff --git a/src/plugins/cpptools/cppcodestylesettings.h b/src/plugins/cpptools/cppcodestylesettings.h
index 4e39e05afc..8b477be354 100644
--- a/src/plugins/cpptools/cppcodestylesettings.h
+++ b/src/plugins/cpptools/cppcodestylesettings.h
@@ -45,26 +45,26 @@ class CPPTOOLS_EXPORT CppCodeStyleSettings
public:
CppCodeStyleSettings();
- bool indentBlockBraces;
- bool indentBlockBody;
- bool indentClassBraces;
- bool indentEnumBraces;
- bool indentNamespaceBraces;
- bool indentNamespaceBody;
- bool indentAccessSpecifiers;
- bool indentDeclarationsRelativeToAccessSpecifiers;
- bool indentFunctionBody;
- bool indentFunctionBraces;
- bool indentSwitchLabels;
- bool indentStatementsRelativeToSwitchLabels;
- bool indentBlocksRelativeToSwitchLabels;
- bool indentControlFlowRelativeToSwitchLabels;
+ bool indentBlockBraces = false;
+ bool indentBlockBody = true;
+ bool indentClassBraces = false;
+ bool indentEnumBraces = false;
+ bool indentNamespaceBraces = false;
+ bool indentNamespaceBody = false;
+ bool indentAccessSpecifiers = false;
+ bool indentDeclarationsRelativeToAccessSpecifiers = true;
+ bool indentFunctionBody = true;
+ bool indentFunctionBraces = false;
+ bool indentSwitchLabels = false;
+ bool indentStatementsRelativeToSwitchLabels = true;
+ bool indentBlocksRelativeToSwitchLabels = false;
+ bool indentControlFlowRelativeToSwitchLabels = true;
// Formatting of pointer and reference declarations, see Overview::StarBindFlag.
- bool bindStarToIdentifier;
- bool bindStarToTypeName;
- bool bindStarToLeftSpecifier;
- bool bindStarToRightSpecifier;
+ bool bindStarToIdentifier = true;
+ bool bindStarToTypeName = false;
+ bool bindStarToLeftSpecifier = false;
+ bool bindStarToRightSpecifier = false;
// false: if (a &&
// b)
@@ -75,15 +75,15 @@ public:
// but always: while (a &&
// b)
// foo;
- bool extraPaddingForConditionsIfConfusingAlign;
+ bool extraPaddingForConditionsIfConfusingAlign = true;
// false: a = a +
// b;
// true: a = a +
// b
- bool alignAssignments;
+ bool alignAssignments = false;
- bool preferGetterNameWithoutGetPrefix;
+ bool preferGetterNameWithoutGetPrefix = true;
void toSettings(const QString &category, QSettings *s) const;
void fromSettings(const QString &category, const QSettings *s);
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index ab125a86c7..12b226f756 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -1737,9 +1737,8 @@ void InternalCppCompletionAssistProcessor::addClassMembersToCompletion(Scope *sc
else
addCompletionItem(member);
}
- std::set<Class *>::const_iterator citEnd = nestedAnonymouses.end();
- for (std::set<Class *>::const_iterator cit = nestedAnonymouses.begin(); cit != citEnd; ++cit)
- addClassMembersToCompletion(*cit, staticLookup);
+ for (Class *klass : nestedAnonymouses)
+ addClassMembersToCompletion(klass, staticLookup);
}
bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupItem> &results,
diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
index f412c9ab69..7b9fff7f0e 100644
--- a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
+++ b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
@@ -490,7 +490,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators_data()
QTest::newRow("function-pointer_in-start")
<< "char *s, @*(*foo)(char *s) = 0;"
- << "char *s, *(*foo)(char * s) = 0;";
+ << "char *s, * (*foo)(char * s) = 0;";
}
void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches()
@@ -534,8 +534,8 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data()
<< "int g() { for (char * s; char * t = 0; s++) { char * u = 0; } }";
QTest::newRow("multiple-declarators")
- << "const char c, *s, *(*foo)(char *s) = 0;"
- << "const char c, * s, *(*foo)(char * s) = 0;";
+ << "const char c, *s, * (*foo)(char *s) = 0;"
+ << "const char c, * s, * (*foo)(char * s) = 0;";
QTest::newRow("complex")
<<
@@ -568,7 +568,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data()
" int (*bar)[] = 0;\n"
"\n"
" char * s = 0, * f(int i) = 0;\n"
- " const char c, * s, *(*foo)(char * s) = 0;"
+ " const char c, * s, * (*foo)(char * s) = 0;"
"\n"
" for (char * s; char * t = 0; s++) { char * u = 0; }"
"\n"
diff --git a/src/plugins/cpptools/cppprojectfilecategorizer.cpp b/src/plugins/cpptools/cppprojectfilecategorizer.cpp
index ddb841f9de..35ec2d9263 100644
--- a/src/plugins/cpptools/cppprojectfilecategorizer.cpp
+++ b/src/plugins/cpptools/cppprojectfilecategorizer.cpp
@@ -47,7 +47,7 @@ ProjectFileCategorizer::ProjectFileCategorizer(const QString &projectPartName,
QString ProjectFileCategorizer::partName(const QString &languageName) const
{
if (hasMultipleParts())
- return QString::fromLatin1("%1 (%2)").arg(m_partName).arg(languageName);
+ return QString::fromLatin1("%1 (%2)").arg(m_partName, languageName);
return m_partName;
}
diff --git a/src/plugins/cpptools/cppqtstyleindenter.cpp b/src/plugins/cpptools/cppqtstyleindenter.cpp
index fe9b17828e..8979ad62e8 100644
--- a/src/plugins/cpptools/cppqtstyleindenter.cpp
+++ b/src/plugins/cpptools/cppqtstyleindenter.cpp
@@ -179,7 +179,7 @@ CppCodeStyleSettings CppQtStyleIndenter::codeStyleSettings() const
{
if (m_cppCodeStylePreferences)
return m_cppCodeStylePreferences->currentCodeStyleSettings();
- return CppCodeStyleSettings();
+ return {};
}
TextEditor::IndentationForBlock CppQtStyleIndenter::indentationForBlocks(
diff --git a/src/plugins/cpptools/cpprefactoringchanges.cpp b/src/plugins/cpptools/cpprefactoringchanges.cpp
index 138a5a3693..f3c27073a9 100644
--- a/src/plugins/cpptools/cpprefactoringchanges.cpp
+++ b/src/plugins/cpptools/cpprefactoringchanges.cpp
@@ -198,12 +198,12 @@ Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
unsigned line, column;
cppDocument()->translationUnit()->getPosition(token.utf16charsBegin(), &line, &column);
const int start = document()->findBlockByNumber(line - 1).position() + column - 1;
- return Utils::ChangeSet::Range(start, start + token.utf16chars());
+ return {start, static_cast<int>(start + token.utf16chars())};
}
Utils::ChangeSet::Range CppRefactoringFile::range(AST *ast) const
{
- return Utils::ChangeSet::Range(startOf(ast), endOf(ast));
+ return {startOf(ast), endOf(ast)};
}
int CppRefactoringFile::startOf(unsigned index) const
diff --git a/src/plugins/cpptools/cppselectionchanger.cpp b/src/plugins/cpptools/cppselectionchanger.cpp
index e19c1711a6..98437c1ced 100644
--- a/src/plugins/cpptools/cppselectionchanger.cpp
+++ b/src/plugins/cpptools/cppselectionchanger.cpp
@@ -560,7 +560,6 @@ void CppSelectionChanger::fineTuneASTNodePositions(ASTNodePositions &positions)
qDebug() << "Is raw literal.";
// Start from positions that include quotes.
- int newPosStart = positions.astPosStart;
int newPosEnd = positions.astPosEnd;
// Decrement last position to skip last quote.
@@ -572,7 +571,7 @@ void CppSelectionChanger::fineTuneASTNodePositions(ASTNodePositions &positions)
// Start position will be the end position minus the size of the actual contents of the
// literal.
- newPosStart = newPosEnd - static_cast<int>(firstToken.string->size());
+ int newPosStart = newPosEnd - static_cast<int>(firstToken.string->size());
// Skip raw literal parentheses.
if (isRawLiteral)
@@ -591,13 +590,8 @@ void CppSelectionChanger::fineTuneASTNodePositions(ASTNodePositions &positions)
if (debug)
qDebug() << "Selecting inner contents of char literal.";
- int newPosStart = positions.astPosStart;
- int newPosEnd = positions.astPosEnd;
- newPosEnd = newPosEnd - 1;
- newPosStart = newPosEnd - static_cast<int>(firstToken.literal->size());
-
- positions.astPosStart = newPosStart;
- positions.astPosEnd = newPosEnd;
+ positions.astPosEnd = positions.astPosEnd - 1;
+ positions.astPosStart = positions.astPosEnd - int(firstToken.literal->size());
}
}
} else if (ForStatementAST *forStatementAST = ast->asForStatement()) {
diff --git a/src/plugins/cpptools/doxygengenerator.cpp b/src/plugins/cpptools/doxygengenerator.cpp
index 4ae67721cf..764930cbc9 100644
--- a/src/plugins/cpptools/doxygengenerator.cpp
+++ b/src/plugins/cpptools/doxygengenerator.cpp
@@ -42,12 +42,7 @@
using namespace CppTools;
using namespace CPlusPlus;
-DoxygenGenerator::DoxygenGenerator()
- : m_addLeadingAsterisks(true)
- , m_generateBrief(true)
- , m_startComment(true)
- , m_style(QtStyle)
-{}
+DoxygenGenerator::DoxygenGenerator() = default;
void DoxygenGenerator::setStyle(DocumentationStyle style)
{
diff --git a/src/plugins/cpptools/doxygengenerator.h b/src/plugins/cpptools/doxygengenerator.h
index 051ecfbd3e..780525b65e 100644
--- a/src/plugins/cpptools/doxygengenerator.h
+++ b/src/plugins/cpptools/doxygengenerator.h
@@ -85,10 +85,10 @@ private:
void assignCommentOffset(QTextCursor cursor);
QString offsetString() const;
- bool m_addLeadingAsterisks;
- bool m_generateBrief;
- bool m_startComment;
- DocumentationStyle m_style;
+ bool m_addLeadingAsterisks = true;
+ bool m_generateBrief = true;
+ bool m_startComment = true;
+ DocumentationStyle m_style = QtStyle;
CPlusPlus::Overview m_printer;
QString m_commentOffset;
};
diff --git a/src/plugins/cpptools/insertionpointlocator.cpp b/src/plugins/cpptools/insertionpointlocator.cpp
index b73d672306..e6db241d79 100644
--- a/src/plugins/cpptools/insertionpointlocator.cpp
+++ b/src/plugins/cpptools/insertionpointlocator.cpp
@@ -248,10 +248,7 @@ private:
} // end of anonymous namespace
-InsertionLocation::InsertionLocation()
- : m_line(0)
- , m_column(0)
-{}
+InsertionLocation::InsertionLocation() = default;
InsertionLocation::InsertionLocation(const QString &fileName,
const QString &prefix,
@@ -316,11 +313,9 @@ class HighestValue
{
Key _key;
Value _value;
- bool _set;
+ bool _set = false;
public:
- HighestValue()
- : _key(), _set(false)
- {}
+ HighestValue() = default;
HighestValue(const Key &initialKey, const Value &initialValue)
: _key(initialKey)
diff --git a/src/plugins/cpptools/insertionpointlocator.h b/src/plugins/cpptools/insertionpointlocator.h
index 480d1b592b..c05bc0f6ff 100644
--- a/src/plugins/cpptools/insertionpointlocator.h
+++ b/src/plugins/cpptools/insertionpointlocator.h
@@ -63,8 +63,8 @@ private:
QString m_fileName;
QString m_prefix;
QString m_suffix;
- unsigned m_line;
- unsigned m_column;
+ unsigned m_line = 0;
+ unsigned m_column = 0;
};
class CPPTOOLS_EXPORT InsertionPointLocator
diff --git a/src/plugins/cpptools/searchsymbols.h b/src/plugins/cpptools/searchsymbols.h
index fdda209244..37e5de08eb 100644
--- a/src/plugins/cpptools/searchsymbols.h
+++ b/src/plugins/cpptools/searchsymbols.h
@@ -41,7 +41,7 @@ namespace CppTools {
class SearchSymbols: protected CPlusPlus::SymbolVisitor
{
public:
- typedef SymbolSearcher::SymbolTypes SymbolTypes;
+ using SymbolTypes = SymbolSearcher::SymbolTypes;
static SymbolTypes AllTypes;
diff --git a/src/plugins/cpptools/symbolsfindfilter.cpp b/src/plugins/cpptools/symbolsfindfilter.cpp
index 1fd758a3fa..f6bc1f52ba 100644
--- a/src/plugins/cpptools/symbolsfindfilter.cpp
+++ b/src/plugins/cpptools/symbolsfindfilter.cpp
@@ -248,9 +248,9 @@ QString SymbolsFindFilter::toolTip(FindFlags findFlags) const
if (m_symbolsToSearch & SymbolSearcher::Declarations)
types.append(tr("Declarations"));
return tr("Scope: %1\nTypes: %2\nFlags: %3")
- .arg(searchScope() == SymbolSearcher::SearchGlobal ? tr("All") : tr("Projects"))
- .arg(types.join(tr(", ")))
- .arg(IFindFilter::descriptionForFindFlags(findFlags));
+ .arg(searchScope() == SymbolSearcher::SearchGlobal ? tr("All") : tr("Projects"),
+ types.join(", "),
+ IFindFilter::descriptionForFindFlags(findFlags));
}
// #pragma mark -- SymbolsFindFilterConfigWidget
diff --git a/src/plugins/perfprofiler/perftracepointdialog.cpp b/src/plugins/perfprofiler/perftracepointdialog.cpp
index b821924f83..f42ec8a9a7 100644
--- a/src/plugins/perfprofiler/perftracepointdialog.cpp
+++ b/src/plugins/perfprofiler/perftracepointdialog.cpp
@@ -26,6 +26,7 @@
#include "perftracepointdialog.h"
#include "ui_perftracepointdialog.h"
+#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
@@ -46,17 +47,26 @@ PerfTracePointDialog::PerfTracePointDialog() :
{
m_ui->setupUi(this);
- Project *currentProject = SessionManager::startupProject();
- QTC_ASSERT(currentProject, return);
-
- const Target *target = currentProject->activeTarget();
- QTC_ASSERT(target, return);
+ if (Project *currentProject = SessionManager::startupProject()) {
+ if (const Target *target = currentProject->activeTarget()) {
+ const Kit *kit = target->kit();
+ QTC_ASSERT(kit, return);
+
+ m_device = DeviceKitInformation::device(kit);
+ if (!m_device) {
+ m_ui->textEdit->setPlainText(tr("Error: No device available for active target."));
+ return;
+ }
+ }
+ }
- const Kit *kit = target->kit();
- QTC_ASSERT(kit, return);
+ if (!m_device) {
+ const DeviceManager *deviceManager = DeviceManager::instance();
- m_device = DeviceKitInformation::device(kit);
- QTC_ASSERT(m_device, return);
+ // There should at least be a desktop device.
+ m_device = deviceManager->defaultDevice(Constants::DESKTOP_DEVICE_TYPE);
+ QTC_ASSERT(m_device, return);
+ }
QFile file(":/perfprofiler/tracepoints.sh");
if (file.open(QIODevice::ReadOnly)) {
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index e935e7b5e8..9efcf77bf1 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -133,3 +133,5 @@ for(p, SUBDIRS) {
linux-* {
SUBDIRS += debugger/ptracepreload.pro
}
+
+QMAKE_EXTRA_TARGETS += deployqt # dummy
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp
index 5297ec7c84..7973ed4c05 100644
--- a/src/plugins/projectexplorer/buildconfiguration.cpp
+++ b/src/plugins/projectexplorer/buildconfiguration.cpp
@@ -86,7 +86,7 @@ BuildConfiguration::BuildConfiguration(Target *target, Core::Id id)
Utils::FileName BuildConfiguration::buildDirectory() const
{
- const QString path = macroExpander()->expand(QDir::cleanPath(environment().expandVariables(m_buildDirectory.toString())));
+ const QString path = QDir::cleanPath(macroExpander()->expand(environment().expandVariables(m_buildDirectory.toString())));
return Utils::FileName::fromString(QDir::cleanPath(QDir(target()->project()->projectDirectory().toString()).absoluteFilePath(path)));
}
diff --git a/src/plugins/projectexplorer/kitinformation.cpp b/src/plugins/projectexplorer/kitinformation.cpp
index c093678645..f4da43f095 100644
--- a/src/plugins/projectexplorer/kitinformation.cpp
+++ b/src/plugins/projectexplorer/kitinformation.cpp
@@ -390,8 +390,11 @@ void ToolChainKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander
IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const
{
- ToolChain *tc = toolChain(k, Constants::CXX_LANGUAGE_ID);
- return tc ? tc->outputParser() : nullptr;
+ for (const Core::Id langId : {Constants::CXX_LANGUAGE_ID, Constants::C_LANGUAGE_ID}) {
+ if (const ToolChain * const tc = toolChain(k, langId))
+ return tc->outputParser();
+ }
+ return nullptr;
}
QSet<Core::Id> ToolChainKitInformation::availableFeatures(const Kit *k) const
diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.cpp b/src/plugins/projectexplorer/projectconfigurationaspects.cpp
index 49a854d0e6..c6f9ad9552 100644
--- a/src/plugins/projectexplorer/projectconfigurationaspects.cpp
+++ b/src/plugins/projectexplorer/projectconfigurationaspects.cpp
@@ -282,7 +282,7 @@ void BaseStringAspect::update()
}
if (d->m_lineEditDisplay) {
- d->m_lineEditDisplay->setText(displayedString);
+ d->m_lineEditDisplay->setTextKeepingActiveCursor(displayedString);
d->m_lineEditDisplay->setEnabled(enabled);
}
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 82d458ffa0..47164b4882 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -110,6 +110,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
+#include <coreplugin/editormanager/documentmodel.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/vcsmanager.h>
@@ -360,6 +361,7 @@ public:
void handleRenameFile();
void handleSetStartupProject();
void setStartupProject(ProjectExplorer::Project *project);
+ bool closeAllFilesInProject(const Project *project);
void updateRecentProjectMenu();
void clearRecentProjects();
@@ -441,6 +443,8 @@ public:
QAction *m_openFileAction;
QAction *m_projectTreeCollapseAllAction;
QAction *m_projectTreeExpandAllAction;
+ Utils::ParameterAction *m_closeProjectFilesActionFileMenu;
+ Utils::ParameterAction *m_closeProjectFilesActionContextMenu;
QAction *m_searchOnFileSystem;
QAction *m_showInGraphicalShell;
QAction *m_openTerminalHere;
@@ -933,6 +937,15 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
cmd->setDescription(dd->m_unloadAction->text());
mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);
+ dd->m_closeProjectFilesActionFileMenu = new Utils::ParameterAction(
+ tr("Close All Files in Project"), tr("Close All Files in Project \"%1\""),
+ Utils::ParameterAction::AlwaysEnabled, this);
+ cmd = ActionManager::registerAction(dd->m_closeProjectFilesActionFileMenu,
+ "ProjectExplorer.CloseProjectFilesFileMenu");
+ cmd->setAttribute(Command::CA_UpdateText);
+ cmd->setDescription(dd->m_closeProjectFilesActionFileMenu->text());
+ mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);
+
ActionContainer *munload =
ActionManager::createMenu(Constants::M_UNLOADPROJECTS);
munload->menu()->setTitle(tr("Close Pro&ject"));
@@ -1140,6 +1153,15 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
cmd->setDescription(dd->m_unloadActionContextMenu->text());
mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
+ dd->m_closeProjectFilesActionContextMenu = new Utils::ParameterAction(
+ tr("Close All Files"), tr("Close All Files in Project \"%1\""),
+ Utils::ParameterAction::EnabledWithParameter, this);
+ cmd = ActionManager::registerAction(dd->m_closeProjectFilesActionContextMenu,
+ "ProjectExplorer.CloseAllFilesInProjectContextMenu");
+ cmd->setAttribute(Command::CA_UpdateText);
+ cmd->setDescription(dd->m_closeProjectFilesActionContextMenu->text());
+ mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
+
// file properties action
dd->m_filePropertiesAction = new QAction(tr("Properties..."), this);
cmd = ActionManager::registerAction(dd->m_filePropertiesAction, Constants::FILEPROPERTIES,
@@ -1442,6 +1464,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
dd, &ProjectExplorerPluginPrivate::handleRenameFile);
connect(dd->m_setStartupProjectAction, &QAction::triggered,
dd, &ProjectExplorerPluginPrivate::handleSetStartupProject);
+ connect(dd->m_closeProjectFilesActionFileMenu, &QAction::triggered,
+ dd, [] { dd->closeAllFilesInProject(SessionManager::projects().first()); });
+ connect(dd->m_closeProjectFilesActionContextMenu, &QAction::triggered,
+ dd, [] { dd->closeAllFilesInProject(ProjectTree::currentProject()); });
connect(dd->m_projectTreeCollapseAllAction, &QAction::triggered,
ProjectTree::instance(), &ProjectTree::collapseAll);
connect(dd->m_projectTreeExpandAllAction, &QAction::triggered,
@@ -1674,6 +1700,9 @@ void ProjectExplorerPlugin::unloadProject(Project *project)
if (!DocumentManager::saveModifiedDocumentSilently(document))
return;
+ if (!dd->closeAllFilesInProject(project))
+ return;
+
dd->addToRecentProjects(document->filePath().toString(), project->displayName());
SessionManager::removeProject(project);
@@ -1824,6 +1853,26 @@ void ProjectExplorerPluginPrivate::setStartupProject(Project *project)
updateActions();
}
+bool ProjectExplorerPluginPrivate::closeAllFilesInProject(const Project *project)
+{
+ QTC_ASSERT(project, return false);
+ const Utils::FileNameList filesInProject = project->files(Project::AllFiles);
+ QList<IDocument *> openFiles = DocumentModel::openedDocuments();
+ Utils::erase(openFiles, [filesInProject](const IDocument *doc) {
+ return !filesInProject.contains(doc->filePath());
+ });
+ for (const Project * const otherProject : SessionManager::projects()) {
+ if (otherProject == project)
+ continue;
+ const Utils::FileNameList filesInOtherProject
+ = otherProject->files(Project::AllFiles);
+ Utils::erase(openFiles, [filesInOtherProject](const IDocument *doc) {
+ return filesInOtherProject.contains(doc->filePath());
+ });
+ }
+ return EditorManager::closeDocuments(openFiles);
+}
+
void ProjectExplorerPluginPrivate::savePersistentSettings()
{
if (dd->m_shuttingDown)
@@ -2332,6 +2381,8 @@ void ProjectExplorerPluginPrivate::updateActions()
m_unloadAction->setParameter(projectName);
m_unloadActionContextMenu->setParameter(projectNameContextMenu);
+ m_closeProjectFilesActionFileMenu->setParameter(projectName);
+ m_closeProjectFilesActionContextMenu->setParameter(projectNameContextMenu);
// mode bar build action
QAction * const buildAction = ActionManager::command(Constants::BUILD)->action();
@@ -2390,6 +2441,9 @@ void ProjectExplorerPluginPrivate::updateActions()
m_unloadAction->setVisible(SessionManager::projects().size() <= 1);
m_unloadAction->setEnabled(SessionManager::projects().size() == 1);
m_unloadActionContextMenu->setEnabled(SessionManager::hasProjects());
+ m_closeProjectFilesActionFileMenu->setVisible(SessionManager::projects().size() <= 1);
+ m_closeProjectFilesActionFileMenu->setEnabled(SessionManager::projects().size() == 1);
+ m_closeProjectFilesActionContextMenu->setEnabled(SessionManager::hasProjects());
ActionContainer *aci =
ActionManager::actionContainer(Constants::M_UNLOADPROJECTS);
diff --git a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp
index 1d464039f5..21e24cffa8 100644
--- a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp
+++ b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp
@@ -179,12 +179,6 @@ Internal::QbsProject *QbsBuildConfiguration::project() const
return qobject_cast<Internal::QbsProject *>(BuildConfiguration::project());
}
-IOutputParser *QbsBuildConfiguration::createOutputParser() const
-{
- ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
- return tc ? tc->outputParser() : nullptr;
-}
-
bool QbsBuildConfiguration::isEnabled() const
{
return !project()->isParsing() && project()->hasParseResult();
diff --git a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.h b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.h
index 19c29ac33f..1db6059252 100644
--- a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.h
+++ b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.h
@@ -57,8 +57,6 @@ public:
Internal::QbsProject *project() const override;
- ProjectExplorer::IOutputParser *createOutputParser() const;
-
bool isEnabled() const override;
QString disabledReason() const override;
diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.cpp
index 1bb9fff0fd..ebe3644e4e 100644
--- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.cpp
+++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.cpp
@@ -152,12 +152,6 @@ static int devicePixelHeight(const QPixmap &pixmap)
return pixmap.height() / pixmap.devicePixelRatioF();
}
-static QString iconPath()
-{
- return Core::ICore::resourcePath()
- + QLatin1String("/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/images/");
-}
-
void TimelineFrameHandle::paint(QPainter *painter,
const QStyleOptionGraphicsItem * /*option*/,
QWidget * /*widget*/)
diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.cpp
index ab92bb2dc6..49d35b781b 100644
--- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.cpp
+++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.cpp
@@ -120,7 +120,7 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item,
Q_UNUSED(event);
if (auto *current = currentItem()) {
- if (auto *playhead = current->asTimelineFrameHandle()) {
+ if (current->asTimelineFrameHandle()) {
double mousePos = event->pos().x();
double start = current->mapFromFrameToScene(scene()->startFrame());
double end = current->mapFromFrameToScene(scene()->endFrame());
@@ -142,7 +142,7 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item,
current->commitPosition(mapToItem(current, current->rect().center()));
- if (TimelineKeyframeItem *currentKeyframe = current->asTimelineKeyframeItem()) {
+ if (current->asTimelineKeyframeItem()) {
double frame = std::round(
current->mapFromSceneToFrame(current->rect().center().x()));
diff --git a/src/plugins/qtsupport/qtoutputformatter.cpp b/src/plugins/qtsupport/qtoutputformatter.cpp
index 8fba279776..c5a4d7a427 100644
--- a/src/plugins/qtsupport/qtoutputformatter.cpp
+++ b/src/plugins/qtsupport/qtoutputformatter.cpp
@@ -53,7 +53,7 @@ public:
: qmlError("(" QT_QML_URL_REGEXP // url
":\\d+" // colon, line
"(?::\\d+)?)" // colon, column (optional)
- "[: \t)]") // colon, space, tab or brace
+ "\\b") // word boundary
, qtError("Object::.*in (.*:\\d+)")
, qtAssert(QT_ASSERT_REGEXP)
, qtAssertX(QT_ASSERT_X_REGEXP)
@@ -364,6 +364,26 @@ void QtSupportPlugin::testQtOutputFormatter_data()
<< 0 << 19 << "file:///main.qml:20"
<< "/main.qml" << 20 << -1;
+ QTest::newRow("File link without further text")
+ << "file:///home/user/main.cpp:157"
+ << 0 << 30 << "file:///home/user/main.cpp:157"
+ << "/home/user/main.cpp" << 157 << -1;
+
+ QTest::newRow("File link with text before")
+ << "Text before: file:///home/user/main.cpp:157"
+ << 13 << 43 << "file:///home/user/main.cpp:157"
+ << "/home/user/main.cpp" << 157 << -1;
+
+ QTest::newRow("File link with text afterwards")
+ << "file:///home/user/main.cpp:157: Text afterwards"
+ << 0 << 30 << "file:///home/user/main.cpp:157"
+ << "/home/user/main.cpp" << 157 << -1;
+
+ QTest::newRow("File link with text before and afterwards")
+ << "Text before file:///home/user/main.cpp:157 and text afterwards"
+ << 12 << 42 << "file:///home/user/main.cpp:157"
+ << "/home/user/main.cpp" << 157 << -1;
+
QTest::newRow("Unix file link with timestamp")
<< "file:///home/user/main.cpp:157 2018-03-21 10:54:45.706"
<< 0 << 30 << "file:///home/user/main.cpp:157"
diff --git a/src/plugins/texteditor/codeassist/documentcontentcompletion.cpp b/src/plugins/texteditor/codeassist/documentcontentcompletion.cpp
index 437afcbdb6..ee0deab71c 100644
--- a/src/plugins/texteditor/codeassist/documentcontentcompletion.cpp
+++ b/src/plugins/texteditor/codeassist/documentcontentcompletion.cpp
@@ -80,17 +80,26 @@ DocumentContentCompletionProcessor::~DocumentContentCompletionProcessor()
m_watcher.cancel();
}
-static void createProposal(QFutureInterface<QStringList> &future, const QString text)
+static void createProposal(QFutureInterface<QStringList> &future, const QString &text,
+ const QString &wordUnderCursor)
{
const QRegularExpression wordRE("([a-zA-Z_][a-zA-Z0-9_]{2,})");
QSet<QString> words;
QRegularExpressionMatchIterator it = wordRE.globalMatch(text);
+ int wordUnderCursorFound = 0;
while (it.hasNext()) {
if (future.isCanceled())
return;
QRegularExpressionMatch match = it.next();
const QString &word = match.captured();
+ if (word == wordUnderCursor) {
+ // Only add the word under cursor if it
+ // already appears elsewhere in the text
+ if (++wordUnderCursorFound < 2)
+ continue;
+ }
+
if (!words.contains(word))
words.insert(word);
}
@@ -113,16 +122,18 @@ IAssistProposal *DocumentContentCompletionProcessor::perform(const AssistInterfa
} while (chr.isLetterOrNumber() || chr == '_');
++pos;
+ int length = interface->position() - pos;
if (interface->reason() == IdleEditor) {
QChar characterUnderCursor = interface->characterAt(interface->position());
- if (characterUnderCursor.isLetterOrNumber() || interface->position() - pos < 3)
+ if (characterUnderCursor.isLetterOrNumber() || length < 3)
return nullptr;
}
+ const QString wordUnderCursor = interface->textAt(pos, length);
const QString text = interface->textDocument()->toPlainText();
- m_watcher.setFuture(Utils::runAsync(&createProposal, text));
+ m_watcher.setFuture(Utils::runAsync(&createProposal, text, wordUnderCursor));
QObject::connect(&m_watcher, &QFutureWatcher<QStringList>::resultReadyAt,
&m_watcher, [this, pos](int index){
const TextEditor::SnippetAssistCollector snippetCollector(
diff --git a/src/plugins/texteditor/highlighter.cpp b/src/plugins/texteditor/highlighter.cpp
index 170ec12bc8..c88a5aacb5 100644
--- a/src/plugins/texteditor/highlighter.cpp
+++ b/src/plugins/texteditor/highlighter.cpp
@@ -32,6 +32,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
+#include <utils/mimetypes/mimedatabase.h>
#include <Format>
#include <Repository>
@@ -99,16 +100,48 @@ Highlighter::Highlighter()
&categoryForTextStyle);
}
-KSyntaxHighlighting::Definition Highlighter::definitionForMimeType(const QString &mimeType)
+Highlighter::Definition Highlighter::definitionForDocument(const TextDocument *document)
+{
+ const Utils::MimeType mimeType = Utils::mimeTypeForName(document->mimeType());
+ Definition definition;
+ if (mimeType.isValid())
+ definition = Highlighter::definitionForMimeType(mimeType.name());
+ if (!definition.isValid())
+ definition = Highlighter::definitionForFileName(document->filePath().fileName());
+ return definition;
+}
+
+Highlighter::Definition Highlighter::definitionForMimeType(const QString &mimeType)
{
return highlightRepository()->definitionForMimeType(mimeType);
}
-KSyntaxHighlighting::Definition Highlighter::definitionForFileName(const QString &fileName)
+Highlighter::Definition Highlighter::definitionForFileName(const QString &fileName)
{
return highlightRepository()->definitionForFileName(fileName);
}
+Highlighter::Definitions Highlighter::definitionsForDocument(const TextDocument *document)
+{
+ const Utils::MimeType mimeType = Utils::mimeTypeForName(document->mimeType());
+ Definitions definitions;
+ if (mimeType.isValid())
+ definitions = Highlighter::definitionsForMimeType(mimeType.name());
+ if (definitions.isEmpty())
+ definitions = Highlighter::definitionsForFileName(document->filePath().fileName());
+ return definitions;
+}
+
+Highlighter::Definitions Highlighter::definitionsForMimeType(const QString &mimeType)
+{
+ return highlightRepository()->definitionsForMimeType(mimeType).toList();
+}
+
+Highlighter::Definitions Highlighter::definitionsForFileName(const QString &fileName)
+{
+ return highlightRepository()->definitionsForFileName(fileName).toList();
+}
+
void Highlighter::addCustomHighlighterPath(const Utils::FileName &path)
{
highlightRepository()->addCustomSearchPath(path.toString());
diff --git a/src/plugins/texteditor/highlighter.h b/src/plugins/texteditor/highlighter.h
index 90ab31332a..cec2b0fb69 100644
--- a/src/plugins/texteditor/highlighter.h
+++ b/src/plugins/texteditor/highlighter.h
@@ -34,14 +34,22 @@
namespace TextEditor {
class FontSettings;
+class TextDocument;
class Highlighter : public SyntaxHighlighter, public KSyntaxHighlighting::AbstractHighlighter
{
public:
+ using Definition = KSyntaxHighlighting::Definition;
+ using Definitions = QList<Definition>;
Highlighter();
- static KSyntaxHighlighting::Definition definitionForMimeType(const QString &mimeType);
- static KSyntaxHighlighting::Definition definitionForFileName(const QString &fileName);
+ static Definition definitionForDocument(const TextDocument *document);
+ static Definition definitionForMimeType(const QString &mimeType);
+ static Definition definitionForFileName(const QString &fileName);
+
+ static Definitions definitionsForDocument(const TextDocument *document);
+ static Definitions definitionsForMimeType(const QString &mimeType);
+ static Definitions definitionsForFileName(const QString &fileName);
static void addCustomHighlighterPath(const Utils::FileName &path);
static void updateDefinitions(std::function<void()> callback = nullptr);
diff --git a/src/plugins/texteditor/indenter.h b/src/plugins/texteditor/indenter.h
index 2907ea783c..8a663be903 100644
--- a/src/plugins/texteditor/indenter.h
+++ b/src/plugins/texteditor/indenter.h
@@ -91,11 +91,10 @@ public:
}
// By default just calls indent with default settings.
- virtual Replacements format(const QTextCursor &cursor,
- const TabSettings &tabSettings,
- int cursorPositionInEditor = -1)
+ virtual Replacements format(const QTextCursor &/*cursor*/,
+ const TabSettings &/*tabSettings*/,
+ int /*cursorPositionInEditor*/ = -1)
{
- indent(cursor, QChar::Null, tabSettings, cursorPositionInEditor);
return Replacements();
}
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index d8e994b749..247fd12352 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -611,6 +611,8 @@ public:
void updateCodeFoldingVisible();
void reconfigure();
+ void updateSyntaxInfoBar(bool showInfo);
+ void configureGenericHighlighter(const KSyntaxHighlighting::Definition &definition);
public:
TextEditorWidget *q;
@@ -768,8 +770,6 @@ public:
QScopedPointer<ClipboardAssistProvider> m_clipboardAssistProvider;
- bool m_isMissingSyntaxDefinition = false;
-
QScopedPointer<AutoCompleter> m_autoCompleter;
CommentDefinition m_commentDefinition;
@@ -904,33 +904,6 @@ void TextEditorWidgetPrivate::showTextMarksToolTip(const QPoint &pos,
} // namespace Internal
-/*!
- * Test if syntax highlighter is available (or unneeded) for \a widget.
- * If not found, show a warning with a link to the relevant settings page.
- */
-static void updateEditorInfoBar(TextEditorWidget *widget)
-{
- Id id(Constants::INFO_SYNTAX_DEFINITION);
- InfoBar *infoBar = widget->textDocument()->infoBar();
- if (!widget->isMissingSyntaxDefinition()) {
- infoBar->removeInfo(id);
- } else if (infoBar->canInfoBeAdded(id)) {
- InfoBarEntry info(id,
- BaseTextEditor::tr("A highlight definition was not found for this file. "
- "Would you like to update highlight definition files?"),
- InfoBarEntry::GlobalSuppressionEnabled);
- info.setCustomButtonInfo(BaseTextEditor::tr("Update Definitions"), [id, widget]() {
- widget->textDocument()->infoBar()->removeInfo(id);
- Highlighter::updateDefinitions([widget = QPointer<TextEditorWidget>(widget)]() {
- if (widget)
- widget->configureGenericHighlighter();
- });
- });
-
- infoBar->addInfo(info);
- }
-}
-
QString TextEditorWidget::plainTextFromSelection(const QTextCursor &cursor) const
{
// Copy the selected text as plain text
@@ -3301,6 +3274,49 @@ void TextEditorWidgetPrivate::reconfigure()
q->configureGenericHighlighter();
}
+void TextEditorWidgetPrivate::updateSyntaxInfoBar(bool showInfo)
+{
+ Id id(Constants::INFO_SYNTAX_DEFINITION);
+ InfoBar *infoBar = m_document->infoBar();
+
+ if (showInfo) {
+ InfoBarEntry info(id,
+ BaseTextEditor::tr(
+ "A highlight definition was not found for this file. "
+ "Would you like to update highlight definition files?"),
+ InfoBarEntry::GlobalSuppressionEnabled);
+ info.setCustomButtonInfo(BaseTextEditor::tr("Update Definitions"), [&]() {
+ m_document->infoBar()->removeInfo(id);
+ Highlighter::updateDefinitions([widget = QPointer<TextEditorWidget>(q)]() {
+ if (widget)
+ widget->configureGenericHighlighter();
+ });
+ });
+ infoBar->addInfo(info);
+ } else {
+ infoBar->removeInfo(id);
+ }
+}
+
+void TextEditorWidgetPrivate::configureGenericHighlighter(
+ const KSyntaxHighlighting::Definition &definition)
+{
+ auto highlighter = new Highlighter();
+ m_document->setSyntaxHighlighter(highlighter);
+
+ if (definition.isValid()) {
+ highlighter->setDefinition(definition);
+ m_commentDefinition.singleLine = definition.singleLineCommentMarker();
+ m_commentDefinition.multiLineStart = definition.multiLineCommentMarker().first;
+ m_commentDefinition.multiLineEnd = definition.multiLineCommentMarker().second;
+ q->setCodeFoldingSupported(true);
+ } else {
+ q->setCodeFoldingSupported(false);
+ }
+
+ m_document->setFontSettings(TextEditorSettings::fontSettings());
+}
+
bool TextEditorWidget::codeFoldingVisible() const
{
return d->m_codeFoldingVisible;
@@ -8498,36 +8514,11 @@ QString TextEditorWidget::textAt(int from, int to) const
void TextEditorWidget::configureGenericHighlighter()
{
- auto highlighter = new Highlighter();
- textDocument()->setSyntaxHighlighter(highlighter);
-
- setCodeFoldingSupported(false);
-
- const QString type = textDocument()->mimeType();
- const MimeType mimeType = Utils::mimeTypeForName(type);
- const QString fileName = textDocument()->filePath().fileName();
- KSyntaxHighlighting::Definition definition;
- if (mimeType.isValid())
- definition = Highlighter::definitionForMimeType(mimeType.name());
- if (!definition.isValid())
- definition = Highlighter::definitionForFileName(fileName);
-
- if (definition.isValid()) {
- highlighter->setDefinition(definition);
- d->m_isMissingSyntaxDefinition = false;
- d->m_commentDefinition.singleLine = definition.singleLineCommentMarker();
- d->m_commentDefinition.multiLineStart = definition.multiLineCommentMarker().first;
- d->m_commentDefinition.multiLineEnd = definition.multiLineCommentMarker().second;
-
- setCodeFoldingSupported(true);
- } else {
- d->m_isMissingSyntaxDefinition =
- !TextEditorSettings::highlighterSettings().isIgnoredFilePattern(fileName);
- }
-
- textDocument()->setFontSettings(TextEditorSettings::fontSettings());
-
- updateEditorInfoBar(this);
+ const Highlighter::Definition definition = Highlighter::definitionForDocument(textDocument());
+ d->configureGenericHighlighter(definition);
+ d->updateSyntaxInfoBar(!definition.isValid()
+ && !TextEditorSettings::highlighterSettings().isIgnoredFilePattern(
+ textDocument()->filePath().fileName()));
}
int TextEditorWidget::blockNumberForVisibleRow(int row) const
@@ -8562,11 +8553,6 @@ HighlightScrollBarController *TextEditorWidget::highlightScrollBarController() c
return d->m_highlightScrollBarController;
}
-bool TextEditorWidget::isMissingSyntaxDefinition() const
-{
- return d->m_isMissingSyntaxDefinition;
-}
-
// The remnants of PlainTextEditor.
void TextEditorWidget::setupGenericHighlighter()
{
@@ -8574,8 +8560,6 @@ void TextEditorWidget::setupGenericHighlighter()
connect(textDocument(), &IDocument::filePathChanged,
d, &TextEditorWidgetPrivate::reconfigure);
-
- updateEditorInfoBar(this);
}
//
diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h
index 5cf1ecbd1a..d792a1b12c 100644
--- a/src/plugins/texteditor/texteditor.h
+++ b/src/plugins/texteditor/texteditor.h
@@ -332,7 +332,6 @@ public:
// the blocks list must be sorted
void setIfdefedOutBlocks(const QList<BlockRange> &blocks);
- bool isMissingSyntaxDefinition() const;
enum Side { Left, Right };
QAction *insertExtraToolBarWidget(Side side, QWidget *widget);
diff --git a/src/shared/shared.pro b/src/shared/shared.pro
new file mode 100644
index 0000000000..e75970c0fb
--- /dev/null
+++ b/src/shared/shared.pro
@@ -0,0 +1,28 @@
+TEMPLATE = subdirs
+
+QBS_DIRS = \
+ qbscorelib \
+ qbsqtprofilesetup \
+ qbsapps \
+ qbslibexec \
+ qbsplugins \
+ qbsstatic
+
+qbscorelib.subdir = qbs/src/lib/corelib
+qbsqtprofilesetup.subdir = qbs/src/lib/qtprofilesetup
+qbsqtprofilesetup.depends = qbscorelib
+qbsapps.subdir = qbs/src/app
+qbsapps.depends = qbsqtprofilesetup
+qbslibexec.subdir = qbs/src/libexec
+qbslibexec.depends = qbscorelib
+qbsplugins.subdir = qbs/src/plugins
+qbsplugins.depends = qbscorelib
+qbsstatic.file = qbs/static.pro
+
+exists(qbs/qbs.pro) {
+ isEmpty(QBS_INSTALL_DIR):QBS_INSTALL_DIR = $$(QBS_INSTALL_DIR)
+ isEmpty(QBS_INSTALL_DIR):SUBDIRS += $$QBS_DIRS
+}
+TR_EXCLUDE = qbs
+
+QMAKE_EXTRA_TARGETS += deployqt # dummy
diff --git a/src/src.pro b/src/src.pro
index 496c500dbd..4380ec271d 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,36 +1,16 @@
-include(../qtcreator.pri)
-
TEMPLATE = subdirs
CONFIG += ordered
-QBS_DIRS = \
- qbscorelib \
- qbsqtprofilesetup \
- qbsapps \
- qbslibexec \
- qbsplugins \
- qbsstatic
-
-qbscorelib.subdir = shared/qbs/src/lib/corelib
-qbsqtprofilesetup.subdir = shared/qbs/src/lib/qtprofilesetup
-qbsqtprofilesetup.depends = qbscorelib
-qbsapps.subdir = shared/qbs/src/app
-qbsapps.depends = qbsqtprofilesetup
-qbslibexec.subdir = shared/qbs/src/libexec
-qbslibexec.depends = qbscorelib
-qbsplugins.subdir = shared/qbs/src/plugins
-qbsstatic.file = shared/qbs/static.pro
-
-exists(shared/qbs/qbs.pro) {
- isEmpty(QBS_INSTALL_DIR):QBS_INSTALL_DIR = $$(QBS_INSTALL_DIR)
- isEmpty(QBS_INSTALL_DIR):SUBDIRS += $$QBS_DIRS
-}
-TR_EXCLUDE = shared/qbs
-
SUBDIRS += \
+ shared \
libs \
app \
plugins \
tools \
share/qtcreator/data.pro \
share/3rdparty/data.pro
+
+# delegate deployqt target
+deployqt.CONFIG += recursive
+deployqt.recurse = shared libs app plugins tools
+QMAKE_EXTRA_TARGETS += deployqt
diff --git a/src/tools/clangpchmanagerbackend/source/pchcreator.cpp b/src/tools/clangpchmanagerbackend/source/pchcreator.cpp
index 935e446f53..4333d5706a 100644
--- a/src/tools/clangpchmanagerbackend/source/pchcreator.cpp
+++ b/src/tools/clangpchmanagerbackend/source/pchcreator.cpp
@@ -82,15 +82,6 @@ bool PchCreator::generatePch()
return tool.run(action.get()) != 1;
}
-FilePath PchCreator::generatePchHeaderFilePath() const
-{
- std::uniform_int_distribution<std::mt19937_64::result_type> distribution;
-
- return FilePathView{Utils::PathString{Utils::SmallString(m_environment.pchBuildDirectory()),
- "/",
- std::to_string(distribution(randomNumberGenator)),
- ".h"}};
-}
FilePath PchCreator::generatePchFilePath() const
{
@@ -103,10 +94,9 @@ FilePath PchCreator::generatePchFilePath() const
".pch"}};
}
-std::vector<std::string> PchCreator::generateClangCompilerArguments(
- const PchTask &pchTask,
- FilePathView sourceFilePath,
- FilePathView pchOutputPath)
+Utils::SmallStringVector PchCreator::generateClangCompilerArguments(const PchTask &pchTask,
+ FilePathView sourceFilePath,
+ FilePathView pchOutputPath)
{
CommandLineBuilder<PchTask> builder{pchTask,
pchTask.toolChainArguments,
@@ -121,15 +111,14 @@ void PchCreator::generatePch(PchTask &&pchTask)
{
long long lastModified = QDateTime::currentSecsSinceEpoch();
auto content = generatePchIncludeFileContent(pchTask.includes);
- auto pchSourceFilePath = generatePchHeaderFilePath();
auto pchOutputPath = generatePchFilePath();
- generateFileWithContent(pchSourceFilePath, content);
- m_clangTool.addFile(
- pchSourceFilePath.directory(),
- pchSourceFilePath.name(),
- "",
- generateClangCompilerArguments(pchTask, pchSourceFilePath, pchOutputPath));
+ FilePath headerFilePath{m_environment.pchBuildDirectory().toStdString(), "dummy.h"};
+ Utils::SmallStringVector commandLine = generateClangCompilerArguments(pchTask,
+ headerFilePath,
+ pchOutputPath);
+
+ m_clangTool.addFile(std::move(headerFilePath), std::move(content), std::move(commandLine));
bool success = generatePch();
@@ -179,17 +168,4 @@ const FilePathCaching &PchCreator::filePathCache()
return m_filePathCache;
}
-std::unique_ptr<QFile> PchCreator::generateFileWithContent(const Utils::SmallString &filePath,
- const Utils::SmallString &content)
-{
- std::unique_ptr<QFile> precompiledIncludeFile(new QFile(QString(filePath)));
-
- precompiledIncludeFile->open(QIODevice::WriteOnly);
-
- precompiledIncludeFile->write(content.data(), qint64(content.size()));
- precompiledIncludeFile->close();
-
- return precompiledIncludeFile;
-}
-
} // namespace ClangBackEnd
diff --git a/src/tools/clangpchmanagerbackend/source/pchcreator.h b/src/tools/clangpchmanagerbackend/source/pchcreator.h
index 0d55adbcdd..37d0c7c8a1 100644
--- a/src/tools/clangpchmanagerbackend/source/pchcreator.h
+++ b/src/tools/clangpchmanagerbackend/source/pchcreator.h
@@ -83,13 +83,10 @@ public:
Utils::SmallString generatePchIncludeFileContent(const FilePathIds &includeIds) const;
bool generatePch();
- FilePath generatePchHeaderFilePath() const;
FilePath generatePchFilePath() const;
- static std::vector<std::string> generateClangCompilerArguments(const PchTask &pchTask,
+ static Utils::SmallStringVector generateClangCompilerArguments(const PchTask &pchTask,
FilePathView includePchHeaderPath,
FilePathView pchPath);
- static std::unique_ptr<QFile> generateFileWithContent(const Utils::SmallString &filePath,
- const Utils::SmallString &content);
const ClangTool &clangTool() const
{
diff --git a/src/tools/clangrefactoringbackend/source/clangquerygatherer.cpp b/src/tools/clangrefactoringbackend/source/clangquerygatherer.cpp
index 21cd0d26e5..42fb7d88bc 100644
--- a/src/tools/clangrefactoringbackend/source/clangquerygatherer.cpp
+++ b/src/tools/clangrefactoringbackend/source/clangquerygatherer.cpp
@@ -50,10 +50,9 @@ ClangQueryGatherer::createSourceRangesForSource(
{
ClangQuery clangQuery(*filePathCache, std::move(query));
- clangQuery.addFile(std::string(source.filePath.directory()),
- std::string(source.filePath.name()),
- std::string(source.unsavedFileContent),
- std::vector<std::string>(source.commandLineArguments));
+ clangQuery.addFile(std::move(source.filePath),
+ std::move(source.unsavedFileContent),
+ std::move(source.commandLineArguments));
clangQuery.addUnsavedFiles(unsaved);
diff --git a/src/tools/clangrefactoringbackend/source/clangtool.cpp b/src/tools/clangrefactoringbackend/source/clangtool.cpp
index 66f85c6d36..5ae87793db 100644
--- a/src/tools/clangrefactoringbackend/source/clangtool.cpp
+++ b/src/tools/clangrefactoringbackend/source/clangtool.cpp
@@ -27,6 +27,8 @@
#include <iostream>
+#include <nativefilepath.h>
+
namespace ClangBackEnd {
namespace {
@@ -44,67 +46,37 @@ String toNativePath(String &&path)
}
}
-void ClangTool::addFile(std::string &&directory,
- std::string &&fileName,
- std::string &&content,
- std::vector<std::string> &&commandLine)
+void ClangTool::addFile(FilePath &&filePath,
+ Utils::SmallString &&content,
+ Utils::SmallStringVector &&commandLine)
{
- m_fileContents.emplace_back(toNativePath(std::move(directory)),
- std::move(fileName),
- std::move(content),
- std::move(commandLine));
+ NativeFilePath nativeFilePath{filePath};
- const auto &fileContent = m_fileContents.back();
+ m_compilationDatabase.addFile(nativeFilePath, std::move(commandLine));
+ m_sourceFilePaths.push_back(Utils::SmallStringView{nativeFilePath});
- m_compilationDatabase.addFile(fileContent.directory, fileContent.fileName, fileContent.commandLine);
- m_sourceFilePaths.push_back(fileContent.filePath);
+ m_fileContents.emplace_back(std::move(nativeFilePath), std::move(content));
}
void ClangTool::addFiles(const FilePaths &filePaths, const Utils::SmallStringVector &arguments)
{
for (const FilePath &filePath : filePaths) {
- std::vector<std::string> commandLine(arguments.begin(), arguments.end());
- commandLine.push_back(std::string(filePath.name()));
-
- addFile(filePath.directory(),
- filePath.name(),
- {},
- std::move(commandLine));
- }
-}
-
-template <typename Container>
-void ClangTool::addFiles(const Container &filePaths,
- const Utils::SmallStringVector &arguments)
-{
- for (const typename Container::value_type &filePath : filePaths) {
- auto found = std::find(filePath.rbegin(), filePath.rend(), '/');
-
- auto fileNameBegin = found.base();
+ std::string filePathStr(filePath.path());
+ auto commandLine = arguments;
+ NativeFilePath nativeFilePath{filePath};
- std::vector<std::string> commandLine(arguments.begin(), arguments.end());
- commandLine.push_back(std::string(filePath));
+ commandLine.push_back(nativeFilePath.path());
- addFile({filePath.begin(), std::prev(fileNameBegin)},
- {fileNameBegin, filePath.end()},
- {},
- std::move(commandLine));
+ addFile(filePath.clone(), {}, std::move(commandLine));
}
}
-template
-void ClangTool::addFiles<Utils::SmallStringVector>(const Utils::SmallStringVector &filePaths,
- const Utils::SmallStringVector &arguments);
-template
-void ClangTool::addFiles<Utils::PathStringVector>(const Utils::PathStringVector &filePaths,
- const Utils::SmallStringVector &arguments);
-
void ClangTool::addUnsavedFiles(const V2::FileContainers &unsavedFiles)
{
m_unsavedFileContents.reserve(m_unsavedFileContents.size() + unsavedFiles.size());
- auto convertToUnsavedFileContent = [] (const V2::FileContainer &unsavedFile) {
- return UnsavedFileContent{toNativePath(unsavedFile.filePath.path().clone()),
+ auto convertToUnsavedFileContent = [](const V2::FileContainer &unsavedFile) {
+ return UnsavedFileContent{NativeFilePath{unsavedFile.filePath},
unsavedFile.unsavedFileContent.clone()};
};
@@ -120,7 +92,12 @@ llvm::StringRef toStringRef(const String &string)
{
return llvm::StringRef(string.data(), string.size());
}
+
+llvm::StringRef toStringRef(const NativeFilePath &path)
+{
+ return llvm::StringRef(path.path().data(), path.path().size());
}
+} // namespace
clang::tooling::ClangTool ClangTool::createTool() const
{
@@ -128,7 +105,7 @@ clang::tooling::ClangTool ClangTool::createTool() const
for (const auto &fileContent : m_fileContents) {
if (!fileContent.content.empty())
- tool.mapVirtualFile(fileContent.filePath, fileContent.content);
+ tool.mapVirtualFile(toStringRef(fileContent.filePath), fileContent.content);
}
for (const auto &unsavedFileContent : m_unsavedFileContents)
diff --git a/src/tools/clangrefactoringbackend/source/clangtool.h b/src/tools/clangrefactoringbackend/source/clangtool.h
index 8b4e47df68..e3ff835799 100644
--- a/src/tools/clangrefactoringbackend/source/clangtool.h
+++ b/src/tools/clangrefactoringbackend/source/clangtool.h
@@ -30,6 +30,7 @@
#include <clangrefactoringbackend_global.h>
#include <filecontainerv2.h>
+#include <nativefilepath.h>
#include <sourcelocationscontainer.h>
#include <clang/Tooling/Refactoring.h>
@@ -43,50 +44,34 @@ namespace ClangBackEnd {
struct FileContent
{
- FileContent(const std::string &directory,
- const std::string &fileName,
- const std::string &content,
- const std::vector<std::string> &commandLine)
- : directory(directory),
- fileName(fileName),
- filePath(directory + nativeSeparator + fileName),
- content(content),
- commandLine(commandLine)
+ FileContent(NativeFilePath &&filePath, const Utils::SmallString &content)
+ : filePath(std::move(filePath))
+ , content(std::move(content))
{}
- std::string directory;
- std::string fileName;
- std::string filePath;
+ NativeFilePath filePath;
std::string content;
- std::vector<std::string> commandLine;
};
struct UnsavedFileContent
{
- UnsavedFileContent(Utils::PathString &&filePath,
- Utils::SmallString &&content)
- : filePath(std::move(filePath)),
- content(std::move(content))
+ UnsavedFileContent(NativeFilePath &&filePath, Utils::SmallString &&content)
+ : filePath(std::move(filePath))
+ , content(std::move(content))
{}
- Utils::PathString filePath;
+ NativeFilePath filePath;
Utils::SmallString content;
};
class ClangTool
{
public:
- void addFile(std::string &&directory,
- std::string &&fileName,
- std::string &&content,
- std::vector<std::string> &&commandLine);
-
- template <typename Container>
- void addFiles(const Container &filePaths,
- const Utils::SmallStringVector &arguments);
- void addFiles(const FilePaths &filePaths,
- const Utils::SmallStringVector &arguments);
+ void addFile(FilePath &&filePath,
+ Utils::SmallString &&content,
+ Utils::SmallStringVector &&commandLine);
+ void addFiles(const FilePaths &filePaths, const Utils::SmallStringVector &arguments);
void addUnsavedFiles(const V2::FileContainers &unsavedFiles);
@@ -102,11 +87,4 @@ private:
std::vector<UnsavedFileContent> m_unsavedFileContents;
};
-extern template
-void ClangTool::addFiles<Utils::SmallStringVector>(const Utils::SmallStringVector &filePaths,
- const Utils::SmallStringVector &arguments);
-extern template
-void ClangTool::addFiles<Utils::PathStringVector>(const Utils::PathStringVector &filePaths,
- const Utils::SmallStringVector &arguments);
-
} // namespace ClangBackEnd
diff --git a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp
index c5906aaae4..1e1609d1a4 100644
--- a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp
+++ b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.cpp
@@ -27,20 +27,15 @@
#include "clangrefactoringbackend_global.h"
+#include <filepath.h>
+#include <nativefilepath.h>
+
namespace ClangBackEnd {
RefactoringCompilationDatabase::RefactoringCompilationDatabase()
{
}
-namespace {
-
-std::string concatFilePath(const clang::tooling::CompileCommand &compileCommand)
-{
- return compileCommand.Directory + nativeSeparator + compileCommand.Filename;
-}
-}
-
std::vector<clang::tooling::CompileCommand>
RefactoringCompilationDatabase::getCompileCommands(llvm::StringRef filePath) const
{
@@ -50,7 +45,7 @@ RefactoringCompilationDatabase::getCompileCommands(llvm::StringRef filePath) con
m_compileCommands.end(),
std::back_inserter(foundCommands),
[&] (const clang::tooling::CompileCommand &compileCommand) {
- return filePath == concatFilePath(compileCommand);
+ return filePath == compileCommand.Filename;
});
return foundCommands;
@@ -66,7 +61,7 @@ RefactoringCompilationDatabase::getAllFiles() const
m_compileCommands.end(),
std::back_inserter(filePaths),
[&] (const clang::tooling::CompileCommand &compileCommand) {
- return concatFilePath(compileCommand);
+ return compileCommand.Filename;
});
return filePaths;
@@ -78,12 +73,13 @@ RefactoringCompilationDatabase::getAllCompileCommands() const
return m_compileCommands;
}
-void RefactoringCompilationDatabase::addFile(const std::string &directory,
- const std::string &fileName,
- const std::vector<std::string> &commandLine)
+void RefactoringCompilationDatabase::addFile(NativeFilePathView filePath,
+ Utils::SmallStringVector &&commandLine)
{
-
- m_compileCommands.emplace_back(directory, fileName, commandLine, llvm::StringRef());
+ m_compileCommands.emplace_back(std::string(filePath.directory()),
+ std::string(filePath),
+ std::vector<std::string>(commandLine),
+ llvm::StringRef());
}
} // namespace ClangBackEnd
diff --git a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.h b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.h
index ca2d133819..b25e43e483 100644
--- a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.h
+++ b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.h
@@ -27,6 +27,8 @@
#include "clang/Tooling/CompilationDatabase.h"
+#include <nativefilepath.h>
+
namespace ClangBackEnd {
@@ -39,9 +41,7 @@ public:
std::vector<std::string> getAllFiles() const override;
std::vector<clang::tooling::CompileCommand> getAllCompileCommands() const override;
- void addFile(const std::string &directory,
- const std::string &fileName,
- const std::vector<std::string> &commandLine);
+ void addFile(NativeFilePathView filePath, Utils::SmallStringVector &&commandLine);
private:
std::vector<clang::tooling::CompileCommand> m_compileCommands;
diff --git a/src/tools/clangrefactoringbackend/source/refactoringserver.cpp b/src/tools/clangrefactoringbackend/source/refactoringserver.cpp
index 4b51ee0d69..83aa5a31fd 100644
--- a/src/tools/clangrefactoringbackend/source/refactoringserver.cpp
+++ b/src/tools/clangrefactoringbackend/source/refactoringserver.cpp
@@ -62,10 +62,9 @@ void RefactoringServer::requestSourceLocationsForRenamingMessage(RequestSourceLo
{
SymbolFinder symbolFinder(message.line, message.column, m_filePathCache);
- symbolFinder.addFile(std::string(message.filePath.directory()),
- std::string(message.filePath.name()),
- std::string(message.unsavedContent),
- std::vector<std::string>(message.commandLine));
+ symbolFinder.addFile(std::move(message.filePath),
+ std::move(message.unsavedContent),
+ std::move(message.commandLine));
symbolFinder.findSymbol();
@@ -79,10 +78,9 @@ void RefactoringServer::requestSourceRangesAndDiagnosticsForQueryMessage(
{
ClangQuery clangQuery(m_filePathCache, message.takeQuery());
- clangQuery.addFile(std::string(message.source.filePath.directory()),
- std::string(message.source.filePath.name()),
- std::string(message.source.unsavedFileContent),
- std::vector<std::string>(message.source.commandLineArguments));
+ clangQuery.addFile(std::move(message.source.filePath),
+ std::move(message.source.unsavedFileContent),
+ std::move(message.source.commandLineArguments));
clangQuery.findLocations();
diff --git a/src/tools/perfparser b/src/tools/perfparser
-Subproject 15a4e2d8dcde52994a85361154c44e7810779d7
+Subproject 5222205d9acca1107507bfdeebaab194157012e
diff --git a/src/tools/tools.pro b/src/tools/tools.pro
index 07cc2c2114..61a8d07cc5 100644
--- a/src/tools/tools.pro
+++ b/src/tools/tools.pro
@@ -81,3 +81,8 @@ exists(perfparser/perfparser.pro) {
}
OTHER_FILES += tools.qbs
+
+# delegate deployqt target
+deployqt.CONFIG += recursive
+deployqt.recurse = perfparser
+QMAKE_EXTRA_TARGETS += deployqt
diff --git a/tests/system/objects.map b/tests/system/objects.map
index b3852a89ea..27cb7429d0 100644
--- a/tests/system/objects.map
+++ b/tests/system/objects.map
@@ -1,16 +1,16 @@
-:*Qt Creator.Build Project_Core::Internal::FancyToolButton {text?='Build Project*' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
+:*Qt Creator.Build Project_Core::Internal::FancyToolButton {name='Build.Button' text?='Build Project*' type='Core::Internal::FancyToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:*Qt Creator.Cancel Build_QToolButton {text='Cancel Build' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:*Qt Creator.Clear_QToolButton {text='Clear' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
-:*Qt Creator.Continue_Core::Internal::FancyToolButton {toolTip?='Continue *' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
+:*Qt Creator.Continue_Core::Internal::FancyToolButton {name='Debug.Button' toolTip?='Continue *' type='Core::Internal::FancyToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:*Qt Creator.Find_Find::Internal::FindToolBar {name='Core__Internal__FindWidget' type='Core::Internal::FindToolBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Find'}
:*Qt Creator.FormEditorStack_Designer::Internal::FormEditorStack {name='FormEditorStack' type='Designer::Internal::FormEditorStack' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
-:*Qt Creator.Interrupt_Core::Internal::FancyToolButton {toolTip='Interrupt' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
+:*Qt Creator.Interrupt_Core::Internal::FancyToolButton {name='Debug.Button' toolTip='Interrupt' type='Core::Internal::FancyToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:*Qt Creator.ProjectSelectorDockWidget_QDockWidget {name='ProjectSelectorDockWidget' type='QDockWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
-:*Qt Creator.Run_Core::Internal::FancyToolButton {text='Run' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
-:*Qt Creator.Start Debugging_Core::Internal::FancyToolButton {toolTip?='Start debugging*' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
+:*Qt Creator.Run_Core::Internal::FancyToolButton {name='Run.Button' text='Run' type='Core::Internal::FancyToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
+:*Qt Creator.Start Debugging_Core::Internal::FancyToolButton {name='Debug.Button' toolTip?='Start debugging*' type='Core::Internal::FancyToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:*Qt Creator.Widget Box_QDockWidget {name='WidgetBoxDockWidget' type='QDockWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Widget Box'}
:*Qt Creator.findEdit_Utils::FilterLineEdit {name='findEdit' type='Utils::FancyLineEdit' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
-:*Qt Creator_Core::Internal::FancyToolButton {occurrence='3' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
+:*Qt Creator_Core::Internal::FancyToolButton {name='KitSelector.Button' type='Core::Internal::FancyToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:*Qt Creator_Utils::FilterLineEdit {type='Utils::FancyLineEdit' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:*Qt Creator_Utils::IconButton {occurrence='4' type='Utils::IconButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:About Qt Creator_Core::Internal::VersionDialog {type='Core::Internal::VersionDialog' unnamed='1' visible='1' windowTitle='About Qt Creator'}
diff --git a/tests/unit/unittest/clangquery-test.cpp b/tests/unit/unittest/clangquery-test.cpp
index 8c486a47d7..35842e0143 100644
--- a/tests/unit/unittest/clangquery-test.cpp
+++ b/tests/unit/unittest/clangquery-test.cpp
@@ -94,7 +94,9 @@ TEST_F(ClangQuerySlowTest, RootSourceRangeForSimpleFunctionDeclarationRange)
TEST_F(ClangQuerySlowTest, SourceRangeInUnsavedFileDeclarationRange)
{
::ClangQuery query(filePathCache);
- query.addFile(TESTDATA_DIR, "query_simplefunction.cpp", "#include \"unsaved.h\"", {"cc", toNativePath(TESTDATA_DIR"/query_simplefunction.cpp"), "-std=c++14"});
+ query.addFile({TESTDATA_DIR "/query_simplefunction.cpp"},
+ "#include \"unsaved.h\"",
+ {"cc", toNativePath(TESTDATA_DIR "/query_simplefunction.cpp").path(), "-std=c++14"});
query.setQuery("functionDecl()");
ClangBackEnd::V2::FileContainer unsavedFile{{TESTDATA_DIR, "unsaved.h"}, "void unsaved();", {}};
query.addUnsavedFiles({unsavedFile});
@@ -108,7 +110,9 @@ TEST_F(ClangQuerySlowTest, SourceRangeInUnsavedFileDeclarationRange)
TEST_F(ClangQuerySlowTest, FileIsNotExistingButTheUnsavedDataIsParsed)
{
::ClangQuery query(filePathCache);
- query.addFile(TESTDATA_DIR, "foo.cpp", "void f() {}", {"cc", toNativePath(TESTDATA_DIR"/foo.cpp"), "-std=c++14"});
+ query.addFile({TESTDATA_DIR "/foo.cpp"},
+ "void f() {}",
+ {"cc", toNativePath(TESTDATA_DIR "/foo.cpp").path(), "-std=c++14"});
query.setQuery("functionDecl()");
query.findLocations();
@@ -120,9 +124,13 @@ TEST_F(ClangQuerySlowTest, FileIsNotExistingButTheUnsavedDataIsParsed)
TEST_F(ClangQuerySlowTest, DISABLED_SourceRangeInUnsavedFileDeclarationRangeOverride) // seems not to work in Clang
{
::ClangQuery query(filePathCache);
- query.addFile(TESTDATA_DIR, "query_simplefunction.cpp", "void f() {}", {"cc", toNativePath(TESTDATA_DIR"/query_simplefunction.cpp"), "-std=c++14"});
+ query.addFile({TESTDATA_DIR "/query_simplefunction.cpp"},
+ "void f() {}",
+ {"cc", toNativePath(TESTDATA_DIR "/query_simplefunction.cpp").path(), "-std=c++14"});
query.setQuery("functionDecl()");
- ClangBackEnd::V2::FileContainer unsavedFile{{TESTDATA_DIR, "query_simplefunction.cpp"}, "void unsaved();", {}};
+ ClangBackEnd::V2::FileContainer unsavedFile{{TESTDATA_DIR "/query_simplefunction.cpp"},
+ "void unsaved();",
+ {}};
query.addUnsavedFiles({unsavedFile});
query.findLocations();
@@ -215,8 +223,15 @@ TEST_F(ClangQuerySlowTest, DiagnosticForWrongArgumenType)
void ClangQuery::SetUp()
{
- simpleFunctionQuery.addFile(TESTDATA_DIR, "query_simplefunction.cpp", "", {"cc", toNativePath(TESTDATA_DIR"/query_simplefunction.cpp"), "-std=c++14"});
- simpleClassQuery.addFile(TESTDATA_DIR, "query_simpleclass.cpp", "", {"cc", "query_simpleclass.cpp", "-std=c++14"});
-
-}
-}
+ simpleFunctionQuery.addFile({TESTDATA_DIR "/query_simplefunction.cpp"},
+ "",
+ {"cc",
+ toNativePath(TESTDATA_DIR "/query_simplefunction.cpp").path(),
+ "-std=c++14"});
+ simpleClassQuery.addFile({TESTDATA_DIR "/query_simpleclass.cpp"},
+ "",
+ {"cc",
+ toNativePath(TESTDATA_DIR "/query_simpleclass.cpp").path(),
+ "-std=c++14"});
+}
+} // namespace
diff --git a/tests/unit/unittest/clangquerygatherer-test.cpp b/tests/unit/unittest/clangquerygatherer-test.cpp
index 9c575f6a0f..b0ea9cb3e0 100644
--- a/tests/unit/unittest/clangquerygatherer-test.cpp
+++ b/tests/unit/unittest/clangquerygatherer-test.cpp
@@ -87,13 +87,22 @@ protected:
Utils::SmallString sourceContent{"#include \"query_simplefunction.h\"\nvoid f() {}"};
FileContainer source{{TESTDATA_DIR, "query_simplefunction.cpp"},
sourceContent.clone(),
- {"cc", toNativePath(TESTDATA_DIR"/query_simplefunction.cpp"), "-I", TESTDATA_DIR}};
+ {"cc",
+ toNativePath(TESTDATA_DIR "/query_simplefunction.cpp").path(),
+ "-I",
+ TESTDATA_DIR}};
FileContainer source2{{TESTDATA_DIR, "query_simplefunction2.cpp"},
{},
- {"cc", toNativePath(TESTDATA_DIR"/query_simplefunction2.cpp"), "-I", TESTDATA_DIR}};
+ {"cc",
+ toNativePath(TESTDATA_DIR "/query_simplefunction2.cpp").path(),
+ "-I",
+ TESTDATA_DIR}};
FileContainer source3{{TESTDATA_DIR, "query_simplefunction3.cpp"},
{},
- {"cc", toNativePath(TESTDATA_DIR"/query_simplefunction3.cpp"), "-I", TESTDATA_DIR}};
+ {"cc",
+ toNativePath(TESTDATA_DIR "/query_simplefunction3.cpp").path(),
+ "-I",
+ TESTDATA_DIR}};
Utils::SmallString unsavedContent{"void f();"};
FileContainer unsaved{{TESTDATA_DIR, "query_simplefunction.h"},
unsavedContent.clone(),
diff --git a/tests/unit/unittest/commandlinebuilder-test.cpp b/tests/unit/unittest/commandlinebuilder-test.cpp
index c3dad70de3..9de48fe0d5 100644
--- a/tests/unit/unittest/commandlinebuilder-test.cpp
+++ b/tests/unit/unittest/commandlinebuilder-test.cpp
@@ -25,6 +25,8 @@
#include "googletest.h"
+#include "filesystem-utilities.h"
+
#include <commandlinebuilder.h>
#include <pchtask.h>
#include <projectpartcontainer.h>
@@ -136,7 +138,7 @@ TYPED_TEST(CommandLineBuilder, CTask)
ASSERT_THAT(
builder.commandLine,
- ElementsAre("clang", "-x", "c-header", "-std=c11", "-nostdinc", "-nostdinc++", "/source/file.c"));
+ ElementsAre("clang", "-x", "c-header", "-std=c11", "-nostdinc", "-nostdinc++", toNativePath("/source/file.c").path()));
}
TYPED_TEST(CommandLineBuilder, ObjectiveCTask)
@@ -154,7 +156,7 @@ TYPED_TEST(CommandLineBuilder, ObjectiveCTask)
"-std=c11",
"-nostdinc",
"-nostdinc++",
- "/source/file.c"));
+ toNativePath("/source/file.c").path()));
}
TYPED_TEST(CommandLineBuilder, CppTask)
@@ -171,7 +173,7 @@ TYPED_TEST(CommandLineBuilder, CppTask)
"-std=c++98",
"-nostdinc",
"-nostdinc++",
- "/source/file.cpp"));
+ toNativePath("/source/file.cpp").path()));
}
TYPED_TEST(CommandLineBuilder, ObjectiveCppTask)
@@ -189,7 +191,7 @@ TYPED_TEST(CommandLineBuilder, ObjectiveCppTask)
"-std=c++98",
"-nostdinc",
"-nostdinc++",
- "/source/file.cpp"));
+ toNativePath("/source/file.cpp").path()));
}
TYPED_TEST(CommandLineBuilder, Cpp98)
@@ -422,18 +424,18 @@ TYPED_TEST(CommandLineBuilder, IncludesOrder)
"-nostdinc",
"-nostdinc++",
"-I",
- "/include/foo",
+ toNativePath("/include/foo").path(),
"-I",
- "/include/bar",
+ toNativePath("/include/bar").path(),
"-F",
- "/system/foo",
+ toNativePath("/system/foo").path(),
"-isystem",
- "/system/bar",
+ toNativePath("/system/bar").path(),
"-isystem",
- "/builtin/foo",
+ toNativePath("/builtin/foo").path(),
"-isystem",
- "/builtin/bar",
- "/source/file.cpp"));
+ toNativePath("/builtin/bar").path(),
+ toNativePath("/source/file.cpp").path()));
}
TYPED_TEST(CommandLineBuilder, EmptySourceFile)
@@ -455,7 +457,7 @@ TYPED_TEST(CommandLineBuilder, SourceFile)
"-std=c++98",
"-nostdinc",
"-nostdinc++",
- "/source/file.cpp"));
+ toNativePath("/source/file.cpp").path()));
}
@@ -470,7 +472,7 @@ TYPED_TEST(CommandLineBuilder, EmptyOutputFile)
"-std=c++98",
"-nostdinc",
"-nostdinc++",
- "/source/file.cpp"));
+ toNativePath("/source/file.cpp").path()));
}
TYPED_TEST(CommandLineBuilder, OutputFile)
@@ -485,8 +487,8 @@ TYPED_TEST(CommandLineBuilder, OutputFile)
"-nostdinc",
"-nostdinc++",
"-o",
- "/output/file.o",
- "/source/file.cpp"));
+ toNativePath("/output/file.o").path(),
+ toNativePath("/source/file.cpp").path()));
}
TYPED_TEST(CommandLineBuilder, IncludePchPath)
@@ -503,10 +505,10 @@ TYPED_TEST(CommandLineBuilder, IncludePchPath)
"-Xclang",
"-include-pch",
"-Xclang",
- "/pch/file.pch",
+ toNativePath("/pch/file.pch").path(),
"-o",
- "/output/file.o",
- "/source/file.cpp"));
+ toNativePath("/output/file.o").path(),
+ toNativePath("/source/file.cpp").path()));
}
TYPED_TEST(CommandLineBuilder, CompilerMacros)
diff --git a/tests/unit/unittest/filesystem-utilities.h b/tests/unit/unittest/filesystem-utilities.h
index 3bbafdf368..9a4fd8e2db 100644
--- a/tests/unit/unittest/filesystem-utilities.h
+++ b/tests/unit/unittest/filesystem-utilities.h
@@ -26,32 +26,27 @@
#pragma once
#include <utils/hostosinfo.h>
-#include <utils/smallstring.h>
-#include <string>
+#include <nativefilepath.h>
-// use std::filesystem::path if it is supported by all compilers
-static const char nativeSeparator = Utils::HostOsInfo::isWindowsHost() ? '\\' : '/';
+template<std::size_t Size>
+ClangBackEnd::NativeFilePath toNativePath(const char (&text)[Size])
+{
+ ClangBackEnd::FilePath path = text;
+ return ClangBackEnd::NativeFilePath{path};
+}
-template <std::size_t Size>
-std::string toNativePath(const char (&text)[Size])
+inline ClangBackEnd::NativeFilePath toNativePath(const QString &text)
{
- std::string path = text;
+ ClangBackEnd::FilePath path{text};
- if (Utils::HostOsInfo::isWindowsHost())
- std::replace(path.begin(), path.end(), '/', '\\');
-
- return path;
+ return ClangBackEnd::NativeFilePath{path};
}
-inline
-std::string toNativePath(const QString &qStringPath)
+inline ClangBackEnd::NativeFilePath toNativePath(Utils::SmallStringView text)
{
- auto path = qStringPath.toStdString();
-
- if (Utils::HostOsInfo::isWindowsHost())
- std::replace(path.begin(), path.end(), '/', '\\');
+ ClangBackEnd::FilePath path{text};
- return path;
+ return ClangBackEnd::NativeFilePath{path};
}
diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp
index 3901cb0d30..30660376e1 100644
--- a/tests/unit/unittest/gtest-creator-printing.cpp
+++ b/tests/unit/unittest/gtest-creator-printing.cpp
@@ -69,10 +69,24 @@
#include <coreplugin/find/searchresultitem.h>
#include <coreplugin/locator/ilocatorfilter.h>
+#include <clang/Tooling/CompilationDatabase.h>
+
namespace {
ClangBackEnd::FilePathCaching *filePathCache = nullptr;
}
+namespace clang {
+namespace tooling {
+struct CompileCommand;
+
+std::ostream &operator<<(std::ostream &out, const CompileCommand &command)
+{
+ return out << "(" << command.Directory << ", " << command.Filename << ", "
+ << command.CommandLine << ", " << command.Output << ")";
+}
+} // namespace tooling
+} // namespace clang
+
void PrintTo(const Utf8String &text, ::std::ostream *os)
{
*os << text;
diff --git a/tests/unit/unittest/gtest-creator-printing.h b/tests/unit/unittest/gtest-creator-printing.h
index ec54af3085..d0f0013f60 100644
--- a/tests/unit/unittest/gtest-creator-printing.h
+++ b/tests/unit/unittest/gtest-creator-printing.h
@@ -40,6 +40,14 @@
class Utf8String;
void PrintTo(const Utf8String &text, ::std::ostream *os);
+namespace clang {
+namespace tooling {
+struct CompileCommand;
+
+std::ostream &operator<<(std::ostream &out, const CompileCommand &command);
+} // namespace tooling
+} // namespace clang
+
namespace Core {
class LocatorFilterEntry;
diff --git a/tests/unit/unittest/nativefilepath-test.cpp b/tests/unit/unittest/nativefilepath-test.cpp
index 864c91dc60..327cff42dc 100644
--- a/tests/unit/unittest/nativefilepath-test.cpp
+++ b/tests/unit/unittest/nativefilepath-test.cpp
@@ -25,6 +25,7 @@
#include "googletest.h"
+#include <filepath.h>
#include <nativefilepath.h>
namespace {
diff --git a/tests/unit/unittest/pchcreator-test.cpp b/tests/unit/unittest/pchcreator-test.cpp
index 26ca9965c2..8a1e1ffa8e 100644
--- a/tests/unit/unittest/pchcreator-test.cpp
+++ b/tests/unit/unittest/pchcreator-test.cpp
@@ -26,6 +26,7 @@
#include "googletest.h"
#include "fakeprocess.h"
+#include "filesystem-utilities.h"
#include "mockclangpathwatcher.h"
#include "mockpchmanagerclient.h"
@@ -130,21 +131,6 @@ TEST_F(PchCreator, CreateProjectPartPchFileContent)
HasSubstr("#include \"" TESTDATA_DIR "/builddependencycollector/external/external2.h\"\n")));
}
-TEST_F(PchCreator, CreatePchIncludeFile)
-{
- auto content = creator.generatePchIncludeFileContent(pchTask1.includes);
- auto pchIncludeFilePath = creator.generatePchHeaderFilePath();
- auto file = creator.generateFileWithContent(pchIncludeFilePath, content);
- file->open(QIODevice::ReadOnly);
-
- auto fileContent = file->readAll();
-
- ASSERT_THAT(fileContent.toStdString(),
- AllOf(HasSubstr("#include \"" TESTDATA_DIR "/builddependencycollector/project/header2.h\"\n"),
- HasSubstr("#include \"" TESTDATA_DIR "/builddependencycollector/external/external1.h\"\n"),
- HasSubstr("#include \"" TESTDATA_DIR "/builddependencycollector/external/external2.h\"\n")));
-}
-
TEST_F(PchCreator, CreateProjectPartClangCompilerArguments)
{
auto arguments = creator.generateClangCompilerArguments(std::move(pchTask1),
@@ -159,11 +145,11 @@ TEST_F(PchCreator, CreateProjectPartClangCompilerArguments)
"-nostdinc",
"-nostdinc++",
"-I",
- TESTDATA_DIR "/builddependencycollector/project",
+ toNativePath(TESTDATA_DIR "/builddependencycollector/project").path(),
"-isystem",
- TESTDATA_DIR "/builddependencycollector/external",
+ toNativePath(TESTDATA_DIR "/builddependencycollector/external").path(),
"-isystem",
- TESTDATA_DIR "/builddependencycollector/system",
+ toNativePath(TESTDATA_DIR "/builddependencycollector/system").path(),
"-o",
"project.pch",
"project.h"));
@@ -185,11 +171,11 @@ TEST_F(PchCreator, CreateProjectPartClangCompilerArgumentsWithSystemPch)
"-nostdinc",
"-nostdinc++",
"-I",
- TESTDATA_DIR "/builddependencycollector/project",
+ toNativePath(TESTDATA_DIR "/builddependencycollector/project").path(),
"-isystem",
- TESTDATA_DIR "/builddependencycollector/external",
+ toNativePath(TESTDATA_DIR "/builddependencycollector/external").path(),
"-isystem",
- TESTDATA_DIR "/builddependencycollector/system",
+ toNativePath(TESTDATA_DIR "/builddependencycollector/system").path(),
"-Xclang",
"-include-pch",
"-Xclang",
diff --git a/tests/unit/unittest/pchtaskgenerator-test.cpp b/tests/unit/unittest/pchtaskgenerator-test.cpp
index a3ebb3c17b..08a0079ad8 100644
--- a/tests/unit/unittest/pchtaskgenerator-test.cpp
+++ b/tests/unit/unittest/pchtaskgenerator-test.cpp
@@ -91,46 +91,42 @@ TEST_F(PchTaskGenerator, AddProjectParts)
mockPchTaskMerger,
mergeTasks(
ElementsAre(AllOf(
- Field(
- &PchTaskSet::system,
- AllOf(
- Field(&PchTask::projectPartIds, ElementsAre("ProjectPart1")),
- Field(&PchTask::includes, ElementsAre(5)),
- Field(&PchTask::allIncludes, IsEmpty()),
- Field(&PchTask::compilerMacros,
- ElementsAre(CompilerMacro{"SE", "4", 4}, CompilerMacro{"WU", "5", 5})),
- Field(&PchTask::systemIncludeSearchPaths,
- ElementsAre(
- IncludeSearchPath{"/system/path", 2, IncludeSearchPathType::System},
- IncludeSearchPath{"/builtin/path", 3, IncludeSearchPathType::BuiltIn},
- IncludeSearchPath{"/framework/path", 1, IncludeSearchPathType::System})),
- Field(&PchTask::projectIncludeSearchPaths,
- ElementsAre(IncludeSearchPath{"/to/path1", 1, IncludeSearchPathType::User},
- IncludeSearchPath{"/to/path2", 2, IncludeSearchPathType::User})),
- Field(&PchTask::toolChainArguments, ElementsAre("--yi")),
- Field(&PchTask::language, Eq(Utils::Language::Cxx)),
- Field(&PchTask::languageVersion, Eq(Utils::LanguageVersion::CXX11)),
- Field(&PchTask::languageExtension, Eq(Utils::LanguageExtension::All)))),
+ Field(&PchTaskSet::system,
+ AllOf(Field(&PchTask::projectPartIds, ElementsAre("ProjectPart1")),
+ Field(&PchTask::includes, ElementsAre(5)),
+ Field(&PchTask::allIncludes, IsEmpty()),
+ Field(&PchTask::compilerMacros,
+ ElementsAre(CompilerMacro{"SE", "4", 4}, CompilerMacro{"WU", "5", 5})),
+ Field(&PchTask::systemIncludeSearchPaths,
+ ElementsAre(
+ IncludeSearchPath{"/system/path", 2, IncludeSearchPathType::System},
+ IncludeSearchPath{"/builtin/path", 3, IncludeSearchPathType::BuiltIn},
+ IncludeSearchPath{"/framework/path", 1, IncludeSearchPathType::System})),
+ Field(&PchTask::projectIncludeSearchPaths, IsEmpty()),
+ Field(&PchTask::toolChainArguments, ElementsAre("--yi")),
+ Field(&PchTask::language, Eq(Utils::Language::Cxx)),
+ Field(&PchTask::languageVersion, Eq(Utils::LanguageVersion::CXX11)),
+ Field(&PchTask::languageExtension, Eq(Utils::LanguageExtension::All)))),
AllOf(Field(
&PchTaskSet::project,
- AllOf(
- Field(&PchTask::projectPartIds, ElementsAre("ProjectPart1")),
- Field(&PchTask::includes, ElementsAre(3)),
- Field(&PchTask::allIncludes, ElementsAre(1, 2, 3, 4, 5)),
- Field(&PchTask::compilerMacros,
- ElementsAre(CompilerMacro{"YI", "1", 1}, CompilerMacro{"SAN", "3", 3})),
- Field(&PchTask::systemIncludeSearchPaths,
- ElementsAre(
- IncludeSearchPath{"/system/path", 2, IncludeSearchPathType::System},
- IncludeSearchPath{"/builtin/path", 3, IncludeSearchPathType::BuiltIn},
- IncludeSearchPath{"/framework/path", 1, IncludeSearchPathType::System})),
- Field(&PchTask::projectIncludeSearchPaths,
- ElementsAre(IncludeSearchPath{"/to/path1", 1, IncludeSearchPathType::User},
- IncludeSearchPath{"/to/path2", 2, IncludeSearchPathType::User})),
- Field(&PchTask::toolChainArguments, ElementsAre("--yi")),
- Field(&PchTask::language, Eq(Utils::Language::Cxx)),
- Field(&PchTask::languageVersion, Eq(Utils::LanguageVersion::CXX11)),
- Field(&PchTask::languageExtension, Eq(Utils::LanguageExtension::All))))))),
+ AllOf(Field(&PchTask::projectPartIds, ElementsAre("ProjectPart1")),
+ Field(&PchTask::includes, ElementsAre(3)),
+ Field(&PchTask::allIncludes, ElementsAre(1, 2, 3, 4, 5)),
+ Field(&PchTask::compilerMacros,
+ ElementsAre(CompilerMacro{"YI", "1", 1}, CompilerMacro{"SAN", "3", 3})),
+ Field(&PchTask::systemIncludeSearchPaths,
+ ElementsAre(
+ IncludeSearchPath{"/system/path", 2, IncludeSearchPathType::System},
+ IncludeSearchPath{"/builtin/path", 3, IncludeSearchPathType::BuiltIn},
+ IncludeSearchPath{"/framework/path", 1, IncludeSearchPathType::System})),
+ Field(&PchTask::projectIncludeSearchPaths,
+ ElementsAre(
+ IncludeSearchPath{"/to/path1", 1, IncludeSearchPathType::User},
+ IncludeSearchPath{"/to/path2", 2, IncludeSearchPathType::User})),
+ Field(&PchTask::toolChainArguments, ElementsAre("--yi")),
+ Field(&PchTask::language, Eq(Utils::Language::Cxx)),
+ Field(&PchTask::languageVersion, Eq(Utils::LanguageVersion::CXX11)),
+ Field(&PchTask::languageExtension, Eq(Utils::LanguageExtension::All))))))),
ElementsAre(Eq("ToolChainArgument"))));
generator.addProjectParts({projectPart1}, {"ToolChainArgument"});
diff --git a/tests/unit/unittest/refactoringcompilationdatabase-test.cpp b/tests/unit/unittest/refactoringcompilationdatabase-test.cpp
index b635d174a9..59f88f8b53 100644
--- a/tests/unit/unittest/refactoringcompilationdatabase-test.cpp
+++ b/tests/unit/unittest/refactoringcompilationdatabase-test.cpp
@@ -24,8 +24,10 @@
****************************************************************************/
#include "googletest.h"
+#include "filesystem-utilities.h"
#include <refactoringcompilationdatabase.h>
+#include <nativefilepath.h>
#include <utils/smallstring.h>
@@ -38,16 +40,16 @@ using testing::PrintToString;
namespace {
-MATCHER_P3(IsCompileCommand, directory, fileName, commandLine,
- std::string(negation ? "isn't" : "is")
- + " compile command with directory "+ PrintToString(directory)
- + ", file name " + PrintToString(fileName)
- + " and command line " + PrintToString(commandLine)
- )
+MATCHER_P3(IsCompileCommand,
+ directory,
+ filePath,
+ commandLine,
+ std::string(negation ? "isn't" : "is") + " compile command with directory "
+ + PrintToString(directory) + ", file name " + PrintToString(filePath)
+ + " and command line " + PrintToString(commandLine))
{
- if (arg.Directory != directory
- || arg.Filename != fileName
- || arg.CommandLine != commandLine)
+ if (arg.Directory != std::string(directory) || arg.Filename != std::string(filePath)
+ || arg.CommandLine != commandLine)
return false;
return true;
@@ -56,7 +58,11 @@ MATCHER_P3(IsCompileCommand, directory, fileName, commandLine,
class RefactoringCompilationDatabase : public ::testing::Test
{
protected:
- void SetUp();
+ RefactoringCompilationDatabase()
+ {
+ database.addFile(ClangBackEnd::NativeFilePathView{temporarySourceFilePath},
+ {"cc", toNativePath(temporaryDirectoryPath + "/data.cpp").path(), "-DNO_DEBUG"});
+ }
protected:
ClangBackEnd::RefactoringCompilationDatabase database;
@@ -76,18 +82,28 @@ TEST_F(RefactoringCompilationDatabase, CompileCommandForFilePath)
{
auto compileCommands = database.getAllCompileCommands();
- ASSERT_THAT(compileCommands, Contains(IsCompileCommand(temporaryDirectoryPath,
- "data.cpp",
- std::vector<std::string>{"cc", "data.cpp", "-DNO_DEBUG"})));
+ ASSERT_THAT(compileCommands,
+ Contains(IsCompileCommand(
+ temporaryDirectoryPath,
+ toNativePath(temporaryDirectoryPath + "/data.cpp").path(),
+ std::vector<std::string>{
+ "cc",
+ std::string(toNativePath(temporaryDirectoryPath + "/data.cpp").path()),
+ "-DNO_DEBUG"})));
}
TEST_F(RefactoringCompilationDatabase, NoCompileCommandForFilePath)
{
auto compileCommands = database.getAllCompileCommands();
- ASSERT_THAT(compileCommands, Not(Contains(IsCompileCommand(temporaryDirectoryPath,
- "data.cpp2",
- std::vector<std::string>{"cc", "data.cpp", "-DNO_DEBUG"}))));
+ ASSERT_THAT(compileCommands,
+ Not(Contains(IsCompileCommand(
+ temporaryDirectoryPath,
+ toNativePath(temporaryDirectoryPath + "/data.cpp2").path(),
+ std::vector<std::string>{
+ "cc",
+ std::string(toNativePath(temporaryDirectoryPath + "/data.cpp").path()),
+ "-DNO_DEBUG"}))));
}
TEST_F(RefactoringCompilationDatabase, FilePaths)
@@ -96,10 +112,4 @@ TEST_F(RefactoringCompilationDatabase, FilePaths)
ASSERT_THAT(filePaths, Contains(std::string(temporarySourceFilePath)));
}
-
-void RefactoringCompilationDatabase::SetUp()
-{
- database.addFile(std::string(temporaryDirectoryPath), "data.cpp", {"cc", "data.cpp", "-DNO_DEBUG"});
-}
-
-}
+} // namespace
diff --git a/tests/unit/unittest/refactoringserver-test.cpp b/tests/unit/unittest/refactoringserver-test.cpp
index b8b97437e4..56f5e6950d 100644
--- a/tests/unit/unittest/refactoringserver-test.cpp
+++ b/tests/unit/unittest/refactoringserver-test.cpp
@@ -102,8 +102,9 @@ protected:
Utils::SmallString sourceContent{"void f()\n {}"};
FileContainer source{{TESTDATA_DIR, "query_simplefunction.cpp"},
sourceContent.clone(),
- {"cc", toNativePath(TESTDATA_DIR"/query_simplefunction.cpp")}};
- QTemporaryFile temporaryFile{Utils::TemporaryDirectory::masterDirectoryPath() + "/clangQuery-XXXXXX.cpp"};
+ {"cc", toNativePath(TESTDATA_DIR "/query_simplefunction.cpp").path()}};
+ QTemporaryFile temporaryFile{Utils::TemporaryDirectory::masterDirectoryPath()
+ + "/clangQuery-XXXXXX.cpp"};
int processingSlotCount = 2;
};
@@ -266,10 +267,11 @@ TEST_F(RefactoringServer, PollTimerNotIsActiveAfterCanceling)
TEST_F(RefactoringServerSlowTest, ForValidRequestSourceRangesAndDiagnosticsGetSourceRange)
{
- RequestSourceRangesAndDiagnosticsForQueryMessage message("functionDecl()",
- {FilePath(temporaryFile.fileName()),
- "void f() {}",
- {"cc", toNativePath(temporaryFile.fileName())}});
+ RequestSourceRangesAndDiagnosticsForQueryMessage message(
+ "functionDecl()",
+ {FilePath(temporaryFile.fileName()),
+ "void f() {}",
+ {"cc", toNativePath(temporaryFile.fileName()).path()}});
EXPECT_CALL(mockRefactoringClient,
sourceRangesAndDiagnosticsForQueryMessage(
@@ -285,10 +287,11 @@ TEST_F(RefactoringServerSlowTest, ForValidRequestSourceRangesAndDiagnosticsGetSo
TEST_F(RefactoringServerSlowTest, ForInvalidRequestSourceRangesAndDiagnosticsGetDiagnostics)
{
- RequestSourceRangesAndDiagnosticsForQueryMessage message("func()",
- {FilePath(temporaryFile.fileName()),
- "void f() {}",
- {"cc", toNativePath(temporaryFile.fileName())}});
+ RequestSourceRangesAndDiagnosticsForQueryMessage message(
+ "func()",
+ {FilePath(temporaryFile.fileName()),
+ "void f() {}",
+ {"cc", toNativePath(temporaryFile.fileName()).path()}});
EXPECT_CALL(mockRefactoringClient,
sourceRangesAndDiagnosticsForQueryMessage(
diff --git a/tests/unit/unittest/sourcerangeextractor-test.cpp b/tests/unit/unittest/sourcerangeextractor-test.cpp
index ae9d670bf4..171db9b956 100644
--- a/tests/unit/unittest/sourcerangeextractor-test.cpp
+++ b/tests/unit/unittest/sourcerangeextractor-test.cpp
@@ -57,7 +57,9 @@ protected:
void TearDown() override;
protected:
- TestClangTool clangTool{TESTDATA_DIR, "sourcerangeextractor_location.cpp", "", {"cc", "sourcerangeextractor_location.cpp"}};
+ TestClangTool clangTool{{TESTDATA_DIR "/sourcerangeextractor_location.cpp"},
+ "",
+ {"cc", "sourcerangeextractor_location.cpp"}};
ClangBackEnd::SourceRangesContainer sourceRangesContainer;
const clang::SourceManager &sourceManager{clangTool.sourceManager()};
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
diff --git a/tests/unit/unittest/symbolfinder-test.cpp b/tests/unit/unittest/symbolfinder-test.cpp
index 6ab0bd06cd..1dad3184d6 100644
--- a/tests/unit/unittest/symbolfinder-test.cpp
+++ b/tests/unit/unittest/symbolfinder-test.cpp
@@ -31,28 +31,30 @@
#include "filesystem-utilities.h"
-using ClangBackEnd::SymbolFinder;
using ClangBackEnd::FileContent;
-
+using ClangBackEnd::FilePathView;
+using ClangBackEnd::NativeFilePath;
+using ClangBackEnd::NativeFilePathView;
+using ClangBackEnd::SymbolFinder;
namespace {
-MATCHER_P2(IsSourceLocation, line, column,
- std::string(negation ? "isn't" : "is")
- + "line " + PrintToString(line)
- + ", column " + PrintToString(column)
- )
+inline bool operator==(const ClangBackEnd::NativeFilePath &first, const std::string &second)
+{
+ return first.path() == second;
+}
+MATCHER_P2(IsSourceLocation,
+ line,
+ column,
+ std::string(negation ? "isn't" : "is") + "line " + PrintToString(line) + ", column "
+ + PrintToString(column))
{
return arg.line == uint(line) && arg.column == uint(column);
}
-MATCHER_P(StrEq, text,
- std::string(negation ? "isn't" : "is")
- + " text " + PrintToString(text)
- )
+MATCHER_P(StrEq, text, std::string(negation ? "isn't" : "is") + " text " + PrintToString(text))
{
return std::string(arg.data(), arg.size()) == std::string(text);
}
-
using Finder = SymbolFinder;
class SymbolFinder : public testing::Test
@@ -65,7 +67,7 @@ using SymbolFinderSlowTest = SymbolFinder;
TEST_F(SymbolFinder, FileContentFilePath)
{
- FileContent fileContent(toNativePath("/tmp"), "data.cpp", "int variable;", {"cc", "data.cpp"});
+ FileContent fileContent(NativeFilePath{FilePathView{"/tmp/data.cpp"}}, "int variable;");
ASSERT_THAT(fileContent.filePath, toNativePath("/tmp/data.cpp"));
}
@@ -73,7 +75,9 @@ TEST_F(SymbolFinder, FileContentFilePath)
TEST_F(SymbolFinderSlowTest, FindName)
{
Finder finder(1, 5, filePathCaching);
- finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "int variable;", {"cc", "renamevariable.cpp"});
+ finder.addFile({TESTDATA_DIR "/renamevariable.cpp"},
+ "int variable;",
+ {"cc", toNativePath(TESTDATA_DIR "/renamevariable.cpp").path()});
finder.findSymbol();
@@ -83,7 +87,9 @@ TEST_F(SymbolFinderSlowTest, FindName)
TEST_F(SymbolFinderSlowTest, FindNameInUnsavedFile)
{
Finder finder(1, 5, filePathCaching);
- finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "int newVariable;", {"cc", "renamevariable.cpp"});
+ finder.addFile({TESTDATA_DIR "/renamevariable.cpp"},
+ "int newVariable;",
+ {"cc", toNativePath(TESTDATA_DIR "/renamevariable.cpp").path()});
finder.findSymbol();
@@ -93,7 +99,9 @@ TEST_F(SymbolFinderSlowTest, FindNameInUnsavedFile)
TEST_F(SymbolFinderSlowTest, FindUsrs)
{
Finder finder(1, 5, filePathCaching);
- finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "int variable;", {"cc", "renamevariable.cpp", "-std=c++14"});
+ finder.addFile({TESTDATA_DIR "/renamevariable.cpp"},
+ "int variable;",
+ {"cc", toNativePath(TESTDATA_DIR "/renamevariable.cpp").path(), "-std=c++14"});
finder.findSymbol();
@@ -103,7 +111,9 @@ TEST_F(SymbolFinderSlowTest, FindUsrs)
TEST_F(SymbolFinderSlowTest, VariableDeclarationSourceLocations)
{
Finder finder(1, 5, filePathCaching);
- finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"});
+ finder.addFile({TESTDATA_DIR "/renamevariable.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/renamevariable.cpp").path(), "-std=c++14"});
finder.findSymbol();
@@ -115,7 +125,9 @@ TEST_F(SymbolFinderSlowTest, VariableDeclarationSourceLocations)
TEST_F(SymbolFinderSlowTest, VariableUsageSourceLocations)
{
Finder finder(3, 9, filePathCaching);
- finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"});
+ finder.addFile({TESTDATA_DIR "/renamevariable.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/renamevariable.cpp").path(), "-std=c++14"});
finder.findSymbol();
@@ -127,7 +139,9 @@ TEST_F(SymbolFinderSlowTest, VariableUsageSourceLocations)
TEST_F(SymbolFinderSlowTest, TemplateMemberVariableDeclarationSourceLocations)
{
Finder finder(8, 18, filePathCaching);
- finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"});
+ finder.addFile({TESTDATA_DIR "/renamevariable.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/renamevariable.cpp").path(), "-std=c++14"});
finder.findSymbol();
@@ -140,7 +154,9 @@ TEST_F(SymbolFinderSlowTest, TemplateMemberVariableDeclarationSourceLocations)
TEST_F(SymbolFinderSlowTest, TemplateMemberVariableUsageSourceLocations)
{
Finder finder(15, 14, filePathCaching);
- finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"});
+ finder.addFile({TESTDATA_DIR "/renamevariable.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/renamevariable.cpp").path(), "-std=c++14"});
finder.findSymbol();
@@ -153,7 +169,9 @@ TEST_F(SymbolFinderSlowTest, TemplateMemberVariableUsageSourceLocations)
TEST_F(SymbolFinderSlowTest, TemplateMemberVariableUsageInLambdaSourceLocations)
{
Finder finder(18, 19, filePathCaching);
- finder.addFile(TESTDATA_DIR, "renamevariable.cpp", "", {"cc", "renamevariable.cpp", "-std=c++14"});
+ finder.addFile({TESTDATA_DIR "/renamevariable.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/renamevariable.cpp").path(), "-std=c++14"});
finder.findSymbol();
@@ -166,7 +184,9 @@ TEST_F(SymbolFinderSlowTest, TemplateMemberVariableUsageInLambdaSourceLocations)
TEST_F(SymbolFinderSlowTest, CursorOverMacroDefintionSymbolName)
{
Finder finder(1, 9, filePathCaching);
- finder.addFile(TESTDATA_DIR, "symbolfinder_macro.cpp", "", {"cc", "symbolfinder_macro.cpp"});
+ finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/symbolfinder_macro.cpp").path()});
finder.findSymbol();
@@ -176,7 +196,9 @@ TEST_F(SymbolFinderSlowTest, CursorOverMacroDefintionSymbolName)
TEST_F(SymbolFinderSlowTest, CursorOverMacroExpansionSymbolName)
{
Finder finder(10, 10, filePathCaching);
- finder.addFile(TESTDATA_DIR, "symbolfinder_macro.cpp", "", {"cc", "symbolfinder_macro.cpp"});
+ finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/symbolfinder_macro.cpp").path()});
finder.findSymbol();
@@ -186,7 +208,9 @@ TEST_F(SymbolFinderSlowTest, CursorOverMacroExpansionSymbolName)
TEST_F(SymbolFinderSlowTest, FindMacroDefinition)
{
Finder finder(1, 9, filePathCaching);
- finder.addFile(TESTDATA_DIR, "symbolfinder_macro.cpp", "", {"cc", "symbolfinder_macro.cpp"});
+ finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/symbolfinder_macro.cpp").path()});
finder.findSymbol();
@@ -197,7 +221,9 @@ TEST_F(SymbolFinderSlowTest, FindMacroDefinition)
TEST_F(SymbolFinderSlowTest, FindMacroExpansion)
{
Finder finder(1, 9, filePathCaching);
- finder.addFile(TESTDATA_DIR, "symbolfinder_macro.cpp", "", {"cc", "symbolfinder_macro.cpp"});
+ finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/symbolfinder_macro.cpp").path()});
finder.findSymbol();
@@ -208,7 +234,9 @@ TEST_F(SymbolFinderSlowTest, FindMacroExpansion)
TEST_F(SymbolFinderSlowTest, DoNotFindUndedefinedMacroExpansion)
{
Finder finder(1, 9, filePathCaching);
- finder.addFile(TESTDATA_DIR, "symbolfinder_macro.cpp", "", {"cc", "symbolfinder_macro.cpp"});
+ finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/symbolfinder_macro.cpp").path()});
finder.findSymbol();
@@ -219,7 +247,9 @@ TEST_F(SymbolFinderSlowTest, DoNotFindUndedefinedMacroExpansion)
TEST_F(SymbolFinderSlowTest, FindMacroDefinitionFromMacroExpansion)
{
Finder finder(10, 10, filePathCaching);
- finder.addFile(TESTDATA_DIR, "symbolfinder_macro.cpp", "", {"cc", "symbolfinder_macro.cpp"});
+ finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/symbolfinder_macro.cpp").path()});
finder.findSymbol();
@@ -231,7 +261,9 @@ TEST_F(SymbolFinderSlowTest, FindMacroDefinitionFromMacroExpansion)
TEST_F(SymbolFinderSlowTest, FindMacroExpansionBeforeMacroExpansionWithCursor)
{
Finder finder(12, 10, filePathCaching);
- finder.addFile(TESTDATA_DIR, "symbolfinder_macro.cpp", "", {"cc", "symbolfinder_macro.cpp"});
+ finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/symbolfinder_macro.cpp").path()});
finder.findSymbol();
@@ -242,7 +274,9 @@ TEST_F(SymbolFinderSlowTest, FindMacroExpansionBeforeMacroExpansionWithCursor)
TEST_F(SymbolFinderSlowTest, FindMacroExpansionAfterMacroExpansionWithCursor)
{
Finder finder(10, 10, filePathCaching);
- finder.addFile(TESTDATA_DIR, "symbolfinder_macro.cpp", "", {"cc", "symbolfinder_macro.cpp"});
+ finder.addFile({TESTDATA_DIR "/symbolfinder_macro.cpp"},
+ "",
+ {"cc", toNativePath(TESTDATA_DIR "/symbolfinder_macro.cpp").path()});
finder.findSymbol();
@@ -250,4 +284,4 @@ TEST_F(SymbolFinderSlowTest, FindMacroExpansionAfterMacroExpansionWithCursor)
Contains(IsSourceLocation(12, 10)));
}
-}
+} // namespace
diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp
index 104c17b11b..ce0fadfdf8 100644
--- a/tests/unit/unittest/symbolindexer-test.cpp
+++ b/tests/unit/unittest/symbolindexer-test.cpp
@@ -24,6 +24,7 @@
****************************************************************************/
#include "googletest.h"
+#include "filesystem-utilities.h"
#include "mockclangpathwatcher.h"
#include "mocksymbolscollector.h"
#include "mocksymbolstorage.h"
@@ -273,15 +274,15 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollector)
"-DBAR=1",
"-DFOO=1",
"-I",
- "/project/includes",
+ toNativePath("/project/includes").path(),
"-I",
- "/other/project/includes",
+ toNativePath("/other/project/includes").path(),
"-isystem",
- TESTDATA_DIR,
+ toNativePath(TESTDATA_DIR).path(),
"-isystem",
- "/other/includes",
+ toNativePath("/other/includes").path(),
"-isystem",
- "/includes")));
+ toNativePath("/includes").path())));
indexer.updateProjectParts({projectPart1});
}
@@ -303,19 +304,19 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInColl
"-DBAR=1",
"-DFOO=1",
"-I",
- "/project/includes",
+ toNativePath("/project/includes").path(),
"-I",
- "/other/project/includes",
+ toNativePath("/other/project/includes").path(),
"-isystem",
- TESTDATA_DIR,
+ toNativePath(TESTDATA_DIR).path(),
"-isystem",
- "/other/includes",
+ toNativePath("/other/includes").path(),
"-isystem",
- "/includes",
+ toNativePath("/includes").path(),
"-Xclang",
"-include-pch",
"-Xclang",
- "/path/to/pch")));
+ toNativePath("/path/to/pch").path())));
indexer.updateProjectParts({projectPart1});
}
@@ -336,15 +337,15 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithoutPrecompiledHeaderInC
"-DBAR=1",
"-DFOO=1",
"-I",
- "/project/includes",
+ toNativePath("/project/includes").path(),
"-I",
- "/other/project/includes",
+ toNativePath("/other/project/includes").path(),
"-isystem",
- TESTDATA_DIR,
+ toNativePath(TESTDATA_DIR).path(),
"-isystem",
- "/other/includes",
+ toNativePath("/other/includes").path(),
"-isystem",
- "/includes")));
+ toNativePath("/includes").path())));
indexer.updateProjectParts({projectPart1});
}
@@ -516,15 +517,15 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrderWithoutProjectPartArtifact)
"-DBAR=1",
"-DFOO=1",
"-I",
- "/project/includes",
+ toNativePath("/project/includes").path(),
"-I",
- "/other/project/includes",
+ toNativePath("/other/project/includes").path(),
"-isystem",
- TESTDATA_DIR,
+ toNativePath(TESTDATA_DIR).path(),
"-isystem",
- "/other/includes",
+ toNativePath("/other/includes").path(),
"-isystem",
- "/includes")));
+ toNativePath("/includes").path())));
EXPECT_CALL(mockCollector, collectSymbols());
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
@@ -568,15 +569,15 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrderWithProjectPartArtifact)
"-DBAR=1",
"-DFOO=1",
"-I",
- "/project/includes",
+ toNativePath("/project/includes").path(),
"-I",
- "/other/project/includes",
+ toNativePath("/other/project/includes").path(),
"-isystem",
- TESTDATA_DIR,
+ toNativePath(TESTDATA_DIR).path(),
"-isystem",
- "/other/includes",
+ toNativePath("/other/includes").path(),
"-isystem",
- "/includes")));
+ toNativePath("/includes").path())));
EXPECT_CALL(mockCollector, collectSymbols());
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
@@ -624,15 +625,15 @@ TEST_F(SymbolIndexer, UpdateChangedPathCallsInOrder)
"-DBAR=1",
"-DFOO=1",
"-I",
- "/project/includes",
+ toNativePath("/project/includes").path(),
"-I",
- "/other/project/includes",
+ toNativePath("/other/project/includes").path(),
"-isystem",
- TESTDATA_DIR,
+ toNativePath(TESTDATA_DIR).path(),
"-isystem",
- "/other/includes",
+ toNativePath("/other/includes").path(),
"-isystem",
- "/includes")));
+ toNativePath("/includes").path())));
EXPECT_CALL(mockCollector, collectSymbols());
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
@@ -686,19 +687,19 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsUsingPrecompiledHeader)
"-DBAR=1",
"-DFOO=1",
"-I",
- "/project/includes",
+ toNativePath("/project/includes").path(),
"-I",
- "/other/project/includes",
+ toNativePath("/other/project/includes").path(),
"-isystem",
- TESTDATA_DIR,
+ toNativePath(TESTDATA_DIR).path(),
"-isystem",
- "/other/includes",
+ toNativePath("/other/includes").path(),
"-isystem",
- "/includes",
+ toNativePath("/includes").path(),
"-Xclang",
"-include-pch",
"-Xclang",
- "/path/to/pch")));
+ toNativePath("/path/to/pch").path())));
indexer.pathsChanged({sourceFileIds[0]});
}
@@ -721,15 +722,15 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsNotUsingPrecompiledHeaderIfItNotExists)
"-DBAR=1",
"-DFOO=1",
"-I",
- "/project/includes",
+ toNativePath("/project/includes").path(),
"-I",
- "/other/project/includes",
+ toNativePath("/other/project/includes").path(),
"-isystem",
- TESTDATA_DIR,
+ toNativePath(TESTDATA_DIR).path(),
"-isystem",
- "/other/includes",
+ toNativePath("/other/includes").path(),
"-isystem",
- "/includes")));
+ toNativePath("/includes").path())));
indexer.pathsChanged({sourceFileIds[0]});
}
diff --git a/tests/unit/unittest/testclangtool.cpp b/tests/unit/unittest/testclangtool.cpp
index de41e42a81..bea5afeb4c 100644
--- a/tests/unit/unittest/testclangtool.cpp
+++ b/tests/unit/unittest/testclangtool.cpp
@@ -25,12 +25,11 @@
#include "testclangtool.h"
-TestClangTool::TestClangTool(std::string &&directory,
- std::string &&fileName,
- std::string &&content,
- std::vector<std::string> &&commandLine)
+TestClangTool::TestClangTool(ClangBackEnd::FilePath &&filePath,
+ Utils::SmallString &&content,
+ Utils::SmallStringVector &&commandLine)
{
- addFile(std::move(directory), std::move(fileName), std::move(content), std::move(commandLine));
+ addFile(std::move(filePath), std::move(content), std::move(commandLine));
auto clangTool = createTool();
diff --git a/tests/unit/unittest/testclangtool.h b/tests/unit/unittest/testclangtool.h
index f8ae0caf16..448c4e51ae 100644
--- a/tests/unit/unittest/testclangtool.h
+++ b/tests/unit/unittest/testclangtool.h
@@ -30,10 +30,9 @@
class TestClangTool : public ClangBackEnd::ClangTool
{
public:
- TestClangTool(std::string &&directory,
- std::string &&fileName,
- std::string &&content,
- std::vector<std::string> &&commandLine);
+ TestClangTool(ClangBackEnd::FilePath &&filePath,
+ Utils::SmallString &&content,
+ Utils::SmallStringVector &&commandLine);
const clang::ASTUnit *ast() const;
const clang::SourceManager &sourceManager() const;