summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2018-11-24 10:22:37 +0100
committerAlessandro Portale <alessandro.portale@qt.io>2018-12-07 18:42:04 +0000
commit134bb1b8b61aea6499069fb21e272f4a2ac7ff98 (patch)
treee9ba5c91098be12f7cf842808d0066d5fb7067d2
parentcd9ab31093adbf8675bdc1fc83c85934827ddd07 (diff)
downloadqt-creator-134bb1b8b61aea6499069fb21e272f4a2ac7ff98.tar.gz
QmlJSTools: Modernize
modernize-* Change-Id: Ifc270455ab7500d18798ac0130744662ad3303fb Reviewed-by: Orgad Shaneh <orgads@gmail.com>
-rw-r--r--src/plugins/qmljstools/qmljsbundleprovider.h10
-rw-r--r--src/plugins/qmljstools/qmljscodestylepreferencesfactory.cpp6
-rw-r--r--src/plugins/qmljstools/qmljscodestylepreferencesfactory.h14
-rw-r--r--src/plugins/qmljstools/qmljscodestylesettingspage.cpp4
-rw-r--r--src/plugins/qmljstools/qmljscodestylesettingspage.h16
-rw-r--r--src/plugins/qmljstools/qmljsfunctionfilter.cpp3
-rw-r--r--src/plugins/qmljstools/qmljsfunctionfilter.h4
-rw-r--r--src/plugins/qmljstools/qmljsindenter.cpp6
-rw-r--r--src/plugins/qmljstools/qmljslocatordata.cpp18
-rw-r--r--src/plugins/qmljstools/qmljslocatordata.h2
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp8
-rw-r--r--src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp8
-rw-r--r--src/plugins/qmljstools/qmljsrefactoringchanges.h2
-rw-r--r--src/plugins/qmljstools/qmljssemanticinfo.cpp8
-rw-r--r--src/plugins/qmljstools/qmljssemanticinfo.h10
-rw-r--r--src/plugins/qmljstools/qmljstoolssettings.cpp8
-rw-r--r--src/plugins/qmljstools/qmljstoolssettings.h2
17 files changed, 56 insertions, 73 deletions
diff --git a/src/plugins/qmljstools/qmljsbundleprovider.h b/src/plugins/qmljstools/qmljsbundleprovider.h
index a0bf3b4c3d..a239bd5cbd 100644
--- a/src/plugins/qmljstools/qmljsbundleprovider.h
+++ b/src/plugins/qmljstools/qmljsbundleprovider.h
@@ -47,8 +47,8 @@ class QMLJSTOOLS_EXPORT IBundleProvider : public QObject
{
Q_OBJECT
public:
- explicit IBundleProvider(QObject *parent = 0);
- ~IBundleProvider();
+ explicit IBundleProvider(QObject *parent = nullptr);
+ ~IBundleProvider() override;
static const QList<IBundleProvider *> allBundleProviders();
@@ -60,10 +60,10 @@ class QMLJSTOOLS_EXPORT BasicBundleProvider : public IBundleProvider
{
Q_OBJECT
public:
- explicit BasicBundleProvider(QObject *parent = 0);
+ explicit BasicBundleProvider(QObject *parent = nullptr);
- virtual void mergeBundlesForKit(ProjectExplorer::Kit *kit, QmlJS::QmlLanguageBundles &bundles
- , const QHash<QString,QString> &replacements);
+ void mergeBundlesForKit(ProjectExplorer::Kit *kit, QmlJS::QmlLanguageBundles &bundles,
+ const QHash<QString,QString> &replacements) override;
static QmlJS::QmlBundle defaultBundle(const QString &bundleInfoName);
static QmlJS::QmlBundle defaultQt5QtQuick2Bundle();
diff --git a/src/plugins/qmljstools/qmljscodestylepreferencesfactory.cpp b/src/plugins/qmljstools/qmljscodestylepreferencesfactory.cpp
index e1d395f8f9..f49f88929f 100644
--- a/src/plugins/qmljstools/qmljscodestylepreferencesfactory.cpp
+++ b/src/plugins/qmljstools/qmljscodestylepreferencesfactory.cpp
@@ -54,9 +54,7 @@ static const char *defaultPreviewText =
" }\n"
"}\n";
-QmlJSCodeStylePreferencesFactory::QmlJSCodeStylePreferencesFactory()
-{
-}
+QmlJSCodeStylePreferencesFactory::QmlJSCodeStylePreferencesFactory() = default;
Core::Id QmlJSCodeStylePreferencesFactory::languageId()
{
@@ -76,7 +74,7 @@ TextEditor::ICodeStylePreferences *QmlJSCodeStylePreferencesFactory::createCodeS
QWidget *QmlJSCodeStylePreferencesFactory::createEditor(TextEditor::ICodeStylePreferences *preferences,
QWidget *parent) const
{
- Internal::QmlJSCodeStylePreferencesWidget *widget = new Internal::QmlJSCodeStylePreferencesWidget(parent);
+ auto widget = new Internal::QmlJSCodeStylePreferencesWidget(parent);
widget->layout()->setMargin(0);
widget->setPreferences(preferences);
return widget;
diff --git a/src/plugins/qmljstools/qmljscodestylepreferencesfactory.h b/src/plugins/qmljstools/qmljscodestylepreferencesfactory.h
index 0061843485..18f40a98d3 100644
--- a/src/plugins/qmljstools/qmljscodestylepreferencesfactory.h
+++ b/src/plugins/qmljstools/qmljscodestylepreferencesfactory.h
@@ -34,14 +34,14 @@ class QmlJSCodeStylePreferencesFactory : public TextEditor::ICodeStylePreference
public:
QmlJSCodeStylePreferencesFactory();
- Core::Id languageId();
- QString displayName();
- TextEditor::ICodeStylePreferences *createCodeStyle() const;
+ Core::Id languageId() override;
+ QString displayName() override;
+ TextEditor::ICodeStylePreferences *createCodeStyle() const override;
QWidget *createEditor(TextEditor::ICodeStylePreferences *settings,
- QWidget *parent) const;
- TextEditor::Indenter *createIndenter() const;
- QString snippetProviderGroupId() const;
- QString previewText() const;
+ QWidget *parent) const override;
+ TextEditor::Indenter *createIndenter() const override;
+ QString snippetProviderGroupId() const override;
+ QString previewText() const override;
};
} // namespace QmlJSTools
diff --git a/src/plugins/qmljstools/qmljscodestylesettingspage.cpp b/src/plugins/qmljstools/qmljscodestylesettingspage.cpp
index c6d66a9ebd..f13ac29f75 100644
--- a/src/plugins/qmljstools/qmljscodestylesettingspage.cpp
+++ b/src/plugins/qmljstools/qmljscodestylesettingspage.cpp
@@ -51,7 +51,6 @@ namespace Internal {
QmlJSCodeStylePreferencesWidget::QmlJSCodeStylePreferencesWidget(QWidget *parent) :
QWidget(parent),
- m_preferences(0),
m_ui(new Ui::QmlJSCodeStyleSettingsPage)
{
m_ui->setupUi(this);
@@ -125,8 +124,7 @@ void QmlJSCodeStylePreferencesWidget::updatePreview()
QmlJSCodeStyleSettingsPage::QmlJSCodeStyleSettingsPage(/*QSharedPointer<CppFileSettings> &settings,*/
QWidget *parent) :
- Core::IOptionsPage(parent),
- m_pageTabPreferences(0)
+ Core::IOptionsPage(parent)
{
setId(Constants::QML_JS_CODE_STYLE_SETTINGS_ID);
setDisplayName(QCoreApplication::translate("QmlJSTools", Constants::QML_JS_CODE_STYLE_SETTINGS_NAME));
diff --git a/src/plugins/qmljstools/qmljscodestylesettingspage.h b/src/plugins/qmljstools/qmljscodestylesettingspage.h
index 96d377fc8c..c68f5a8eaf 100644
--- a/src/plugins/qmljstools/qmljscodestylesettingspage.h
+++ b/src/plugins/qmljstools/qmljscodestylesettingspage.h
@@ -50,8 +50,8 @@ class QmlJSCodeStylePreferencesWidget : public QWidget
Q_OBJECT
public:
- explicit QmlJSCodeStylePreferencesWidget(QWidget *parent = 0);
- ~QmlJSCodeStylePreferencesWidget();
+ explicit QmlJSCodeStylePreferencesWidget(QWidget *parent = nullptr);
+ ~QmlJSCodeStylePreferencesWidget() override;
void setPreferences(TextEditor::ICodeStylePreferences *preferences);
@@ -61,7 +61,7 @@ private:
void slotSettingsChanged();
void updatePreview();
- TextEditor::ICodeStylePreferences *m_preferences;
+ TextEditor::ICodeStylePreferences *m_preferences = nullptr;
Ui::QmlJSCodeStyleSettingsPage *m_ui;
};
@@ -71,14 +71,14 @@ class QmlJSCodeStyleSettingsPage : public Core::IOptionsPage
Q_OBJECT
public:
- explicit QmlJSCodeStyleSettingsPage(QWidget *parent = 0);
+ explicit QmlJSCodeStyleSettingsPage(QWidget *parent = nullptr);
- QWidget *widget();
- void apply();
- void finish();
+ QWidget *widget() override;
+ void apply() override;
+ void finish() override;
private:
- TextEditor::ICodeStylePreferences *m_pageTabPreferences;
+ TextEditor::ICodeStylePreferences *m_pageTabPreferences = nullptr;
QPointer<TextEditor::CodeStyleEditor> m_widget;
};
diff --git a/src/plugins/qmljstools/qmljsfunctionfilter.cpp b/src/plugins/qmljstools/qmljsfunctionfilter.cpp
index dce27bcd29..e13dd041d4 100644
--- a/src/plugins/qmljstools/qmljsfunctionfilter.cpp
+++ b/src/plugins/qmljstools/qmljsfunctionfilter.cpp
@@ -46,8 +46,7 @@ FunctionFilter::FunctionFilter(LocatorData *data, QObject *parent)
setIncludedByDefault(false);
}
-FunctionFilter::~FunctionFilter()
-{ }
+FunctionFilter::~FunctionFilter() = default;
void FunctionFilter::refresh(QFutureInterface<void> &)
{
diff --git a/src/plugins/qmljstools/qmljsfunctionfilter.h b/src/plugins/qmljstools/qmljsfunctionfilter.h
index 3b2cb2a93f..99759f3219 100644
--- a/src/plugins/qmljstools/qmljsfunctionfilter.h
+++ b/src/plugins/qmljstools/qmljsfunctionfilter.h
@@ -37,8 +37,8 @@ class FunctionFilter : public Core::ILocatorFilter
Q_OBJECT
public:
- explicit FunctionFilter(LocatorData *data, QObject *parent = 0);
- ~FunctionFilter();
+ explicit FunctionFilter(LocatorData *data, QObject *parent = nullptr);
+ ~FunctionFilter() override;
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry) override;
diff --git a/src/plugins/qmljstools/qmljsindenter.cpp b/src/plugins/qmljstools/qmljsindenter.cpp
index bcbff019b4..416267e695 100644
--- a/src/plugins/qmljstools/qmljsindenter.cpp
+++ b/src/plugins/qmljstools/qmljsindenter.cpp
@@ -35,11 +35,9 @@
using namespace QmlJSEditor;
using namespace Internal;
-Indenter::Indenter()
-{}
+Indenter::Indenter() = default;
-Indenter::~Indenter()
-{}
+Indenter::~Indenter() = default;
bool Indenter::isElectricCharacter(const QChar &ch) const
{
diff --git a/src/plugins/qmljstools/qmljslocatordata.cpp b/src/plugins/qmljstools/qmljslocatordata.cpp
index 47c89435a7..01725f1d9f 100644
--- a/src/plugins/qmljstools/qmljslocatordata.cpp
+++ b/src/plugins/qmljstools/qmljslocatordata.cpp
@@ -64,8 +64,7 @@ LocatorData::LocatorData()
[this] (ProjectExplorer::Project*) { m_entries.clear(); });
}
-LocatorData::~LocatorData()
-{}
+LocatorData::~LocatorData() = default;
namespace {
@@ -77,9 +76,6 @@ class FunctionFinder : protected AST::Visitor
QString m_documentContext;
public:
- FunctionFinder()
- {}
-
QList<LocatorData::Entry> run(const Document::Ptr &doc)
{
m_doc = doc;
@@ -116,12 +112,12 @@ protected:
m_context = old;
}
- bool visit(FunctionDeclaration *ast)
+ bool visit(FunctionDeclaration *ast) override
{
return visit(static_cast<FunctionExpression *>(ast));
}
- bool visit(FunctionExpression *ast)
+ bool visit(FunctionExpression *ast) override
{
if (ast->name.isEmpty())
return true;
@@ -146,7 +142,7 @@ protected:
return false;
}
- bool visit(UiScriptBinding *ast)
+ bool visit(UiScriptBinding *ast) override
{
if (!ast->qualifiedId)
return true;
@@ -163,7 +159,7 @@ protected:
return false;
}
- bool visit(UiObjectBinding *ast)
+ bool visit(UiObjectBinding *ast) override
{
if (!ast->qualifiedTypeNameId)
return true;
@@ -176,7 +172,7 @@ protected:
return false;
}
- bool visit(UiObjectDefinition *ast)
+ bool visit(UiObjectDefinition *ast) override
{
if (!ast->qualifiedTypeNameId)
return true;
@@ -189,7 +185,7 @@ protected:
return false;
}
- bool visit(AST::BinaryExpression *ast)
+ bool visit(AST::BinaryExpression *ast) override
{
auto fieldExpr = AST::cast<AST::FieldMemberExpression *>(ast->left);
auto funcExpr = AST::cast<AST::FunctionExpression *>(ast->right);
diff --git a/src/plugins/qmljstools/qmljslocatordata.h b/src/plugins/qmljstools/qmljslocatordata.h
index b32c48c6b4..6a9b3f9f27 100644
--- a/src/plugins/qmljstools/qmljslocatordata.h
+++ b/src/plugins/qmljstools/qmljslocatordata.h
@@ -39,7 +39,7 @@ class LocatorData : public QObject
Q_OBJECT
public:
LocatorData();
- ~LocatorData();
+ ~LocatorData() override;
enum EntryType
{
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index 14a0aa678d..0bd258e5c0 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -145,7 +145,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo)
{
- Target *activeTarget = 0;
+ Target *activeTarget = nullptr;
if (projectInfo.project)
activeTarget = projectInfo.project->activeTarget();
Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit();
@@ -212,9 +212,7 @@ ModelManager::ModelManager()
loadDefaultQmlTypeDescriptions();
}
-ModelManager::~ModelManager()
-{
-}
+ModelManager::~ModelManager() = default;
void ModelManager::delayedInitialization()
{
@@ -257,7 +255,7 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const
foreach (IDocument *document, DocumentModel::openedDocuments()) {
const QString key = document->filePath().toString();
- if (TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(document)) {
+ if (auto textDocument = qobject_cast<const TextEditor::TextDocument *>(document)) {
// TODO the language should be a property on the document, not the editor
if (DocumentModel::editorsForDocument(document).first()
->context().contains(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID)) {
diff --git a/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp b/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
index b1bc60fbbe..ece0d5fa1b 100644
--- a/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
+++ b/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
@@ -31,9 +31,7 @@ using namespace QmlJS;
using namespace QmlJSTools;
using namespace TextEditor;
-CreatorCodeFormatter::CreatorCodeFormatter()
-{
-}
+CreatorCodeFormatter::CreatorCodeFormatter() = default;
CreatorCodeFormatter::CreatorCodeFormatter(const TabSettings &tabSettings)
{
@@ -44,7 +42,7 @@ CreatorCodeFormatter::CreatorCodeFormatter(const TabSettings &tabSettings)
void CreatorCodeFormatter::saveBlockData(QTextBlock *block, const BlockData &data) const
{
TextBlockUserData *userData = TextDocumentLayout::userData(*block);
- QmlJSCodeFormatterData *cppData = static_cast<QmlJSCodeFormatterData *>(userData->codeFormatterData());
+ auto cppData = static_cast<QmlJSCodeFormatterData *>(userData->codeFormatterData());
if (!cppData) {
cppData = new QmlJSCodeFormatterData;
userData->setCodeFormatterData(cppData);
@@ -57,7 +55,7 @@ bool CreatorCodeFormatter::loadBlockData(const QTextBlock &block, BlockData *dat
TextBlockUserData *userData = TextDocumentLayout::testUserData(block);
if (!userData)
return false;
- QmlJSCodeFormatterData *cppData = static_cast<QmlJSCodeFormatterData *>(userData->codeFormatterData());
+ auto cppData = static_cast<const QmlJSCodeFormatterData *>(userData->codeFormatterData());
if (!cppData)
return false;
diff --git a/src/plugins/qmljstools/qmljsrefactoringchanges.h b/src/plugins/qmljstools/qmljsrefactoringchanges.h
index 132d7ee17a..2d6f5788d4 100644
--- a/src/plugins/qmljstools/qmljsrefactoringchanges.h
+++ b/src/plugins/qmljstools/qmljsrefactoringchanges.h
@@ -38,7 +38,7 @@ namespace QmlJSTools {
class QmlJSRefactoringChanges;
class QmlJSRefactoringFile;
class QmlJSRefactoringChangesData;
-typedef QSharedPointer<QmlJSRefactoringFile> QmlJSRefactoringFilePtr;
+using QmlJSRefactoringFilePtr = QSharedPointer<QmlJSRefactoringFile>;
class QMLJSTOOLS_EXPORT QmlJSRefactoringFile: public TextEditor::RefactoringFile
{
diff --git a/src/plugins/qmljstools/qmljssemanticinfo.cpp b/src/plugins/qmljstools/qmljssemanticinfo.cpp
index b72aa2f58e..1e9eae248a 100644
--- a/src/plugins/qmljstools/qmljssemanticinfo.cpp
+++ b/src/plugins/qmljstools/qmljssemanticinfo.cpp
@@ -131,7 +131,7 @@ protected:
AST::Node *SemanticInfo::rangeAt(int cursorPosition) const
{
- AST::Node *declaringMember = 0;
+ AST::Node *declaringMember = nullptr;
for (int i = ranges.size() - 1; i != -1; --i) {
const Range &range = ranges.at(i);
@@ -152,7 +152,7 @@ Node *SemanticInfo::declaringMemberNoProperties(int cursorPosition) const
{
AST::Node *node = rangeAt(cursorPosition);
- if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(node)) {
+ if (auto objectDefinition = cast<const UiObjectDefinition*>(node)) {
const QStringRef name = objectDefinition->qualifiedTypeNameId->name;
if (!name.isEmpty() && name.at(0).isLower()) {
QList<AST::Node *> path = rangePath(cursorPosition);
@@ -163,7 +163,7 @@ Node *SemanticInfo::declaringMemberNoProperties(int cursorPosition) const
if (path.size() > 2)
return path.at(path.size() - 3);
}
- } else if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(node)) {
+ } else if (auto objectBinding = cast<const UiObjectBinding*>(node)) {
const QStringRef name = objectBinding->qualifiedTypeNameId->name;
if (name.contains(QLatin1String("Gradient"))) {
QList<AST::Node *> path = rangePath(cursorPosition);
@@ -222,7 +222,7 @@ AST::Node *SemanticInfo::astNodeAt(int pos) const
{
const QList<AST::Node *> path = astPath(pos);
if (path.isEmpty())
- return 0;
+ return nullptr;
return path.last();
}
diff --git a/src/plugins/qmljstools/qmljssemanticinfo.h b/src/plugins/qmljstools/qmljssemanticinfo.h
index 58496252f6..8d7d1438dc 100644
--- a/src/plugins/qmljstools/qmljssemanticinfo.h
+++ b/src/plugins/qmljstools/qmljssemanticinfo.h
@@ -44,10 +44,8 @@ namespace QmlJSTools {
class QMLJSTOOLS_EXPORT Range
{
public:
- Range(): ast(nullptr) {}
-
-public: // attributes
- QmlJS::AST::Node *ast;
+ // attributes
+ QmlJS::AST::Node *ast = nullptr;
QTextCursor begin;
QTextCursor end;
};
@@ -55,8 +53,8 @@ public: // attributes
class QMLJSTOOLS_EXPORT SemanticInfo
{
public:
- SemanticInfo() {}
- SemanticInfo(QmlJS::ScopeChain *rootScopeChain);
+ SemanticInfo() = default;
+ explicit SemanticInfo(QmlJS::ScopeChain *rootScopeChain);
bool isValid() const;
int revision() const;
diff --git a/src/plugins/qmljstools/qmljstoolssettings.cpp b/src/plugins/qmljstools/qmljstoolssettings.cpp
index 2a0bb9ad85..dcfe957027 100644
--- a/src/plugins/qmljstools/qmljstoolssettings.cpp
+++ b/src/plugins/qmljstools/qmljstoolssettings.cpp
@@ -44,7 +44,7 @@ namespace QmlJSTools {
const char idKey[] = "QmlJSGlobal";
-static SimpleCodeStylePreferences *m_globalCodeStyle = 0;
+static SimpleCodeStylePreferences *m_globalCodeStyle = nullptr;
QmlJSToolsSettings::QmlJSToolsSettings()
{
@@ -55,7 +55,7 @@ QmlJSToolsSettings::QmlJSToolsSettings()
TextEditorSettings::registerCodeStyleFactory(factory);
// code style pool
- CodeStylePool *pool = new CodeStylePool(factory, this);
+ auto pool = new CodeStylePool(factory, this);
TextEditorSettings::registerCodeStylePool(Constants::QML_JS_SETTINGS_ID, pool);
// global code style settings
@@ -68,7 +68,7 @@ QmlJSToolsSettings::QmlJSToolsSettings()
// built-in settings
// Qt style
- SimpleCodeStylePreferences *qtCodeStyle = new SimpleCodeStylePreferences();
+ auto qtCodeStyle = new SimpleCodeStylePreferences;
qtCodeStyle->setId("qt");
qtCodeStyle->setDisplayName(tr("Qt"));
qtCodeStyle->setReadOnly(true);
@@ -145,7 +145,7 @@ QmlJSToolsSettings::~QmlJSToolsSettings()
TextEditorSettings::unregisterCodeStyleFactory(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
delete m_globalCodeStyle;
- m_globalCodeStyle = 0;
+ m_globalCodeStyle = nullptr;
}
SimpleCodeStylePreferences *QmlJSToolsSettings::globalCodeStyle()
diff --git a/src/plugins/qmljstools/qmljstoolssettings.h b/src/plugins/qmljstools/qmljstoolssettings.h
index 213837d290..85521d6b5e 100644
--- a/src/plugins/qmljstools/qmljstoolssettings.h
+++ b/src/plugins/qmljstools/qmljstoolssettings.h
@@ -42,7 +42,7 @@ class QMLJSTOOLS_EXPORT QmlJSToolsSettings : public QObject
public:
explicit QmlJSToolsSettings();
- ~QmlJSToolsSettings();
+ ~QmlJSToolsSettings() override;
static TextEditor::SimpleCodeStylePreferences *globalCodeStyle();
};