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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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