CppEditor: Use BaseTextEditor{Widget} if possible

Change-Id: I59c420c6469717e552469d176bbeac3a455f3bb0
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-05-22 11:04:57 -04:00
parent 4e8b1544b7
commit e828f60c90
13 changed files with 35 additions and 34 deletions

View File

@@ -27,7 +27,6 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cppeditor.h"
#include "cppeditorplugin.h" #include "cppeditorplugin.h"
#include "cppeditortestcase.h" #include "cppeditortestcase.h"

View File

@@ -31,6 +31,8 @@
#ifndef CPPEDITORTESTCASE_H #ifndef CPPEDITORTESTCASE_H
#define CPPEDITORTESTCASE_H #define CPPEDITORTESTCASE_H
#include "cppeditor.h"
#include <cpptools/cpptoolstestcase.h> #include <cpptools/cpptoolstestcase.h>
namespace CppEditor { namespace CppEditor {

View File

@@ -29,6 +29,8 @@
#include "cppelementevaluator.h" #include "cppelementevaluator.h"
#include "cppeditor.h"
#include <cpptools/cpptoolsreuse.h> #include <cpptools/cpptoolsreuse.h>
#include <cpptools/typehierarchybuilder.h> #include <cpptools/typehierarchybuilder.h>
@@ -59,7 +61,7 @@ namespace {
} }
} }
CppElementEvaluator::CppElementEvaluator(CPPEditorWidget *editor) : CppElementEvaluator::CppElementEvaluator(TextEditor::BaseTextEditorWidget *editor) :
m_editor(editor), m_editor(editor),
m_modelManager(CppTools::CppModelManagerInterface::instance()), m_modelManager(CppTools::CppModelManagerInterface::instance()),
m_tc(editor->textCursor()), m_tc(editor->textCursor()),
@@ -262,7 +264,7 @@ CppInclude::CppInclude(const Document::Include &includeFile) :
helpCategory = TextEditor::HelpItem::Brief; helpCategory = TextEditor::HelpItem::Brief;
helpIdCandidates = QStringList(fileName); helpIdCandidates = QStringList(fileName);
helpMark = fileName; helpMark = fileName;
link = CPPEditorWidget::Link(path); link = TextEditor::BaseTextEditorWidget::Link(path);
tooltip = path; tooltip = path;
} }
@@ -273,7 +275,7 @@ CppMacro::CppMacro(const Macro &macro)
const QString macroName = QString::fromUtf8(macro.name(), macro.name().size()); const QString macroName = QString::fromUtf8(macro.name(), macro.name().size());
helpIdCandidates = QStringList(macroName); helpIdCandidates = QStringList(macroName);
helpMark = macroName; helpMark = macroName;
link = CPPEditorWidget::Link(macro.fileName(), macro.line()); link = TextEditor::BaseTextEditorWidget::Link(macro.fileName(), macro.line());
tooltip = macro.toStringWithLineBreaks(); tooltip = macro.toStringWithLineBreaks();
} }

View File

@@ -30,9 +30,8 @@
#ifndef CPPELEMENTEVALUATOR_H #ifndef CPPELEMENTEVALUATOR_H
#define CPPELEMENTEVALUATOR_H #define CPPELEMENTEVALUATOR_H
#include "cppeditor.h"
#include <cpptools/symbolfinder.h> #include <cpptools/symbolfinder.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/helpitem.h> #include <texteditor/helpitem.h>
#include <QString> #include <QString>
@@ -57,7 +56,7 @@ class CppElement;
class CppElementEvaluator class CppElementEvaluator
{ {
public: public:
explicit CppElementEvaluator(CPPEditorWidget *editor); explicit CppElementEvaluator(TextEditor::BaseTextEditorWidget *editor);
void setTextCursor(const QTextCursor &tc); void setTextCursor(const QTextCursor &tc);
void setLookupBaseClasses(const bool lookup); void setLookupBaseClasses(const bool lookup);
@@ -79,7 +78,7 @@ private:
const CPlusPlus::LookupContext &lookupContext, const CPlusPlus::LookupContext &lookupContext,
const CPlusPlus::Scope *scope); const CPlusPlus::Scope *scope);
CPPEditorWidget *m_editor; TextEditor::BaseTextEditorWidget *m_editor;
CppTools::CppModelManagerInterface *m_modelManager; CppTools::CppModelManagerInterface *m_modelManager;
QTextCursor m_tc; QTextCursor m_tc;
bool m_lookupBaseClasses; bool m_lookupBaseClasses;
@@ -100,7 +99,7 @@ public:
TextEditor::HelpItem::Category helpCategory; TextEditor::HelpItem::Category helpCategory;
QStringList helpIdCandidates; QStringList helpIdCandidates;
QString helpMark; QString helpMark;
CPPEditorWidget::Link link; TextEditor::BaseTextEditorWidget::Link link;
QString tooltip; QString tooltip;
}; };

View File

@@ -29,10 +29,13 @@
#include "cpphoverhandler.h" #include "cpphoverhandler.h"
#include "cppeditor.h" #include "cppeditorconstants.h"
#include "cppelementevaluator.h" #include "cppelementevaluator.h"
#include <coreplugin/helpmanager.h> #include <coreplugin/helpmanager.h>
#include <texteditor/basetexteditor.h>
#include <utils/qtcassert.h>
#include <QTextCursor> #include <QTextCursor>
#include <QUrl> #include <QUrl>
@@ -48,25 +51,22 @@ CppHoverHandler::~CppHoverHandler()
bool CppHoverHandler::acceptEditor(IEditor *editor) bool CppHoverHandler::acceptEditor(IEditor *editor)
{ {
CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor); return editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID;
if (cppEditor)
return true;
return false;
} }
void CppHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos) void CppHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos)
{ {
CPPEditorWidget *cppEditor = qobject_cast<CPPEditorWidget *>(editor->widget()); using namespace TextEditor;
if (!cppEditor) BaseTextEditorWidget *textEditor = qobject_cast<BaseTextEditorWidget *>(editor->widget());
return; QTC_ASSERT(textEditor, return);
if (!cppEditor->extraSelectionTooltip(pos).isEmpty()) { if (!textEditor->extraSelectionTooltip(pos).isEmpty()) {
setToolTip(cppEditor->extraSelectionTooltip(pos)); setToolTip(textEditor->extraSelectionTooltip(pos));
} else { } else {
QTextCursor tc(cppEditor->document()); QTextCursor tc(textEditor->document());
tc.setPosition(pos); tc.setPosition(pos);
CppElementEvaluator evaluator(cppEditor); CppElementEvaluator evaluator(textEditor);
evaluator.setTextCursor(tc); evaluator.setTextCursor(tc);
evaluator.execute(); evaluator.execute();
if (evaluator.hasDiagnosis()) { if (evaluator.hasDiagnosis()) {

View File

@@ -44,6 +44,7 @@ class QLabel;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Core { class IEditor; } namespace Core { class IEditor; }
namespace TextEditor { class BaseTextEditor; }
namespace Utils { namespace Utils {
class AnnotatedItemDelegate; class AnnotatedItemDelegate;
@@ -84,7 +85,7 @@ private:
Utils::AnnotatedItemDelegate *m_delegate; Utils::AnnotatedItemDelegate *m_delegate;
CppIncludeLabel *m_inspectedFile; CppIncludeLabel *m_inspectedFile;
QLabel *m_includeHierarchyInfoLabel; QLabel *m_includeHierarchyInfoLabel;
CPPEditor *m_editor; TextEditor::BaseTextEditor *m_editor;
}; };
// @todo: Pretty much the same design as the OutlineWidgetStack. Maybe we can generalize the // @todo: Pretty much the same design as the OutlineWidgetStack. Maybe we can generalize the

View File

@@ -32,7 +32,6 @@
#include "cppincludehierarchymodel.h" #include "cppincludehierarchymodel.h"
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <cppeditor/cppeditor.h>
#include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppmodelmanagerinterface.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>

View File

@@ -32,10 +32,11 @@
#include "cppincludehierarchyitem.h" #include "cppincludehierarchyitem.h"
#include <coreplugin/fileiconprovider.h> #include <coreplugin/fileiconprovider.h>
#include <cplusplus/CppDocument.h>
#include <cppeditor/cppeditor.h>
#include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cpptoolseditorsupport.h> #include <cpptools/cpptoolseditorsupport.h>
#include <texteditor/basetexteditor.h>
#include <cplusplus/CppDocument.h>
#include <QSet> #include <QSet>
@@ -138,7 +139,7 @@ QVariant CppIncludeHierarchyModel::data(const QModelIndex &index, int role) cons
return Core::FileIconProvider::icon(QFileInfo(item->filePath())); return Core::FileIconProvider::icon(QFileInfo(item->filePath()));
case LinkRole: { case LinkRole: {
QVariant itemLink; QVariant itemLink;
CPPEditorWidget::Link link(item->filePath(), item->line()); TextEditor::BaseTextEditorWidget::Link link(item->filePath(), item->line());
itemLink.setValue(link); itemLink.setValue(link);
return itemLink; return itemLink;
} }
@@ -202,7 +203,8 @@ void CppIncludeHierarchyModel::clear()
endResetModel(); endResetModel();
} }
void CppIncludeHierarchyModel::buildHierarchy(CPPEditor *editor, const QString &filePath) void CppIncludeHierarchyModel::buildHierarchy(TextEditor::BaseTextEditor *editor,
const QString &filePath)
{ {
m_editor = editor; m_editor = editor;
beginResetModel(); beginResetModel();

View File

@@ -41,7 +41,7 @@ enum ItemRole {
} // Anonymous } // Anonymous
namespace Core { class IEditor; } namespace TextEditor { class BaseTextEditor; }
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
@@ -66,7 +66,7 @@ public:
bool hasChildren(const QModelIndex &parent) const; bool hasChildren(const QModelIndex &parent) const;
void clear(); void clear();
void buildHierarchy(CPPEditor *editor, const QString &filePath); void buildHierarchy(TextEditor::BaseTextEditor *editor, const QString &filePath);
bool isEmpty() const; bool isEmpty() const;
private: private:
@@ -80,7 +80,7 @@ private:
CppIncludeHierarchyItem *m_rootItem; CppIncludeHierarchyItem *m_rootItem;
CppIncludeHierarchyItem *m_includesItem; CppIncludeHierarchyItem *m_includesItem;
CppIncludeHierarchyItem *m_includedByItem; CppIncludeHierarchyItem *m_includedByItem;
CPPEditor *m_editor; TextEditor::BaseTextEditor *m_editor;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -27,7 +27,6 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cppeditor.h"
#include "cppeditorplugin.h" #include "cppeditorplugin.h"
#include "cppeditortestcase.h" #include "cppeditortestcase.h"
#include "cppquickfixassistant.h" #include "cppquickfixassistant.h"

View File

@@ -1786,7 +1786,7 @@ public:
m_name[i] = m_name.at(i).toUpper(); m_name[i] = m_name.at(i).toUpper();
} }
} }
static_cast<CPPEditorWidget*>(assistInterface()->editor())->renameUsages(m_name); assistInterface()->editor()->renameUsages(m_name);
} }
static bool isConvertibleUnderscore(const QString &name, int pos) static bool isConvertibleUnderscore(const QString &name, int pos)

View File

@@ -30,7 +30,6 @@
#include "cppsnippetprovider.h" #include "cppsnippetprovider.h"
#include "cpphighlighter.h" #include "cpphighlighter.h"
#include "cppeditor.h"
#include "cppautocompleter.h" #include "cppautocompleter.h"
#include "cppeditorconstants.h" #include "cppeditorconstants.h"

View File

@@ -27,7 +27,6 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cppeditor.h"
#include "cppeditorplugin.h" #include "cppeditorplugin.h"
#include "cppeditortestcase.h" #include "cppeditortestcase.h"
#include "cppelementevaluator.h" #include "cppelementevaluator.h"