forked from qt-creator/qt-creator
QmlJSTools: Modernize
modernize-* Change-Id: Ifc270455ab7500d18798ac0130744662ad3303fb Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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));
|
||||
|
@@ -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;
|
||||
};
|
||||
|
||||
|
@@ -46,8 +46,7 @@ FunctionFilter::FunctionFilter(LocatorData *data, QObject *parent)
|
||||
setIncludedByDefault(false);
|
||||
}
|
||||
|
||||
FunctionFilter::~FunctionFilter()
|
||||
{ }
|
||||
FunctionFilter::~FunctionFilter() = default;
|
||||
|
||||
void FunctionFilter::refresh(QFutureInterface<void> &)
|
||||
{
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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);
|
||||
|
@@ -39,7 +39,7 @@ class LocatorData : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
LocatorData();
|
||||
~LocatorData();
|
||||
~LocatorData() override;
|
||||
|
||||
enum EntryType
|
||||
{
|
||||
|
@@ -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)) {
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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()
|
||||
|
@@ -42,7 +42,7 @@ class QMLJSTOOLS_EXPORT QmlJSToolsSettings : public QObject
|
||||
|
||||
public:
|
||||
explicit QmlJSToolsSettings();
|
||||
~QmlJSToolsSettings();
|
||||
~QmlJSToolsSettings() override;
|
||||
|
||||
static TextEditor::SimpleCodeStylePreferences *globalCodeStyle();
|
||||
};
|
||||
|
Reference in New Issue
Block a user