Commit c4a0f90e authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppEditor: Introduce C++ Code Model Inspector

By default invokable via Ctrl+Shift+F12.

Change-Id: If8d61233b6d38d12131718f7c20bf40f76bc9ae4
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 7f829b26
......@@ -808,6 +808,11 @@ Symbol **Control::lastSymbol() const
return &*d->symbols.begin() + d->symbols.size();
}
unsigned Control::symbolCount() const
{
return unsigned(d->symbols.size());
}
bool Control::hasSymbol(Symbol *symbol) const
{
return std::find(d->symbols.begin(), d->symbols.end(), symbol) != d->symbols.end();
......
......@@ -213,6 +213,7 @@ public:
Symbol **firstSymbol() const;
Symbol **lastSymbol() const;
unsigned symbolCount() const;
bool hasSymbol(Symbol *symbol) const;
void addSymbol(Symbol *symbol);
......
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CPPCODEMODELINSPECTORDIALOG_H
#define CPPCODEMODELINSPECTORDIALOG_H
#include <cpptools/cppmodelmanagerinterface.h>
#include <cplusplus/CppDocument.h>
#include <QDialog>
#include <QList>
QT_BEGIN_NAMESPACE
class QSortFilterProxyModel;
class QModelIndex;
namespace Ui { class CppCodeModelInspectorDialog; }
QT_END_NAMESPACE
namespace CppEditor {
namespace Internal {
class FilterableView;
class SnapshotInfo;
class DiagnosticMessagesModel;
class IncludesModel;
class KeyValueModel;
class MacrosModel;
class ProjectPartsModel;
class SnapshotModel;
class SymbolsModel;
class TokensModel;
class WorkingCopyModel;
//
// This dialog is for DEBUGGING PURPOSES and thus NOT TRANSLATED.
//
class CppCodeModelInspectorDialog : public QDialog
{
Q_OBJECT
public:
explicit CppCodeModelInspectorDialog(QWidget *parent = 0);
~CppCodeModelInspectorDialog();
private slots:
void onRefreshRequested();
void onSnapshotFilterChanged(const QString &pattern);
void onSnapshotSelected(int row);
void onDocumentSelected(const QModelIndex &current, const QModelIndex &);
void onSymbolsViewExpandedOrCollapsed(const QModelIndex &);
void onProjectPartFilterChanged(const QString &pattern);
void onProjectPartSelected(const QModelIndex &current, const QModelIndex &);
void onWorkingCopyFilterChanged(const QString &pattern);
void onWorkingCopyDocumentSelected(const QModelIndex &current, const QModelIndex &);
private:
void refresh();
void clearDocumentData();
void updateDocumentData(const CPlusPlus::Document::Ptr &document);
void clearProjectPartData();
void updateProjectPartData(const CppTools::ProjectPart::Ptr &part);
bool event(QEvent *e);
private:
Ui::CppCodeModelInspectorDialog *m_ui;
// Snapshots and Documents
QList<SnapshotInfo> *m_snapshotInfos;
FilterableView *m_snapshotView;
SnapshotModel *m_snapshotModel;
QSortFilterProxyModel *m_proxySnapshotModel;
KeyValueModel *m_docGenericInfoModel;
IncludesModel *m_docIncludesModel;
DiagnosticMessagesModel *m_docDiagnosticMessagesModel;
MacrosModel *m_docMacrosModel;
SymbolsModel *m_docSymbolsModel;
TokensModel *m_docTokensModel;
// Project Parts
FilterableView *m_projectPartsView;
ProjectPartsModel *m_projectPartsModel;
QSortFilterProxyModel *m_proxyProjectPartsModel;
KeyValueModel *m_partGenericInfoModel;
// Working Copy
FilterableView *m_workingCopyView;
WorkingCopyModel *m_workingCopyModel;
QSortFilterProxyModel *m_proxyWorkingCopyModel;
};
} // namespace Internal
} // namespace CppEditor
#endif // CPPCODEMODELINSPECTORDIALOG_H
This diff is collapsed.
......@@ -4,6 +4,7 @@ include(../../qtcreatorplugin.pri)
HEADERS += \
cppautocompleter.h \
cppclasswizard.h \
cppcodemodelinspectordialog.h \
cppeditor.h \
cppeditor_global.h \
cppeditorconstants.h \
......@@ -33,6 +34,7 @@ HEADERS += \
SOURCES += \
cppautocompleter.cpp \
cppclasswizard.cpp \
cppcodemodelinspectordialog.cpp \
cppeditor.cpp \
cppeditorplugin.cpp \
cppelementevaluator.cpp \
......@@ -57,7 +59,8 @@ SOURCES += \
cppvirtualfunctionproposalitem.cpp
FORMS += \
cpppreprocessordialog.ui
cpppreprocessordialog.ui \
cppcodemodelinspectordialog.ui
RESOURCES += \
cppeditor.qrc
......@@ -74,4 +77,3 @@ equals(TEST, 1) {
followsymbol_switchmethoddecldef_test.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
......@@ -16,6 +16,7 @@ QtcPlugin {
files: [
"cppautocompleter.cpp", "cppautocompleter.h",
"cppclasswizard.cpp", "cppclasswizard.h",
"cppcodemodelinspectordialog.cpp", "cppcodemodelinspectordialog.h", "cppcodemodelinspectordialog.ui",
"cppeditor.cpp", "cppeditor.h",
"cppeditor.qrc",
"cppeditor_global.h",
......
......@@ -44,6 +44,7 @@ const char FIND_USAGES[] = "CppEditor.FindUsages";
const char OPEN_PREPROCESSOR_DIALOG[] = "CppEditor.OpenPreprocessorDialog";
const char M_REFACTORING_MENU_INSERTION_POINT[] = "CppEditor.RefactorGroup";
const char UPDATE_CODEMODEL[] = "CppEditor.UpdateCodeModel";
const char INSPECT_CPP_CODEMODEL[] = "CppEditor.InspectCppCodeModel";
const int TYPE_HIERARCHY_PRIORITY = 700;
const char TYPE_HIERARCHY_ID[] = "CppEditor.TypeHierarchy";
......
......@@ -42,6 +42,8 @@
#include "cppquickfixes.h"
#include "cpphighlighterfactory.h"
#include "cppcodemodelinspectordialog.h"
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/coreconstants.h>
......@@ -285,6 +287,11 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
connect(m_reparseExternallyChangedFiles, SIGNAL(triggered()), cppModelManager, SLOT(updateModifiedSourceFiles()));
cppToolsMenu->addAction(cmd);
QAction *inspectCppCodeModel = new QAction(tr("Debug: Inspect C++ Code Model"), this);
cmd = ActionManager::registerAction(inspectCppCodeModel, Constants::INSPECT_CPP_CODEMODEL, globalContext);
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+F12") : tr("Ctrl+Shift+F12")));
connect(inspectCppCodeModel, SIGNAL(triggered()), this, SLOT(inspectCppCodeModel()));
m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection
......@@ -387,6 +394,16 @@ void CppEditorPlugin::onAllTasksFinished(Core::Id type)
}
}
void CppEditorPlugin::inspectCppCodeModel()
{
if (m_cppCodeModelInspectorDialog) {
ICore::raiseWindow(m_cppCodeModelInspectorDialog);
} else {
m_cppCodeModelInspectorDialog = new CppCodeModelInspectorDialog(ICore::mainWindow());
m_cppCodeModelInspectorDialog->show();
}
}
void CppEditorPlugin::openTypeHierarchy()
{
if (currentCppEditorWidget()) {
......
......@@ -46,6 +46,7 @@ namespace CppEditor {
namespace Internal {
class CPPEditorWidget;
class CppCodeModelInspectorDialog;
class CppQuickFixCollector;
class CppQuickFixAssistProvider;
......@@ -90,6 +91,7 @@ public slots:
private slots:
void onTaskStarted(Core::Id type);
void onAllTasksFinished(Core::Id type);
void inspectCppCodeModel();
#ifdef WITH_TESTS
private slots:
......@@ -242,6 +244,8 @@ private:
CppQuickFixAssistProvider *m_quickFixProvider;
QPointer<CppCodeModelInspectorDialog> m_cppCodeModelInspectorDialog;
QPointer<TextEditor::ITextEditor> m_currentEditor;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment