diff options
Diffstat (limited to 'src/plugins/cppeditor')
-rw-r--r-- | src/plugins/cppeditor/CMakeLists.txt | 47 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppcodemodelinspectordialog.cpp | 9 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditordocument.cpp | 4 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditordocument.h | 2 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditorplugin.cpp | 7 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditorplugin.h | 2 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditorwidget.cpp | 4 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppoutline.cpp | 1 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppoutline.h | 1 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppparsecontext.cpp | 8 | ||||
-rw-r--r-- | src/plugins/cppeditor/cpppreprocessordialog.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 17 | ||||
-rw-r--r-- | src/plugins/cppeditor/resourcepreviewhoverhandler.cpp | 4 |
13 files changed, 78 insertions, 30 deletions
diff --git a/src/plugins/cppeditor/CMakeLists.txt b/src/plugins/cppeditor/CMakeLists.txt new file mode 100644 index 0000000000..d2072fa5ba --- /dev/null +++ b/src/plugins/cppeditor/CMakeLists.txt @@ -0,0 +1,47 @@ +add_qtc_plugin(CppEditor + DEFINES CPPEDITOR_LIBRARY + PLUGIN_DEPENDS Core CppTools ProjectExplorer TextEditor + SOURCES + cppautocompleter.cpp cppautocompleter.h + cppcodemodelinspectordialog.cpp cppcodemodelinspectordialog.h cppcodemodelinspectordialog.ui + cppdocumentationcommenthelper.cpp cppdocumentationcommenthelper.h + cppeditor.cpp cppeditor.h + cppeditor.qrc + cppeditor_global.h + cppeditorconstants.h + cppeditordocument.cpp cppeditordocument.h + cppeditorenums.h + cppeditorplugin.cpp cppeditorplugin.h + cppeditorwidget.cpp cppeditorwidget.h + cppfunctiondecldeflink.cpp cppfunctiondecldeflink.h + cpphighlighter.cpp cpphighlighter.h + cppincludehierarchy.cpp cppincludehierarchy.h + cppinsertvirtualmethods.cpp cppinsertvirtualmethods.h + cpplocalrenaming.cpp cpplocalrenaming.h + cppminimizableinfobars.cpp cppminimizableinfobars.h + cppoutline.cpp cppoutline.h + cppparsecontext.cpp cppparsecontext.h + cpppreprocessordialog.cpp cpppreprocessordialog.h cpppreprocessordialog.ui + cppquickfix.cpp cppquickfix.h + cppquickfixassistant.cpp cppquickfixassistant.h + cppquickfixes.cpp cppquickfixes.h + cpptypehierarchy.cpp cpptypehierarchy.h + cppuseselectionsupdater.cpp cppuseselectionsupdater.h + resourcepreviewhoverhandler.cpp resourcepreviewhoverhandler.h + EXPLICIT_MOC cppeditor.h +) + +extend_qtc_plugin(CppEditor + CONDITION WITH_TESTS + SOURCES + cppdoxygen_test.cpp cppdoxygen_test.h + cppeditortestcase.cpp cppeditortestcase.h + cppincludehierarchy_test.cpp + cppquickfix_test.cpp cppquickfix_test.h + cppuseselections_test.cpp + fileandtokenactions_test.cpp + followsymbol_switchmethoddecldef_test.cpp + EXPLICIT_MOC + cppdoxygen_test.h + cppquickfix_test.h +) diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp index 1cedfbfd9d..6b26cd8185 100644 --- a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp +++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp @@ -1254,7 +1254,7 @@ void WorkingCopyModel::configure(const WorkingCopy &workingCopy) { emit layoutAboutToBeChanged(); m_workingCopyList.clear(); - QHashIterator<Utils::FileName, QPair<QByteArray, unsigned> > it = workingCopy.iterator(); + QHashIterator<Utils::FilePath, QPair<QByteArray, unsigned> > it = workingCopy.iterator(); while (it.hasNext()) { it.next(); m_workingCopyList << WorkingCopyEntry(it.key().toString(), it.value().first, @@ -1389,7 +1389,7 @@ CppCodeModelInspectorDialog::CppCodeModelInspectorDialog(QWidget *parent) connect(m_snapshotView, &FilterableView::filterChanged, this, &CppCodeModelInspectorDialog::onSnapshotFilterChanged); connect(m_ui->snapshotSelector, - static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CppCodeModelInspectorDialog::onSnapshotSelected); connect(m_ui->docSymbolsView, &QTreeView::expanded, this, &CppCodeModelInspectorDialog::onSymbolsViewExpandedOrCollapsed); @@ -1806,11 +1806,14 @@ void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr & {QString::fromLatin1("Project Part File"), part->projectFileLocation()}, {QString::fromLatin1("Project Name"), projectName}, {QString::fromLatin1("Project File"), projectFilePath}, - {QString::fromLatin1("Buildsystem Target"), buildSystemTarget}, {QString::fromLatin1("Callgroup Id"), callGroupId}, {QString::fromLatin1("Precompiled Headers"), precompiledHeaders}, {QString::fromLatin1("Selected For Building"), CMI::Utils::toString(part->selectedForBuilding)}, + {QString::fromLatin1("Buildsystem Target"), buildSystemTarget}, {QString::fromLatin1("Build Target Type"), CMI::Utils::toString(part->buildTargetType)}, + {QString::fromLatin1("ToolChain Type"), part->toolchainType.toString()}, + {QString::fromLatin1("ToolChain Target Triple"), part->toolChainTargetTriple}, + {QString::fromLatin1("ToolChain Word Width"), CMI::Utils::toString(part->toolChainWordWidth)}, {QString::fromLatin1("Language Version"), CMI::Utils::toString(part->languageVersion)}, {QString::fromLatin1("Language Extensions"), CMI::Utils::toString(part->languageExtensions)}, {QString::fromLatin1("Qt Version"), CMI::Utils::toString(part->qtVersion)} diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp index 85c10e8f0c..f09e3807d3 100644 --- a/src/plugins/cppeditor/cppeditordocument.cpp +++ b/src/plugins/cppeditor/cppeditordocument.cpp @@ -238,8 +238,8 @@ void CppEditorDocument::reparseWithPreferredParseContext(const QString &parseCon scheduleProcessDocument(); } -void CppEditorDocument::onFilePathChanged(const Utils::FileName &oldPath, - const Utils::FileName &newPath) +void CppEditorDocument::onFilePathChanged(const Utils::FilePath &oldPath, + const Utils::FilePath &newPath) { Q_UNUSED(oldPath); diff --git a/src/plugins/cppeditor/cppeditordocument.h b/src/plugins/cppeditor/cppeditordocument.h index 5055b2654a..d8fc7094aa 100644 --- a/src/plugins/cppeditor/cppeditordocument.h +++ b/src/plugins/cppeditor/cppeditordocument.h @@ -91,7 +91,7 @@ protected: private: void invalidateFormatterCache(); - void onFilePathChanged(const Utils::FileName &oldPath, const Utils::FileName &newPath); + void onFilePathChanged(const Utils::FilePath &oldPath, const Utils::FilePath &newPath); void onMimeTypeChanged(); void onAboutToReload(); diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index f46c3db17d..bb73272446 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -27,6 +27,7 @@ #include "cppautocompleter.h" #include "cppcodemodelinspectordialog.h" +#include "cppeditor.h" #include "cppeditorconstants.h" #include "cppeditorwidget.h" #include "cppeditordocument.h" @@ -370,11 +371,9 @@ void CppEditorPluginPrivate::inspectCppCodeModel() } #ifdef WITH_TESTS -QList<QObject *> CppEditorPlugin::createTestObjects() const +QVector<QObject *> CppEditorPlugin::createTestObjects() const { - return QList<QObject *>() - << new Tests::DoxygenTest - ; + return {new Tests::DoxygenTest}; } #endif diff --git a/src/plugins/cppeditor/cppeditorplugin.h b/src/plugins/cppeditor/cppeditorplugin.h index f4d024f33f..40b251fbef 100644 --- a/src/plugins/cppeditor/cppeditorplugin.h +++ b/src/plugins/cppeditor/cppeditorplugin.h @@ -64,7 +64,7 @@ public: #ifdef WITH_TESTS private: - QList<QObject *> createTestObjects() const override; + QVector<QObject *> createTestObjects() const override; private slots: // The following tests expect that no projects are loaded on start-up. diff --git a/src/plugins/cppeditor/cppeditorwidget.cpp b/src/plugins/cppeditor/cppeditorwidget.cpp index df37a22d29..e55ac8a665 100644 --- a/src/plugins/cppeditor/cppeditorwidget.cpp +++ b/src/plugins/cppeditor/cppeditorwidget.cpp @@ -516,7 +516,7 @@ bool CppEditorWidget::isWidgetHighlighted(QWidget *widget) namespace { QList<ProjectPart::Ptr> fetchProjectParts(CppTools::CppModelManager *modelManager, - const Utils::FileName &filePath) + const Utils::FilePath &filePath) { QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath); @@ -734,7 +734,7 @@ void CppEditorWidget::findLinkAt(const QTextCursor &cursor, if (!d->m_modelManager) return processLinkCallback(Utils::Link()); - const Utils::FileName &filePath = textDocument()->filePath(); + const Utils::FilePath &filePath = textDocument()->filePath(); followSymbolInterface().findLink(CppTools::CursorInEditor{cursor, filePath, this}, std::move(processLinkCallback), diff --git a/src/plugins/cppeditor/cppoutline.cpp b/src/plugins/cppeditor/cppoutline.cpp index 4f34433ba4..55a2e93f19 100644 --- a/src/plugins/cppeditor/cppoutline.cpp +++ b/src/plugins/cppeditor/cppoutline.cpp @@ -25,6 +25,7 @@ #include "cppoutline.h" +#include "cppeditor.h" #include <cpptools/cppeditoroutline.h> #include <cpptools/cppoverviewmodel.h> diff --git a/src/plugins/cppeditor/cppoutline.h b/src/plugins/cppeditor/cppoutline.h index f8db92c46d..9cabc48aa5 100644 --- a/src/plugins/cppeditor/cppoutline.h +++ b/src/plugins/cppeditor/cppoutline.h @@ -25,7 +25,6 @@ #pragma once -#include "cppeditor.h" #include "cppeditorwidget.h" #include <texteditor/ioutlinewidget.h> diff --git a/src/plugins/cppeditor/cppparsecontext.cpp b/src/plugins/cppeditor/cppparsecontext.cpp index ef941f44d2..521cc49328 100644 --- a/src/plugins/cppeditor/cppparsecontext.cpp +++ b/src/plugins/cppeditor/cppparsecontext.cpp @@ -111,14 +111,16 @@ QString ParseContextModel::currentId() const return m_projectParts[m_currentIndex]->id(); } -int ParseContextModel::rowCount(const QModelIndex &) const +int ParseContextModel::rowCount(const QModelIndex &parent) const { + if (parent.isValid()) + return 0; return m_projectParts.size(); } QVariant ParseContextModel::data(const QModelIndex &index, int role) const { - if (m_projectParts.isEmpty()) + if (!index.isValid() || index.row() < 0 || index.row() >= m_projectParts.size()) return QVariant(); const int row = index.row(); @@ -149,7 +151,7 @@ ParseContextWidget::ParseContextWidget(ParseContextModel &parseContextModel, QWi // Set up sync of this widget and model in both directions connect(this, - static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), + QOverload<int>::of(&QComboBox::activated), &m_parseContextModel, &ParseContextModel::setPreferred); connect(&m_parseContextModel, &ParseContextModel::updated, diff --git a/src/plugins/cppeditor/cpppreprocessordialog.cpp b/src/plugins/cppeditor/cpppreprocessordialog.cpp index f66ee92a89..b0edff0fc0 100644 --- a/src/plugins/cppeditor/cpppreprocessordialog.cpp +++ b/src/plugins/cppeditor/cpppreprocessordialog.cpp @@ -42,7 +42,7 @@ CppPreProcessorDialog::CppPreProcessorDialog(const QString &filePath, QWidget *p setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_ui->setupUi(this); - m_ui->editorLabel->setText(m_ui->editorLabel->text().arg(Utils::FileName::fromString(m_filePath).fileName())); + m_ui->editorLabel->setText(m_ui->editorLabel->text().arg(Utils::FilePath::fromString(m_filePath).fileName())); m_ui->editWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); CppEditor::decorateEditor(m_ui->editWidget); diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index c17850662f..538c9242b8 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -1510,8 +1510,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi 0x20 */ - QString replacement; - replacement.sprintf("0x%lX", value); + const QString replacement = QString::asprintf("0x%lX", value); auto op = new ConvertNumericLiteralOp(interface, start, start + numberLength, replacement); op->setDescription(QApplication::translate("CppTools::QuickFix", "Convert to Hexadecimal")); op->setPriority(priority); @@ -1528,8 +1527,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi With 040 */ - QString replacement; - replacement.sprintf("0%lo", value); + const QString replacement = QString::asprintf("0%lo", value); auto op = new ConvertNumericLiteralOp(interface, start, start + numberLength, replacement); op->setDescription(QApplication::translate("CppTools::QuickFix", "Convert to Octal")); op->setPriority(priority); @@ -1546,8 +1544,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi With 32 */ - QString replacement; - replacement.sprintf("%lu", value); + const QString replacement = QString::asprintf("%lu", value); auto op = new ConvertNumericLiteralOp(interface, start, start + numberLength, replacement); op->setDescription(QApplication::translate("CppTools::QuickFix", "Convert to Decimal")); op->setPriority(priority); @@ -1973,16 +1970,16 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa Snapshot localForwardHeaders = forwardHeaders; localForwardHeaders.insert(interface.snapshot().document(info->fileName())); - Utils::FileNameList headerAndItsForwardingHeaders; - headerAndItsForwardingHeaders << Utils::FileName::fromString(info->fileName()); + Utils::FilePathList headerAndItsForwardingHeaders; + headerAndItsForwardingHeaders << Utils::FilePath::fromString(info->fileName()); headerAndItsForwardingHeaders += localForwardHeaders.filesDependingOn(info->fileName()); - foreach (const Utils::FileName &header, headerAndItsForwardingHeaders) { + foreach (const Utils::FilePath &header, headerAndItsForwardingHeaders) { const QString include = findShortestInclude(currentDocumentFilePath, header.toString(), headerPaths); if (include.size() > 2) { - const QString headerFileName = Utils::FileName::fromString(info->fileName()).fileName(); + const QString headerFileName = Utils::FilePath::fromString(info->fileName()).fileName(); QTC_ASSERT(!headerFileName.isEmpty(), break); int priority = 0; diff --git a/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp b/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp index 72fb74f087..082c04493d 100644 --- a/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp +++ b/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp @@ -143,8 +143,8 @@ static QString findResourceInProject(const QString &resName) return QString(); if (auto *project = ProjectExplorer::ProjectTree::currentProject()) { - const Utils::FileNameList files = project->files(ProjectExplorer::Project::AllFiles); - for (const Utils::FileName &file : files) { + const Utils::FilePathList files = project->files(ProjectExplorer::Project::AllFiles); + for (const Utils::FilePath &file : files) { if (!file.endsWith(".qrc")) continue; const QFileInfo fi = file.toFileInfo(); |