forked from qt-creator/qt-creator
CppEditor: Modernize
modernize-orgad modernize-return-braced-init-list modernize-use-auto modernize-use-default-member-init modernize-use-equals-default modernize-use-nullptr modernize-use-override modernize-use-using Change-Id: Ifa862782fb7b56ed3f93d9f98685c3af616797c2 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -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,
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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()
|
||||
|
@@ -40,7 +40,7 @@ class CppEditorPlugin : public ExtensionSystem::IPlugin
|
||||
|
||||
public:
|
||||
CppEditorPlugin();
|
||||
~CppEditorPlugin();
|
||||
~CppEditorPlugin() override;
|
||||
|
||||
static CppEditorPlugin *instance();
|
||||
|
||||
|
@@ -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,8 +665,8 @@ 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());
|
||||
@@ -998,7 +995,7 @@ AssistInterface *CppEditorWidget::createAssistInterface(AssistKind kind, AssistR
|
||||
} else {
|
||||
return TextEditorWidget::createAssistInterface(kind, reason);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QSharedPointer<FunctionDeclDefLink> CppEditorWidget::declDefLink() const
|
||||
|
@@ -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();
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -39,5 +39,4 @@ CppQuickFixOperation::CppQuickFixOperation(const CppQuickFixInterface &interface
|
||||
: QuickFixOperation(priority), CppQuickFixInterface(interface)
|
||||
{}
|
||||
|
||||
CppQuickFixOperation::~CppQuickFixOperation()
|
||||
{}
|
||||
CppQuickFixOperation::~CppQuickFixOperation() = default;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace CppTools {
|
||||
class CppRefactoringFile;
|
||||
typedef QSharedPointer<CppRefactoringFile> CppRefactoringFilePtr;
|
||||
using CppRefactoringFilePtr = QSharedPointer<CppRefactoringFile>;
|
||||
}
|
||||
|
||||
namespace CppEditor {
|
||||
|
@@ -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());
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -3963,7 +3938,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
void perform()
|
||||
void perform() override
|
||||
{
|
||||
FunctionDeclaratorAST *functionDeclaratorOfDefinition
|
||||
= functionDeclarator(m_functionDefinition);
|
||||
@@ -4043,7 +4018,7 @@ private:
|
||||
if (functionDeclaratorAST)
|
||||
return functionDeclaratorAST;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FunctionDeclaratorAST *functionDeclarator(DeclaratorAST *ast) const
|
||||
@@ -4053,7 +4028,7 @@ private:
|
||||
if (funcdecl)
|
||||
return funcdecl;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FunctionDeclaratorAST *functionDeclarator(FunctionDefinitionAST *ast) const
|
||||
@@ -4197,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
|
||||
@@ -4403,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;
|
||||
@@ -4426,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;
|
||||
@@ -4499,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());
|
||||
@@ -4601,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)
|
||||
@@ -4673,7 +4648,7 @@ public:
|
||||
, m_link(link)
|
||||
{}
|
||||
|
||||
void perform()
|
||||
void perform() override
|
||||
{
|
||||
if (editor()->declDefLink() == m_link)
|
||||
editor()->applyDeclDefLinkChanges(/*don't jump*/false);
|
||||
@@ -4840,7 +4815,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void perform()
|
||||
void perform() override
|
||||
{
|
||||
MoveFuncDefRefactoringHelper helper(this, m_type, m_headerFileName, m_cppFileName);
|
||||
helper.performMove(m_funcDef);
|
||||
@@ -4859,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();
|
||||
@@ -4883,7 +4858,7 @@ void MoveFuncDefOutside::match(const CppQuickFixInterface &interface, QuickFixOp
|
||||
break;
|
||||
}
|
||||
}
|
||||
funcAST = 0;
|
||||
funcAST = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4933,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) {
|
||||
@@ -5024,7 +4999,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void perform()
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr fromFile = refactoring.file(m_fromFileName);
|
||||
@@ -5065,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) {
|
||||
@@ -5082,7 +5057,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
|
||||
completeDefAST = enclosingAST->asTemplateDeclaration() ? enclosingAST : funcAST;
|
||||
break;
|
||||
}
|
||||
funcAST = 0;
|
||||
funcAST = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5196,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());
|
||||
@@ -5271,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()) {
|
||||
@@ -5404,7 +5379,7 @@ public:
|
||||
setDescription(QApplication::translate("CppTools::QuickFix", "Optimize for-Loop"));
|
||||
}
|
||||
|
||||
void perform()
|
||||
void perform() override
|
||||
{
|
||||
QTC_ASSERT(m_forAst, return);
|
||||
|
||||
@@ -5491,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))
|
||||
@@ -5511,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
|
||||
@@ -5563,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);
|
||||
}
|
||||
}
|
||||
@@ -5661,7 +5636,7 @@ private:
|
||||
|
||||
// QuickFixOperation interface
|
||||
public:
|
||||
void perform()
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
|
||||
@@ -5748,7 +5723,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void perform()
|
||||
void perform() override
|
||||
{
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(fileName());
|
||||
@@ -5766,7 +5741,7 @@ Symbol *skipForwardDeclarations(const QList<Symbol *> &symbols)
|
||||
return symbol;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool findRawAccessFunction(Class *klass, PointerType *pointerType, QString *objAccessFunction)
|
||||
@@ -5784,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;
|
||||
@@ -5811,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()) {
|
||||
@@ -5830,7 +5805,7 @@ PointerType *determineConvertedType(NamedType *namedType, const LookupContext &c
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Class *senderOrReceiverClass(const CppQuickFixInterface &interface,
|
||||
@@ -5852,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();
|
||||
}
|
||||
@@ -5992,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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -44,7 +44,7 @@ class CppUseSelectionsUpdater : public QObject
|
||||
|
||||
public:
|
||||
explicit CppUseSelectionsUpdater(TextEditor::TextEditorWidget *editorWidget);
|
||||
~CppUseSelectionsUpdater();
|
||||
~CppUseSelectionsUpdater() override;
|
||||
|
||||
void scheduleUpdate();
|
||||
void abortSchedule();
|
||||
|
Reference in New Issue
Block a user