forked from qt-creator/qt-creator
CppEditor: Use BaseTextEditor{Widget} if possible
Change-Id: I59c420c6469717e552469d176bbeac3a455f3bb0 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
|
||||
|
@@ -31,6 +31,8 @@
|
||||
#ifndef CPPEDITORTESTCASE_H
|
||||
#define CPPEDITORTESTCASE_H
|
||||
|
||||
#include "cppeditor.h"
|
||||
|
||||
#include <cpptools/cpptoolstestcase.h>
|
||||
|
||||
namespace CppEditor {
|
||||
|
@@ -29,6 +29,8 @@
|
||||
|
||||
#include "cppelementevaluator.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
#include <cpptools/typehierarchybuilder.h>
|
||||
|
||||
@@ -59,7 +61,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
CppElementEvaluator::CppElementEvaluator(CPPEditorWidget *editor) :
|
||||
CppElementEvaluator::CppElementEvaluator(TextEditor::BaseTextEditorWidget *editor) :
|
||||
m_editor(editor),
|
||||
m_modelManager(CppTools::CppModelManagerInterface::instance()),
|
||||
m_tc(editor->textCursor()),
|
||||
@@ -262,7 +264,7 @@ CppInclude::CppInclude(const Document::Include &includeFile) :
|
||||
helpCategory = TextEditor::HelpItem::Brief;
|
||||
helpIdCandidates = QStringList(fileName);
|
||||
helpMark = fileName;
|
||||
link = CPPEditorWidget::Link(path);
|
||||
link = TextEditor::BaseTextEditorWidget::Link(path);
|
||||
tooltip = path;
|
||||
}
|
||||
|
||||
@@ -273,7 +275,7 @@ CppMacro::CppMacro(const Macro ¯o)
|
||||
const QString macroName = QString::fromUtf8(macro.name(), macro.name().size());
|
||||
helpIdCandidates = QStringList(macroName);
|
||||
helpMark = macroName;
|
||||
link = CPPEditorWidget::Link(macro.fileName(), macro.line());
|
||||
link = TextEditor::BaseTextEditorWidget::Link(macro.fileName(), macro.line());
|
||||
tooltip = macro.toStringWithLineBreaks();
|
||||
}
|
||||
|
||||
|
@@ -30,9 +30,8 @@
|
||||
#ifndef CPPELEMENTEVALUATOR_H
|
||||
#define CPPELEMENTEVALUATOR_H
|
||||
|
||||
#include "cppeditor.h"
|
||||
|
||||
#include <cpptools/symbolfinder.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <texteditor/helpitem.h>
|
||||
|
||||
#include <QString>
|
||||
@@ -57,7 +56,7 @@ class CppElement;
|
||||
class CppElementEvaluator
|
||||
{
|
||||
public:
|
||||
explicit CppElementEvaluator(CPPEditorWidget *editor);
|
||||
explicit CppElementEvaluator(TextEditor::BaseTextEditorWidget *editor);
|
||||
|
||||
void setTextCursor(const QTextCursor &tc);
|
||||
void setLookupBaseClasses(const bool lookup);
|
||||
@@ -79,7 +78,7 @@ private:
|
||||
const CPlusPlus::LookupContext &lookupContext,
|
||||
const CPlusPlus::Scope *scope);
|
||||
|
||||
CPPEditorWidget *m_editor;
|
||||
TextEditor::BaseTextEditorWidget *m_editor;
|
||||
CppTools::CppModelManagerInterface *m_modelManager;
|
||||
QTextCursor m_tc;
|
||||
bool m_lookupBaseClasses;
|
||||
@@ -100,7 +99,7 @@ public:
|
||||
TextEditor::HelpItem::Category helpCategory;
|
||||
QStringList helpIdCandidates;
|
||||
QString helpMark;
|
||||
CPPEditorWidget::Link link;
|
||||
TextEditor::BaseTextEditorWidget::Link link;
|
||||
QString tooltip;
|
||||
};
|
||||
|
||||
|
@@ -29,10 +29,13 @@
|
||||
|
||||
#include "cpphoverhandler.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppelementevaluator.h"
|
||||
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QTextCursor>
|
||||
#include <QUrl>
|
||||
@@ -48,25 +51,22 @@ CppHoverHandler::~CppHoverHandler()
|
||||
|
||||
bool CppHoverHandler::acceptEditor(IEditor *editor)
|
||||
{
|
||||
CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor);
|
||||
if (cppEditor)
|
||||
return true;
|
||||
return false;
|
||||
return editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID;
|
||||
}
|
||||
|
||||
void CppHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos)
|
||||
{
|
||||
CPPEditorWidget *cppEditor = qobject_cast<CPPEditorWidget *>(editor->widget());
|
||||
if (!cppEditor)
|
||||
return;
|
||||
using namespace TextEditor;
|
||||
BaseTextEditorWidget *textEditor = qobject_cast<BaseTextEditorWidget *>(editor->widget());
|
||||
QTC_ASSERT(textEditor, return);
|
||||
|
||||
if (!cppEditor->extraSelectionTooltip(pos).isEmpty()) {
|
||||
setToolTip(cppEditor->extraSelectionTooltip(pos));
|
||||
if (!textEditor->extraSelectionTooltip(pos).isEmpty()) {
|
||||
setToolTip(textEditor->extraSelectionTooltip(pos));
|
||||
} else {
|
||||
QTextCursor tc(cppEditor->document());
|
||||
QTextCursor tc(textEditor->document());
|
||||
tc.setPosition(pos);
|
||||
|
||||
CppElementEvaluator evaluator(cppEditor);
|
||||
CppElementEvaluator evaluator(textEditor);
|
||||
evaluator.setTextCursor(tc);
|
||||
evaluator.execute();
|
||||
if (evaluator.hasDiagnosis()) {
|
||||
|
@@ -44,6 +44,7 @@ class QLabel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core { class IEditor; }
|
||||
namespace TextEditor { class BaseTextEditor; }
|
||||
|
||||
namespace Utils {
|
||||
class AnnotatedItemDelegate;
|
||||
@@ -84,7 +85,7 @@ private:
|
||||
Utils::AnnotatedItemDelegate *m_delegate;
|
||||
CppIncludeLabel *m_inspectedFile;
|
||||
QLabel *m_includeHierarchyInfoLabel;
|
||||
CPPEditor *m_editor;
|
||||
TextEditor::BaseTextEditor *m_editor;
|
||||
};
|
||||
|
||||
// @todo: Pretty much the same design as the OutlineWidgetStack. Maybe we can generalize the
|
||||
|
@@ -32,7 +32,6 @@
|
||||
#include "cppincludehierarchymodel.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <cppeditor/cppeditor.h>
|
||||
#include <cpptools/cppmodelmanagerinterface.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
|
@@ -32,10 +32,11 @@
|
||||
#include "cppincludehierarchyitem.h"
|
||||
|
||||
#include <coreplugin/fileiconprovider.h>
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <cppeditor/cppeditor.h>
|
||||
#include <cpptools/cppmodelmanagerinterface.h>
|
||||
#include <cpptools/cpptoolseditorsupport.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
|
||||
#include <QSet>
|
||||
|
||||
@@ -138,7 +139,7 @@ QVariant CppIncludeHierarchyModel::data(const QModelIndex &index, int role) cons
|
||||
return Core::FileIconProvider::icon(QFileInfo(item->filePath()));
|
||||
case LinkRole: {
|
||||
QVariant itemLink;
|
||||
CPPEditorWidget::Link link(item->filePath(), item->line());
|
||||
TextEditor::BaseTextEditorWidget::Link link(item->filePath(), item->line());
|
||||
itemLink.setValue(link);
|
||||
return itemLink;
|
||||
}
|
||||
@@ -202,7 +203,8 @@ void CppIncludeHierarchyModel::clear()
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void CppIncludeHierarchyModel::buildHierarchy(CPPEditor *editor, const QString &filePath)
|
||||
void CppIncludeHierarchyModel::buildHierarchy(TextEditor::BaseTextEditor *editor,
|
||||
const QString &filePath)
|
||||
{
|
||||
m_editor = editor;
|
||||
beginResetModel();
|
||||
|
@@ -41,7 +41,7 @@ enum ItemRole {
|
||||
|
||||
} // Anonymous
|
||||
|
||||
namespace Core { class IEditor; }
|
||||
namespace TextEditor { class BaseTextEditor; }
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
bool hasChildren(const QModelIndex &parent) const;
|
||||
|
||||
void clear();
|
||||
void buildHierarchy(CPPEditor *editor, const QString &filePath);
|
||||
void buildHierarchy(TextEditor::BaseTextEditor *editor, const QString &filePath);
|
||||
bool isEmpty() const;
|
||||
|
||||
private:
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
CppIncludeHierarchyItem *m_rootItem;
|
||||
CppIncludeHierarchyItem *m_includesItem;
|
||||
CppIncludeHierarchyItem *m_includedByItem;
|
||||
CPPEditor *m_editor;
|
||||
TextEditor::BaseTextEditor *m_editor;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -27,7 +27,6 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
|
@@ -1786,7 +1786,7 @@ public:
|
||||
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)
|
||||
|
@@ -30,7 +30,6 @@
|
||||
#include "cppsnippetprovider.h"
|
||||
|
||||
#include "cpphighlighter.h"
|
||||
#include "cppeditor.h"
|
||||
#include "cppautocompleter.h"
|
||||
#include "cppeditorconstants.h"
|
||||
|
||||
|
@@ -27,7 +27,6 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppelementevaluator.h"
|
||||
|
Reference in New Issue
Block a user