CppTools: Move CppHoverHandler to CppTools

This is in preparation for clang code model to provide its own hover
handler.

Change-Id: Ifbdd96f427989bd5d1fbc4badb9c38108485c2f2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Nikolai Kosjar
2018-01-11 17:06:26 +01:00
parent 53a744a6df
commit 5e861d2be6
20 changed files with 69 additions and 44 deletions

View File

@@ -33,6 +33,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppfollowsymbolundercursor.h>
#include <cpptools/cpphoverhandler.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/editordocumenthandle.h>
#include <cpptools/projectinfo.h>
@@ -111,6 +112,11 @@ CppTools::CppCompletionAssistProvider *ModelManagerSupportClang::completionAssis
return &m_completionAssistProvider;
}
TextEditor::BaseHoverHandler *ModelManagerSupportClang::createHoverHandler()
{
return new CppTools::CppHoverHandler;
}
CppTools::FollowSymbolInterface &ModelManagerSupportClang::followSymbolInterface()
{
return *m_followSymbol;

View File

@@ -61,6 +61,7 @@ public:
~ModelManagerSupportClang();
CppTools::CppCompletionAssistProvider *completionAssistProvider() override;
TextEditor::BaseHoverHandler *createHoverHandler() override;
CppTools::BaseEditorDocumentProcessor *createEditorDocumentProcessor(
TextEditor::TextDocument *baseTextDocument) override;
CppTools::FollowSymbolInterface &followSymbolInterface() override;

View File

@@ -12,10 +12,8 @@ HEADERS += \
cppeditorenums.h \
cppeditorplugin.h \
cppeditorwidget.h \
cppelementevaluator.h \
cppfunctiondecldeflink.h \
cpphighlighter.h \
cpphoverhandler.h \
cppparsecontext.h \
cppincludehierarchy.h \
cppinsertvirtualmethods.h \
@@ -38,10 +36,8 @@ SOURCES += \
cppeditordocument.cpp \
cppeditorplugin.cpp \
cppeditorwidget.cpp \
cppelementevaluator.cpp \
cppfunctiondecldeflink.cpp \
cpphighlighter.cpp \
cpphoverhandler.cpp \
cppparsecontext.cpp \
cppincludehierarchy.cpp \
cppinsertvirtualmethods.cpp \

View File

@@ -39,14 +39,10 @@ QtcPlugin {
"cppeditorenums.h",
"cppeditorplugin.cpp",
"cppeditorplugin.h",
"cppelementevaluator.cpp",
"cppelementevaluator.h",
"cppfunctiondecldeflink.cpp",
"cppfunctiondecldeflink.h",
"cpphighlighter.cpp",
"cpphighlighter.h",
"cpphoverhandler.cpp",
"cpphoverhandler.h",
"cppincludehierarchy.cpp",
"cppincludehierarchy.h",
"cppinsertvirtualmethods.cpp",

View File

@@ -31,7 +31,6 @@
#include "cppeditorwidget.h"
#include "cppeditordocument.h"
#include "cpphighlighter.h"
#include "cpphoverhandler.h"
#include "cppincludehierarchy.h"
#include "cppoutline.h"
#include "cppquickfixassistant.h"
@@ -53,6 +52,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/navigationwidget.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <cpptools/cpphoverhandler.h>
#include <cpptools/cpptoolsconstants.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h>
@@ -105,7 +105,7 @@ public:
| TextEditorActionHandler::UnCollapseAll
| TextEditorActionHandler::FollowSymbolUnderCursor);
addHoverHandler(new CppHoverHandler);
addHoverHandler(CppModelManager::instance()->createHoverHandler());
addHoverHandler(new ColorPreviewHoverHandler);
addHoverHandler(new ResourcePreviewHoverHandler);
}
@@ -145,7 +145,6 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
{
Q_UNUSED(errorMessage)
addAutoReleasedObject(new CppEditorFactory);
addAutoReleasedObject(new CppOutlineWidgetFactory);
addAutoReleasedObject(new CppTypeHierarchyFactory);
addAutoReleasedObject(new CppIncludeHierarchyFactory);
@@ -268,6 +267,10 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
void CppEditorPlugin::extensionsInitialized()
{
// Add the editor factory here instead of in initialize()
// so that the Clang Code Model has a chance to hook in.
addAutoReleasedObject(new CppEditorFactory);
if (!HostOsInfo::isMacHost() && !HostOsInfo::isWindowsHost()) {
FileIconProvider::registerIconOverlayForMimeType(
QIcon(creatorTheme()->imageFile(Theme::IconOverlayCppSource, QLatin1String(":/cppeditor/images/qt_cpp.png"))),

View File

@@ -29,13 +29,13 @@
#include "cppeditorwidget.h"
#include "cppeditorconstants.h"
#include "cppeditorplugin.h"
#include "cppelementevaluator.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/find/itemviewfind.h>
#include <cpptools/baseeditordocumentprocessor.h>
#include <cpptools/cppelementevaluator.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/cpptoolsbridge.h>
#include <cpptools/editordocumenthandle.h>

View File

@@ -28,11 +28,11 @@
#include "cppeditorconstants.h"
#include "cppeditor.h"
#include "cppeditorwidget.h"
#include "cppelementevaluator.h"
#include "cppeditorplugin.h"
#include <coreplugin/find/itemviewfind.h>
#include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppelementevaluator.h>
#include <utils/algorithm.h>
#include <utils/annotateditemdelegate.h>
#include <utils/navigationtreeview.h>
@@ -46,6 +46,7 @@
#include <QVBoxLayout>
using namespace CppEditor;
using namespace CppTools;
using namespace CppEditor::Internal;
using namespace Utils;

View File

@@ -47,11 +47,12 @@ class NavigationTreeView;
class AnnotatedItemDelegate;
}
namespace CppTools { class CppClass; }
namespace CppEditor {
namespace Internal {
class CppEditorWidget;
class CppClass;
class CppTypeHierarchyModel : public QStandardItemModel
{
@@ -75,8 +76,8 @@ public:
void perform();
private:
typedef QList<CppClass> CppClass::*HierarchyMember;
void buildHierarchy(const CppClass &cppClass, QStandardItem *parent,
typedef QList<CppTools::CppClass> CppTools::CppClass::*HierarchyMember;
void buildHierarchy(const CppTools::CppClass &cppClass, QStandardItem *parent,
bool isRoot, HierarchyMember member);
void showNoTypeHierarchyLabel();
void showTypeHierarchy();

View File

@@ -27,8 +27,8 @@
#include "cppeditorwidget.h"
#include "cppeditorplugin.h"
#include "cppeditortestcase.h"
#include "cppelementevaluator.h"
#include <cpptools/cppelementevaluator.h>
#include <cpptools/cppfollowsymbolundercursor.h>
#include <cpptools/cppvirtualfunctionassistprovider.h>
#include <cpptools/cppvirtualfunctionproposalitem.h>

View File

@@ -42,8 +42,7 @@
using namespace CPlusPlus;
namespace CppEditor {
namespace Internal {
namespace CppTools {
static QStringList stripName(const QString &name)
{
@@ -471,5 +470,4 @@ CppEnumerator::CppEnumerator(EnumeratorDeclaration *declaration)
tooltip.append(QLatin1String(" = ") + enumeratorValue);
}
} // namespace Internal
} // namespace CppEditor
} // namespace CppTools

View File

@@ -25,6 +25,8 @@
#pragma once
#include "cpptools_global.h"
#include <texteditor/texteditor.h>
#include <texteditor/helpitem.h>
@@ -41,14 +43,11 @@ class LookupItem;
class LookupContext;
}
namespace CppTools { class CppModelManager; }
namespace CppEditor {
namespace Internal {
namespace CppTools {
class CppElement;
class CppModelManager;
class CppElementEvaluator
class CPPTOOLS_EXPORT CppElementEvaluator
{
public:
explicit CppElementEvaluator(TextEditor::TextEditorWidget *editor);
@@ -82,7 +81,7 @@ private:
QString m_diagnosis;
};
class CppElement
class CPPTOOLS_EXPORT CppElement
{
protected:
CppElement();
@@ -189,5 +188,4 @@ public:
explicit CppEnumerator(CPlusPlus::EnumeratorDeclaration *declaration);
};
} // namespace Internal
} // namespace CppEditor
} // namespace CppTools

View File

@@ -25,7 +25,6 @@
#include "cpphoverhandler.h"
#include "cppeditorconstants.h"
#include "cppelementevaluator.h"
#include <coreplugin/helpmanager.h>
@@ -89,8 +88,7 @@ void processWithEditorDocumentProcessor(TextEditorWidget *editorWidget,
} // anonymous namespace
namespace CppEditor {
namespace Internal {
namespace CppTools {
void CppHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos)
{
@@ -186,5 +184,4 @@ void CppHoverHandler::operateTooltip(TextEditor::TextEditorWidget *editorWidget,
helpId);
}
} // namespace Internal
} // namespace CppEditor
} // namespace CppTools

View File

@@ -25,12 +25,13 @@
#pragma once
#include "cpptools_global.h"
#include <texteditor/basehoverhandler.h>
namespace CppEditor {
namespace Internal {
namespace CppTools {
class CppHoverHandler : public TextEditor::BaseHoverHandler
class CPPTOOLS_EXPORT CppHoverHandler : public TextEditor::BaseHoverHandler
{
private:
void identifyMatch(TextEditor::TextEditorWidget *editorWidget, int pos) override;
@@ -41,5 +42,4 @@ private:
int m_positionForEditorDocumentProcessor = -1;
};
} // namespace Internal
} // namespace CppEditor
} // namespace CppTools

View File

@@ -1293,8 +1293,13 @@ CppCompletionAssistProvider *CppModelManager::completionAssistProvider() const
return d->m_activeModelManagerSupport->completionAssistProvider();
}
TextEditor::BaseHoverHandler *CppModelManager::createHoverHandler() const
{
return d->m_activeModelManagerSupport->createHoverHandler();
}
BaseEditorDocumentProcessor *CppModelManager::createEditorDocumentProcessor(
TextEditor::TextDocument *baseTextDocument) const
TextEditor::TextDocument *baseTextDocument) const
{
return d->m_activeModelManagerSupport->createEditorDocumentProcessor(baseTextDocument);
}

View File

@@ -44,7 +44,10 @@ class IEditor;
}
namespace CPlusPlus { class LookupContext; }
namespace ProjectExplorer { class Project; }
namespace TextEditor { class TextDocument; }
namespace TextEditor {
class BaseHoverHandler;
class TextDocument;
} // namespace TextEditor
namespace CppTools {
@@ -173,7 +176,8 @@ public:
void activateClangCodeModel(ModelManagerSupportProvider *modelManagerSupportProvider);
CppCompletionAssistProvider *completionAssistProvider() const;
BaseEditorDocumentProcessor *createEditorDocumentProcessor(
TextEditor::TextDocument *baseTextDocument) const;
TextEditor::TextDocument *baseTextDocument) const;
TextEditor::BaseHoverHandler *createHoverHandler() const;
FollowSymbolInterface &followSymbolInterface() const;
void setIndexingSupport(CppIndexingSupport *indexingSupport);

View File

@@ -30,7 +30,10 @@
#include <QSharedPointer>
#include <QString>
namespace TextEditor { class TextDocument; }
namespace TextEditor {
class TextDocument;
class BaseHoverHandler;
} // namespace TextEditor
namespace CppTools {
@@ -48,6 +51,7 @@ public:
virtual ~ModelManagerSupport() = 0;
virtual CppCompletionAssistProvider *completionAssistProvider() = 0;
virtual TextEditor::BaseHoverHandler *createHoverHandler() = 0;
virtual BaseEditorDocumentProcessor *createEditorDocumentProcessor(
TextEditor::TextDocument *baseTextDocument) = 0;
virtual FollowSymbolInterface &followSymbolInterface() = 0;

View File

@@ -26,6 +26,7 @@
#include "cppcompletionassist.h"
#include "cppmodelmanagersupportinternal.h"
#include "cppfollowsymbolundercursor.h"
#include "cpphoverhandler.h"
#include "cpprefactoringengine.h"
#include "builtineditordocumentprocessor.h"
@@ -74,6 +75,11 @@ CppCompletionAssistProvider *ModelManagerSupportInternal::completionAssistProvid
return m_completionAssistProvider.data();
}
TextEditor::BaseHoverHandler *ModelManagerSupportInternal::createHoverHandler()
{
return new CppHoverHandler;
}
FollowSymbolInterface &ModelManagerSupportInternal::followSymbolInterface()
{
return *m_followSymbol;

View File

@@ -41,6 +41,7 @@ public:
virtual ~ModelManagerSupportInternal();
CppCompletionAssistProvider *completionAssistProvider() final;
TextEditor::BaseHoverHandler *createHoverHandler() final;
BaseEditorDocumentProcessor *createEditorDocumentProcessor(
TextEditor::TextDocument *baseTextDocument) final;
FollowSymbolInterface &followSymbolInterface() final;

View File

@@ -32,11 +32,13 @@ HEADERS += \
cppdoxygen.h \
cppeditoroutline.h \
cppeditorwidgetinterface.h \
cppelementevaluator.h \
cppfileiterationorder.h \
cppfilesettingspage.h \
cppfindreferences.h \
cppfollowsymbolundercursor.h \
cppfunctionsfilter.h \
cpphoverhandler.h \
cppincludesfilter.h \
cppindexingsupport.h \
cpplocalsymbols.h \
@@ -125,11 +127,13 @@ SOURCES += \
cppcurrentdocumentfilter.cpp \
cppeditoroutline.cpp \
cppdoxygen.cpp \
cppelementevaluator.cpp \
cppfileiterationorder.cpp \
cppfilesettingspage.cpp \
cppfindreferences.cpp \
cppfollowsymbolundercursor.cpp \
cppfunctionsfilter.cpp \
cpphoverhandler.cpp \
cppincludesfilter.cpp \
cppindexingsupport.cpp \
cpplocalsymbols.cpp \

View File

@@ -90,6 +90,8 @@ Project {
"cppeditoroutline.cpp",
"cppeditoroutline.h",
"cppeditorwidgetinterface.h",
"cppelementevaluator.cpp",
"cppelementevaluator.h",
"cppfileiterationorder.cpp",
"cppfileiterationorder.h",
"cppfilesettingspage.cpp",
@@ -101,6 +103,8 @@ Project {
"cppfollowsymbolundercursor.h",
"cppfunctionsfilter.cpp",
"cppfunctionsfilter.h",
"cpphoverhandler.cpp",
"cpphoverhandler.h",
"cppincludesfilter.cpp",
"cppincludesfilter.h",
"cppindexingsupport.cpp",