forked from qt-creator/qt-creator
CppEditor: Clean up CppEditor/CppEditorWidget
* Excess includes and forward declarations * Access protection levels * QTC_OVERRIDE * Remove declared but not implemented/used functions. * Remove unused class Change-Id: Ia19ddddccd9adde827a7875b466fde5ca4d96e7d Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -72,12 +72,10 @@
|
|||||||
#include <cplusplus/OverviewModel.h>
|
#include <cplusplus/OverviewModel.h>
|
||||||
#include <cplusplus/BackwardsScanner.h>
|
#include <cplusplus/BackwardsScanner.h>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QHeaderView>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
@@ -120,46 +118,9 @@ private:
|
|||||||
CPlusPlus::OverviewModel *m_sourceModel;
|
CPlusPlus::OverviewModel *m_sourceModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FindFunctionDefinitions: protected SymbolVisitor
|
class CanonicalSymbol
|
||||||
{
|
{
|
||||||
const Name *_declarationName;
|
|
||||||
QList<Function *> *_functions;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FindFunctionDefinitions()
|
|
||||||
: _declarationName(0),
|
|
||||||
_functions(0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
void operator()(const Name *declarationName, Scope *globals,
|
|
||||||
QList<Function *> *functions)
|
|
||||||
{
|
|
||||||
_declarationName = declarationName;
|
|
||||||
_functions = functions;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < globals->memberCount(); ++i) {
|
|
||||||
accept(globals->memberAt(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
using SymbolVisitor::visit;
|
|
||||||
|
|
||||||
virtual bool visit(Function *function)
|
|
||||||
{
|
|
||||||
const Name *name = function->name();
|
|
||||||
if (const QualifiedNameId *q = name->asQualifiedNameId())
|
|
||||||
name = q->name();
|
|
||||||
|
|
||||||
if (_declarationName->match(name))
|
|
||||||
_functions->append(function);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CanonicalSymbol
|
|
||||||
{
|
|
||||||
CPPEditorWidget *editor;
|
CPPEditorWidget *editor;
|
||||||
TypeOfExpression typeOfExpression;
|
TypeOfExpression typeOfExpression;
|
||||||
SemanticInfo info;
|
SemanticInfo info;
|
||||||
|
|||||||
@@ -36,19 +36,14 @@
|
|||||||
#include <cpptools/commentssettings.h>
|
#include <cpptools/commentssettings.h>
|
||||||
#include <cpptools/cppsemanticinfo.h>
|
#include <cpptools/cppsemanticinfo.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
|
||||||
|
|
||||||
|
#include <utils/qtcoverride.h>
|
||||||
#include <utils/uncommentselection.h>
|
#include <utils/uncommentselection.h>
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QMutex>
|
|
||||||
#include <QThread>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QWaitCondition>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QComboBox;
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@@ -58,13 +53,6 @@ class OverviewModel;
|
|||||||
class Symbol;
|
class Symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CppTools {
|
|
||||||
class CppCodeStyleSettings;
|
|
||||||
class CppModelManagerInterface;
|
|
||||||
class CppRefactoringFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace TextEditor { class FontSettings; }
|
|
||||||
namespace Utils { class TreeViewComboBox; }
|
namespace Utils { class TreeViewComboBox; }
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
@@ -97,12 +85,14 @@ class CPPEditor : public TextEditor::BaseTextEditor
|
|||||||
public:
|
public:
|
||||||
CPPEditor(CPPEditorWidget *);
|
CPPEditor(CPPEditorWidget *);
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate() QTC_OVERRIDE;
|
||||||
|
|
||||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
bool open(QString *errorString,
|
||||||
|
const QString &fileName,
|
||||||
|
const QString &realFileName) QTC_OVERRIDE;
|
||||||
|
|
||||||
const Utils::CommentDefinition *commentDefinition() const;
|
const Utils::CommentDefinition *commentDefinition() const QTC_OVERRIDE;
|
||||||
TextEditor::CompletionAssistProvider *completionAssistProvider();
|
TextEditor::CompletionAssistProvider *completionAssistProvider() QTC_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utils::CommentDefinition m_commentDefinition;
|
Utils::CommentDefinition m_commentDefinition;
|
||||||
@@ -113,44 +103,39 @@ class CPPEditorWidget : public TextEditor::BaseTextEditorWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef TextEditor::TabSettings TabSettings;
|
static Link linkToSymbol(CPlusPlus::Symbol *symbol);
|
||||||
|
static QString identifierUnderCursor(QTextCursor *macroCursor);
|
||||||
|
|
||||||
|
public:
|
||||||
CPPEditorWidget(QWidget *parent = 0);
|
CPPEditorWidget(QWidget *parent = 0);
|
||||||
CPPEditorWidget(CPPEditorWidget *other);
|
CPPEditorWidget(CPPEditorWidget *other);
|
||||||
~CPPEditorWidget();
|
~CPPEditorWidget();
|
||||||
|
|
||||||
CPPEditorDocument *cppEditorDocument() const;
|
CPPEditorDocument *cppEditorDocument() const;
|
||||||
|
|
||||||
void unCommentSelection();
|
|
||||||
|
|
||||||
unsigned editorRevision() const;
|
|
||||||
bool isOutdated() const;
|
|
||||||
CppTools::SemanticInfo semanticInfo() const;
|
CppTools::SemanticInfo semanticInfo() const;
|
||||||
|
|
||||||
CPlusPlus::OverviewModel *outlineModel() const;
|
CPlusPlus::OverviewModel *outlineModel() const;
|
||||||
QModelIndex outlineModelIndex();
|
QModelIndex outlineModelIndex();
|
||||||
|
|
||||||
virtual void paste(); // reimplemented from BaseTextEditorWidget
|
|
||||||
virtual void cut(); // reimplemented from BaseTextEditorWidget
|
|
||||||
virtual void selectAll(); // reimplemented from BaseTextEditorWidget
|
|
||||||
|
|
||||||
bool openLink(const Link &link, bool inNextSplit) { return openCppEditorAt(link, inNextSplit); }
|
|
||||||
|
|
||||||
static Link linkToSymbol(CPlusPlus::Symbol *symbol);
|
|
||||||
static QString identifierUnderCursor(QTextCursor *macroCursor);
|
|
||||||
|
|
||||||
virtual TextEditor::IAssistInterface *createAssistInterface(TextEditor::AssistKind kind,
|
|
||||||
TextEditor::AssistReason reason) const;
|
|
||||||
|
|
||||||
QSharedPointer<FunctionDeclDefLink> declDefLink() const;
|
QSharedPointer<FunctionDeclDefLink> declDefLink() const;
|
||||||
void applyDeclDefLinkChanges(bool jumpToMatch);
|
void applyDeclDefLinkChanges(bool jumpToMatch);
|
||||||
|
|
||||||
|
TextEditor::IAssistInterface *createAssistInterface(
|
||||||
|
TextEditor::AssistKind kind,
|
||||||
|
TextEditor::AssistReason reason) const QTC_OVERRIDE;
|
||||||
|
|
||||||
FollowSymbolUnderCursor *followSymbolUnderCursorDelegate(); // exposed for tests
|
FollowSymbolUnderCursor *followSymbolUnderCursorDelegate(); // exposed for tests
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void outlineModelIndexChanged(const QModelIndex &index);
|
void outlineModelIndexChanged(const QModelIndex &index);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void paste() QTC_OVERRIDE;
|
||||||
|
void cut() QTC_OVERRIDE;
|
||||||
|
void selectAll() QTC_OVERRIDE;
|
||||||
|
|
||||||
|
void unCommentSelection() QTC_OVERRIDE;
|
||||||
void setSortedOutline(bool sort);
|
void setSortedOutline(bool sort);
|
||||||
void switchDeclarationDefinition(bool inNextSplit);
|
void switchDeclarationDefinition(bool inNextSplit);
|
||||||
void renameSymbolUnderCursor();
|
void renameSymbolUnderCursor();
|
||||||
@@ -163,17 +148,20 @@ public slots:
|
|||||||
unsigned revision);
|
unsigned revision);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *e);
|
bool event(QEvent *e) QTC_OVERRIDE;
|
||||||
void contextMenuEvent(QContextMenuEvent *);
|
void contextMenuEvent(QContextMenuEvent *) QTC_OVERRIDE;
|
||||||
void keyPressEvent(QKeyEvent *e);
|
void keyPressEvent(QKeyEvent *e) QTC_OVERRIDE;
|
||||||
|
|
||||||
void applyFontSettings();
|
void applyFontSettings() QTC_OVERRIDE;
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
TextEditor::BaseTextEditor *createEditor() QTC_OVERRIDE;
|
||||||
|
|
||||||
|
bool openLink(const Link &link, bool inNextSplit) QTC_OVERRIDE
|
||||||
|
{ return openCppEditorAt(link, inNextSplit); }
|
||||||
|
|
||||||
const CPlusPlus::Macro *findCanonicalMacro(const QTextCursor &cursor,
|
const CPlusPlus::Macro *findCanonicalMacro(const QTextCursor &cursor,
|
||||||
CPlusPlus::Document::Ptr doc) const;
|
CPlusPlus::Document::Ptr doc) const;
|
||||||
protected slots:
|
protected slots:
|
||||||
void slotCodeStyleSettingsChanged(const QVariant &);
|
void slotCodeStyleSettingsChanged(const QVariant &) QTC_OVERRIDE;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void jumpToOutlineElement();
|
void jumpToOutlineElement();
|
||||||
@@ -206,12 +194,13 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
CPPEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
|
CPPEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
|
||||||
void ctor();
|
void ctor();
|
||||||
|
|
||||||
|
unsigned editorRevision() const;
|
||||||
|
bool isOutdated() const;
|
||||||
|
|
||||||
void markSymbols(const QTextCursor &tc, const CppTools::SemanticInfo &info);
|
void markSymbols(const QTextCursor &tc, const CppTools::SemanticInfo &info);
|
||||||
bool sortedOutline() const;
|
bool sortedOutline() const;
|
||||||
|
|
||||||
TextEditor::ITextEditor *openCppEditorAt(const QString &fileName, int line,
|
|
||||||
int column = 0);
|
|
||||||
|
|
||||||
void highlightUses(const QList<TextEditor::HighlightingResult> &uses,
|
void highlightUses(const QList<TextEditor::HighlightingResult> &uses,
|
||||||
QList<QTextEdit::ExtraSelection> *selections);
|
QList<QTextEdit::ExtraSelection> *selections);
|
||||||
|
|
||||||
@@ -223,7 +212,8 @@ private:
|
|||||||
|
|
||||||
Q_SLOT void abortDeclDefLink();
|
Q_SLOT void abortDeclDefLink();
|
||||||
|
|
||||||
Link findLinkAt(const QTextCursor &, bool resolveTarget = true, bool inNextSplit = false);
|
Link findLinkAt(const QTextCursor &, bool resolveTarget = true,
|
||||||
|
bool inNextSplit = false) QTC_OVERRIDE;
|
||||||
bool openCppEditorAt(const Link &, bool inNextSplit = false);
|
bool openCppEditorAt(const Link &, bool inNextSplit = false);
|
||||||
|
|
||||||
QModelIndex indexForPosition(int line, int column,
|
QModelIndex indexForPosition(int line, int column,
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
#include <cpptools/cpptoolsconstants.h>
|
#include <cpptools/cpptoolsconstants.h>
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
|
#include <texteditor/texteditorconstants.h>
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <cpptools/cpplocalsymbols.h>
|
#include <cpptools/cpplocalsymbols.h>
|
||||||
#include <cpptools/symbolfinder.h>
|
#include <cpptools/symbolfinder.h>
|
||||||
#include <texteditor/refactoroverlay.h>
|
#include <texteditor/refactoroverlay.h>
|
||||||
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
|
||||||
#include <cplusplus/ASTPath.h>
|
#include <cplusplus/ASTPath.h>
|
||||||
#include <cplusplus/CppRewriter.h>
|
#include <cplusplus/CppRewriter.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user