forked from qt-creator/qt-creator
C++: remove builtin FollowSymbol dependency from CppEditor
Move FollowSymbolUnderCursor to CppTools and builtin member ownership to internal model manager. Change-Id: I97a4f744ec1709ccc0b34fb67b58680973ef566f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "clangfollowsymbol.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <cpptools/cppfollowsymbolundercursor.h>
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/editordocumenthandle.h>
|
||||
#include <cpptools/projectinfo.h>
|
||||
@@ -72,6 +73,8 @@ ModelManagerSupportClang::ModelManagerSupportClang()
|
||||
|
||||
if (useClangFollowSymbol())
|
||||
m_followSymbol.reset(new ClangFollowSymbol);
|
||||
else
|
||||
m_followSymbol.reset(new CppTools::FollowSymbolUnderCursor);
|
||||
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
connect(editorManager, &Core::EditorManager::editorOpened,
|
||||
@@ -106,9 +109,9 @@ CppTools::CppCompletionAssistProvider *ModelManagerSupportClang::completionAssis
|
||||
return &m_completionAssistProvider;
|
||||
}
|
||||
|
||||
CppTools::FollowSymbolInterface *ModelManagerSupportClang::followSymbolInterface()
|
||||
CppTools::FollowSymbolInterface &ModelManagerSupportClang::followSymbolInterface()
|
||||
{
|
||||
return m_followSymbol.get();
|
||||
return *m_followSymbol;
|
||||
}
|
||||
|
||||
CppTools::BaseEditorDocumentProcessor *ModelManagerSupportClang::editorDocumentProcessor(
|
||||
|
||||
@@ -42,12 +42,11 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core { class IDocument; }
|
||||
namespace TextEditor { class TextEditorWidget; }
|
||||
namespace CppTools { class FollowSymbolInterface; }
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class ClangFollowSymbol;
|
||||
|
||||
class ModelManagerSupportClang:
|
||||
public QObject,
|
||||
public CppTools::ModelManagerSupport
|
||||
@@ -61,7 +60,7 @@ public:
|
||||
CppTools::CppCompletionAssistProvider *completionAssistProvider() override;
|
||||
CppTools::BaseEditorDocumentProcessor *editorDocumentProcessor(
|
||||
TextEditor::TextDocument *baseTextDocument) override;
|
||||
CppTools::FollowSymbolInterface *followSymbolInterface() override;
|
||||
CppTools::FollowSymbolInterface &followSymbolInterface() override;
|
||||
|
||||
IpcCommunicator &ipcCommunicator();
|
||||
QString dummyUiHeaderOnDiskDirPath() const;
|
||||
@@ -105,7 +104,7 @@ private:
|
||||
UiHeaderOnDiskManager m_uiHeaderOnDiskManager;
|
||||
IpcCommunicator m_ipcCommunicator;
|
||||
ClangCompletionAssistProvider m_completionAssistProvider;
|
||||
std::unique_ptr<ClangFollowSymbol> m_followSymbol;
|
||||
std::unique_ptr<CppTools::FollowSymbolInterface> m_followSymbol;
|
||||
};
|
||||
|
||||
class ModelManagerSupportProviderClang : public CppTools::ModelManagerSupportProvider
|
||||
|
||||
@@ -13,7 +13,6 @@ HEADERS += \
|
||||
cppeditorplugin.h \
|
||||
cppeditorwidget.h \
|
||||
cppelementevaluator.h \
|
||||
cppfollowsymbolundercursor.h \
|
||||
cppfunctiondecldeflink.h \
|
||||
cpphighlighter.h \
|
||||
cpphoverhandler.h \
|
||||
@@ -30,8 +29,6 @@ HEADERS += \
|
||||
cpprefactoringengine.h \
|
||||
cpptypehierarchy.h \
|
||||
cppuseselectionsupdater.h \
|
||||
cppvirtualfunctionassistprovider.h \
|
||||
cppvirtualfunctionproposalitem.h \
|
||||
resourcepreviewhoverhandler.h
|
||||
|
||||
SOURCES += \
|
||||
@@ -43,7 +40,6 @@ SOURCES += \
|
||||
cppeditorplugin.cpp \
|
||||
cppeditorwidget.cpp \
|
||||
cppelementevaluator.cpp \
|
||||
cppfollowsymbolundercursor.cpp \
|
||||
cppfunctiondecldeflink.cpp \
|
||||
cpphighlighter.cpp \
|
||||
cpphoverhandler.cpp \
|
||||
@@ -60,8 +56,6 @@ SOURCES += \
|
||||
cpprefactoringengine.cpp \
|
||||
cpptypehierarchy.cpp \
|
||||
cppuseselectionsupdater.cpp \
|
||||
cppvirtualfunctionassistprovider.cpp \
|
||||
cppvirtualfunctionproposalitem.cpp \
|
||||
resourcepreviewhoverhandler.cpp
|
||||
|
||||
FORMS += \
|
||||
|
||||
@@ -41,8 +41,6 @@ QtcPlugin {
|
||||
"cppeditorplugin.h",
|
||||
"cppelementevaluator.cpp",
|
||||
"cppelementevaluator.h",
|
||||
"cppfollowsymbolundercursor.cpp",
|
||||
"cppfollowsymbolundercursor.h",
|
||||
"cppfunctiondecldeflink.cpp",
|
||||
"cppfunctiondecldeflink.h",
|
||||
"cpphighlighter.cpp",
|
||||
@@ -76,10 +74,6 @@ QtcPlugin {
|
||||
"cpptypehierarchy.h",
|
||||
"cppuseselectionsupdater.cpp",
|
||||
"cppuseselectionsupdater.h",
|
||||
"cppvirtualfunctionassistprovider.cpp",
|
||||
"cppvirtualfunctionassistprovider.h",
|
||||
"cppvirtualfunctionproposalitem.cpp",
|
||||
"cppvirtualfunctionproposalitem.h",
|
||||
"resourcepreviewhoverhandler.cpp",
|
||||
"resourcepreviewhoverhandler.h",
|
||||
]
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditordocument.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppfollowsymbolundercursor.h"
|
||||
#include "cppfunctiondecldeflink.h"
|
||||
#include "cpphighlighter.h"
|
||||
#include "cpplocalrenaming.h"
|
||||
@@ -63,6 +62,7 @@
|
||||
#include <cpptools/cpptoolssettings.h>
|
||||
#include <cpptools/cppworkingcopy.h>
|
||||
#include <cpptools/refactoringengineinterface.h>
|
||||
#include <cpptools/followsymbolinterface.h>
|
||||
#include <cpptools/symbolfinder.h>
|
||||
|
||||
#include <texteditor/behaviorsettings.h>
|
||||
@@ -130,7 +130,6 @@ public:
|
||||
CppLocalRenaming m_localRenaming;
|
||||
CppUseSelectionsUpdater m_useSelectionsUpdater;
|
||||
CppSelectionChanger m_cppSelectionChanger;
|
||||
FollowSymbolUnderCursor m_builtinFollowSymbol;
|
||||
CppRefactoringEngine m_builtinRefactoringEngine;
|
||||
};
|
||||
|
||||
@@ -650,7 +649,7 @@ CppEditorWidget::Link CppEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||
|
||||
const Utils::FileName &filePath = textDocument()->filePath();
|
||||
|
||||
return followSymbolInterface()->findLink(CppTools::CursorInEditor{cursor, filePath, this},
|
||||
return followSymbolInterface().findLink(CppTools::CursorInEditor{cursor, filePath, this},
|
||||
resolveTarget,
|
||||
d->m_modelManager->snapshot(),
|
||||
d->m_lastSemanticInfo.doc,
|
||||
@@ -690,12 +689,9 @@ RefactoringEngineInterface *CppEditorWidget::refactoringEngine() const
|
||||
: static_cast<RefactoringEngineInterface *>(&d->m_builtinRefactoringEngine);
|
||||
}
|
||||
|
||||
CppTools::FollowSymbolInterface *CppEditorWidget::followSymbolInterface() const
|
||||
CppTools::FollowSymbolInterface &CppEditorWidget::followSymbolInterface() const
|
||||
{
|
||||
CppTools::FollowSymbolInterface *followSymbol
|
||||
= CppTools::CppModelManager::instance()->followSymbolInterface();
|
||||
return followSymbol ? followSymbol
|
||||
: static_cast<CppTools::FollowSymbolInterface *>(&d->m_builtinFollowSymbol);
|
||||
return CppTools::CppModelManager::instance()->followSymbolInterface();
|
||||
}
|
||||
|
||||
bool CppEditorWidget::isSemanticInfoValidExceptLocalUses() const
|
||||
@@ -1041,5 +1037,11 @@ void CppEditorWidget::showPreProcessorWidget()
|
||||
}
|
||||
}
|
||||
|
||||
void CppEditorWidget::invokeTextEditorWidgetAssist(TextEditor::AssistKind assistKind,
|
||||
TextEditor::IAssistProvider *provider)
|
||||
{
|
||||
invokeAssist(assistKind, provider);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <cpptools/cppeditorwidgetinterface.h>
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace CppTools {
|
||||
@@ -45,7 +47,8 @@ class CppEditorDocument;
|
||||
class CppEditorWidgetPrivate;
|
||||
class FunctionDeclDefLink;
|
||||
|
||||
class CppEditorWidget : public TextEditor::TextEditorWidget
|
||||
class CppEditorWidget : public TextEditor::TextEditorWidget,
|
||||
public CppTools::CppEditorWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -74,7 +77,7 @@ public:
|
||||
void selectAll() override;
|
||||
|
||||
void switchDeclarationDefinition(bool inNextSplit);
|
||||
void showPreProcessorWidget();
|
||||
void showPreProcessorWidget() override;
|
||||
|
||||
void findUsages();
|
||||
void renameSymbolUnderCursor();
|
||||
@@ -86,9 +89,10 @@ public:
|
||||
static void updateWidgetHighlighting(QWidget *widget, bool highlight);
|
||||
static bool isWidgetHighlighted(QWidget *widget);
|
||||
|
||||
void updateSemanticInfo();
|
||||
void updateSemanticInfo() override;
|
||||
void invokeTextEditorWidgetAssist(TextEditor::AssistKind assistKind,
|
||||
TextEditor::IAssistProvider *provider) override;
|
||||
|
||||
CppTools::FollowSymbolInterface *followSymbolInterface() const;
|
||||
protected:
|
||||
bool event(QEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *) override;
|
||||
@@ -133,6 +137,7 @@ private:
|
||||
|
||||
TextEditor::RefactorMarkers refactorMarkersWithoutClangMarkers() const;
|
||||
|
||||
CppTools::FollowSymbolInterface &followSymbolInterface() const;
|
||||
CppTools::RefactoringEngineInterface *refactoringEngine() const;
|
||||
|
||||
CppTools::ProjectPart *projectPart() const;
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
#include "cppeditordocument.h"
|
||||
#include "cppfunctiondecldeflink.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
#include "cppvirtualfunctionassistprovider.h"
|
||||
#include "cppinsertvirtualmethods.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagebox.h>
|
||||
|
||||
#include <cpptools/cppvirtualfunctionassistprovider.h>
|
||||
#include <cpptools/baseeditordocumentprocessor.h>
|
||||
#include <cpptools/cppclassesfilter.h>
|
||||
#include <cpptools/cppcodestylesettings.h>
|
||||
|
||||
@@ -35,7 +35,7 @@ void CppRefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &da
|
||||
CppTools::ProjectPart *,
|
||||
RenameCallback &&renameSymbolsCallback)
|
||||
{
|
||||
CppEditorWidget *editorWidget = static_cast<CppEditorWidget *>(data.editorWidget());
|
||||
CppEditorWidget *editorWidget = dynamic_cast<CppEditorWidget *>(data.editorWidget());
|
||||
QTC_ASSERT(editorWidget, renameSymbolsCallback(QString(),
|
||||
ClangBackEnd::SourceLocationsContainer(),
|
||||
0); return;);
|
||||
@@ -48,7 +48,7 @@ void CppRefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &da
|
||||
|
||||
void CppRefactoringEngine::startGlobalRenaming(const CppTools::CursorInEditor &data)
|
||||
{
|
||||
CppEditorWidget *editorWidget = static_cast<CppEditorWidget *>(data.editorWidget());
|
||||
CppEditorWidget *editorWidget = dynamic_cast<CppEditorWidget *>(data.editorWidget());
|
||||
if (!editorWidget)
|
||||
return;
|
||||
editorWidget->renameUsages();
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppelementevaluator.h"
|
||||
#include "cppfollowsymbolundercursor.h"
|
||||
#include "cppvirtualfunctionassistprovider.h"
|
||||
#include "cppvirtualfunctionproposalitem.h"
|
||||
|
||||
#include <cpptools/cppfollowsymbolundercursor.h>
|
||||
#include <cpptools/cppvirtualfunctionassistprovider.h>
|
||||
#include <cpptools/cppvirtualfunctionproposalitem.h>
|
||||
#include <cpptools/cpptoolstestcase.h>
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
|
||||
@@ -327,10 +327,8 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
||||
switch (action) {
|
||||
case FollowSymbolUnderCursorAction: {
|
||||
CppEditorWidget *widget = initialTestFile->m_editorWidget;
|
||||
FollowSymbolInterface* delegate = widget->followSymbolInterface();
|
||||
if (!delegate)
|
||||
QFAIL("No follow symbol interface");
|
||||
auto* builtinFollowSymbol = dynamic_cast<FollowSymbolUnderCursor *>(delegate);
|
||||
FollowSymbolInterface &delegate = CppModelManager::instance()->followSymbolInterface();
|
||||
auto* builtinFollowSymbol = dynamic_cast<FollowSymbolUnderCursor *>(&delegate);
|
||||
if (!builtinFollowSymbol) {
|
||||
if (filePaths.size() > 1)
|
||||
QSKIP("Clang FollowSymbol does not currently support multiple files (except cpp+header)");
|
||||
|
||||
46
src/plugins/cpptools/cppeditorwidgetinterface.h
Normal file
46
src/plugins/cpptools/cppeditorwidgetinterface.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <texteditor/codeassist/assistenums.h>
|
||||
|
||||
namespace TextEditor { class IAssistProvider; }
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
class CPPTOOLS_EXPORT CppEditorWidgetInterface
|
||||
{
|
||||
public:
|
||||
virtual void showPreProcessorWidget() = 0;
|
||||
virtual void updateSemanticInfo() = 0;
|
||||
|
||||
virtual void invokeTextEditorWidgetAssist(TextEditor::AssistKind assistKind,
|
||||
TextEditor::IAssistProvider *provider) = 0;
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
@@ -24,9 +24,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppfollowsymbolundercursor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditordocument.h"
|
||||
#include "cppvirtualfunctionassistprovider.h"
|
||||
#include "cppmodelmanager.h"
|
||||
#include "functionutils.h"
|
||||
#include "cpptoolsreuse.h"
|
||||
#include "symbolfinder.h"
|
||||
|
||||
#include <cplusplus/ASTPath.h>
|
||||
#include <cplusplus/BackwardsScanner.h>
|
||||
@@ -34,10 +36,6 @@
|
||||
#include <cplusplus/ResolveExpression.h>
|
||||
#include <cplusplus/SimpleLexer.h>
|
||||
#include <cplusplus/TypeOfExpression.h>
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/functionutils.h>
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
#include <cpptools/symbolfinder.h>
|
||||
#include <texteditor/textdocumentlayout.h>
|
||||
#include <texteditor/convenience.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -46,13 +44,12 @@
|
||||
#include <QSet>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
using namespace CppTools;
|
||||
using namespace CppEditor;
|
||||
using namespace CppEditor::Internal;
|
||||
using namespace TextEditor;
|
||||
|
||||
typedef TextEditorWidget::Link Link;
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
namespace {
|
||||
|
||||
class VirtualFunctionHelper {
|
||||
@@ -299,9 +296,9 @@ inline LookupItem skipForwardDeclarations(const QList<LookupItem> &resolvedSymbo
|
||||
return result;
|
||||
}
|
||||
|
||||
CppEditorWidget::Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
|
||||
const Document::Ptr &document,
|
||||
SymbolFinder *symbolFinder)
|
||||
Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
|
||||
const Document::Ptr &document,
|
||||
SymbolFinder *symbolFinder)
|
||||
{
|
||||
Link result;
|
||||
QTC_ASSERT(document, return result);
|
||||
@@ -610,11 +607,11 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
}
|
||||
}
|
||||
|
||||
CppEditorWidget *editorWidget = static_cast<CppEditorWidget *>(data.editorWidget());
|
||||
CppEditorWidgetInterface *editorWidget = data.editorWidget();
|
||||
if (!editorWidget)
|
||||
return link;
|
||||
// Now we prefer the doc from the snapshot with macros expanded.
|
||||
Document::Ptr doc = snapshot.document(editorWidget->textDocument()->filePath());
|
||||
Document::Ptr doc = snapshot.document(data.filePath());
|
||||
if (!doc) {
|
||||
doc = documentFromSemanticInfo;
|
||||
if (!doc)
|
||||
@@ -697,7 +694,7 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
if (Symbol *d = r.declaration()) {
|
||||
if (d->isDeclaration() || d->isFunction()) {
|
||||
const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength());
|
||||
if (editorWidget->textDocument()->filePath().toString() == fileName) {
|
||||
if (data.filePath().toString() == fileName) {
|
||||
if (unsigned(lineNumber) == d->line()
|
||||
&& unsigned(positionInBlock) >= d->column()) { // TODO: check the end
|
||||
result = r; // take the symbol under cursor.
|
||||
@@ -706,8 +703,8 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
}
|
||||
} else if (d->isUsingDeclaration()) {
|
||||
int tokenBeginLineNumber = 0, tokenBeginColumnNumber = 0;
|
||||
editorWidget->convertPosition(beginOfToken, &tokenBeginLineNumber,
|
||||
&tokenBeginColumnNumber);
|
||||
TextEditor::Convenience::convertPosition(document, beginOfToken, &tokenBeginLineNumber,
|
||||
&tokenBeginColumnNumber);
|
||||
if (unsigned(tokenBeginLineNumber) > d->line()
|
||||
|| (unsigned(tokenBeginLineNumber) == d->line()
|
||||
&& unsigned(tokenBeginColumnNumber) > d->column())) {
|
||||
@@ -736,7 +733,8 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
params.openInNextSplit = inNextSplit;
|
||||
|
||||
if (m_virtualFunctionAssistProvider->configure(params)) {
|
||||
editorWidget->invokeAssist(FollowSymbol, m_virtualFunctionAssistProvider.data());
|
||||
editorWidget->invokeTextEditorWidgetAssist(
|
||||
FollowSymbol,m_virtualFunctionAssistProvider.data());
|
||||
m_virtualFunctionAssistProvider->clearParams();
|
||||
}
|
||||
|
||||
@@ -795,3 +793,5 @@ void FollowSymbolUnderCursor::setVirtualFunctionAssistProvider(
|
||||
{
|
||||
m_virtualFunctionAssistProvider = provider;
|
||||
}
|
||||
|
||||
} // namespace CppTools
|
||||
@@ -25,14 +25,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cpptools/followsymbolinterface.h>
|
||||
#include "followsymbolinterface.h"
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
namespace CppTools {
|
||||
|
||||
class VirtualFunctionAssistProvider;
|
||||
|
||||
class FollowSymbolUnderCursor : public CppTools::FollowSymbolInterface
|
||||
class CPPTOOLS_EXPORT FollowSymbolUnderCursor : public CppTools::FollowSymbolInterface
|
||||
{
|
||||
public:
|
||||
FollowSymbolUnderCursor();
|
||||
@@ -52,5 +51,4 @@ private:
|
||||
QSharedPointer<VirtualFunctionAssistProvider> m_virtualFunctionAssistProvider;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
} // namespace CppTools
|
||||
@@ -275,7 +275,7 @@ RefactoringEngineInterface *CppModelManager::refactoringEngine()
|
||||
return instance()->d->m_refactoringEngine;
|
||||
}
|
||||
|
||||
FollowSymbolInterface *CppModelManager::followSymbolInterface() const
|
||||
FollowSymbolInterface &CppModelManager::followSymbolInterface() const
|
||||
{
|
||||
return d->m_activeModelManagerSupport->followSymbolInterface();
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
CppCompletionAssistProvider *completionAssistProvider() const;
|
||||
BaseEditorDocumentProcessor *editorDocumentProcessor(
|
||||
TextEditor::TextDocument *baseTextDocument) const;
|
||||
FollowSymbolInterface *followSymbolInterface() const;
|
||||
FollowSymbolInterface &followSymbolInterface() const;
|
||||
|
||||
void setIndexingSupport(CppIndexingSupport *indexingSupport);
|
||||
CppIndexingSupport *indexingSupport();
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
virtual CppCompletionAssistProvider *completionAssistProvider() = 0;
|
||||
virtual BaseEditorDocumentProcessor *editorDocumentProcessor(
|
||||
TextEditor::TextDocument *baseTextDocument) = 0;
|
||||
virtual FollowSymbolInterface *followSymbolInterface() = 0;
|
||||
virtual FollowSymbolInterface &followSymbolInterface() = 0;
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT ModelManagerSupportProvider
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "cppcompletionassist.h"
|
||||
#include "cppmodelmanagersupportinternal.h"
|
||||
#include "cppfollowsymbolundercursor.h"
|
||||
#include "builtineditordocumentprocessor.h"
|
||||
|
||||
#include <app/app_version.h>
|
||||
@@ -51,7 +52,8 @@ ModelManagerSupport::Ptr ModelManagerSupportProviderInternal::createModelManager
|
||||
}
|
||||
|
||||
ModelManagerSupportInternal::ModelManagerSupportInternal()
|
||||
: m_completionAssistProvider(new InternalCompletionAssistProvider)
|
||||
: m_completionAssistProvider(new InternalCompletionAssistProvider),
|
||||
m_followSymbol(new FollowSymbolUnderCursor)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,7 +72,7 @@ CppCompletionAssistProvider *ModelManagerSupportInternal::completionAssistProvid
|
||||
return m_completionAssistProvider.data();
|
||||
}
|
||||
|
||||
FollowSymbolInterface *ModelManagerSupportInternal::followSymbolInterface()
|
||||
FollowSymbolInterface &ModelManagerSupportInternal::followSymbolInterface()
|
||||
{
|
||||
return nullptr;
|
||||
return *m_followSymbol;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,11 @@ public:
|
||||
CppCompletionAssistProvider *completionAssistProvider() final;
|
||||
BaseEditorDocumentProcessor *editorDocumentProcessor(
|
||||
TextEditor::TextDocument *baseTextDocument) final;
|
||||
FollowSymbolInterface *followSymbolInterface() final;
|
||||
FollowSymbolInterface &followSymbolInterface() final;
|
||||
|
||||
private:
|
||||
QScopedPointer<CppCompletionAssistProvider> m_completionAssistProvider;
|
||||
QScopedPointer<FollowSymbolInterface> m_followSymbol;
|
||||
};
|
||||
|
||||
class ModelManagerSupportProviderInternal : public ModelManagerSupportProvider
|
||||
|
||||
@@ -29,11 +29,13 @@ HEADERS += \
|
||||
cppcompletionassistprovider.h \
|
||||
cppcursorinfo.h \
|
||||
cppcurrentdocumentfilter.h \
|
||||
cppeditoroutline.h \
|
||||
cppdoxygen.h \
|
||||
cppeditoroutline.h \
|
||||
cppeditorwidgetinterface.h \
|
||||
cppfileiterationorder.h \
|
||||
cppfilesettingspage.h \
|
||||
cppfindreferences.h \
|
||||
cppfollowsymbolundercursor.h \
|
||||
cppfunctionsfilter.h \
|
||||
cppincludesfilter.h \
|
||||
cppindexingsupport.h \
|
||||
@@ -60,6 +62,8 @@ HEADERS += \
|
||||
cpptoolsplugin.h \
|
||||
cpptoolsreuse.h \
|
||||
cpptoolssettings.h \
|
||||
cppvirtualfunctionassistprovider.h \
|
||||
cppvirtualfunctionproposalitem.h \
|
||||
cppworkingcopy.h \
|
||||
doxygengenerator.h \
|
||||
editordocumenthandle.h \
|
||||
@@ -123,6 +127,7 @@ SOURCES += \
|
||||
cppfileiterationorder.cpp \
|
||||
cppfilesettingspage.cpp \
|
||||
cppfindreferences.cpp \
|
||||
cppfollowsymbolundercursor.cpp \
|
||||
cppfunctionsfilter.cpp \
|
||||
cppincludesfilter.cpp \
|
||||
cppindexingsupport.cpp \
|
||||
@@ -145,6 +150,8 @@ SOURCES += \
|
||||
cpptoolsplugin.cpp \
|
||||
cpptoolsreuse.cpp \
|
||||
cpptoolssettings.cpp \
|
||||
cppvirtualfunctionassistprovider.cpp \
|
||||
cppvirtualfunctionproposalitem.cpp \
|
||||
cppworkingcopy.cpp \
|
||||
doxygengenerator.cpp \
|
||||
editordocumenthandle.cpp \
|
||||
|
||||
@@ -90,6 +90,7 @@ Project {
|
||||
"cppdoxygen.h",
|
||||
"cppeditoroutline.cpp",
|
||||
"cppeditoroutline.h",
|
||||
"cppeditorwidgetinterface.h",
|
||||
"cppfileiterationorder.cpp",
|
||||
"cppfileiterationorder.h",
|
||||
"cppfilesettingspage.cpp",
|
||||
@@ -97,6 +98,8 @@ Project {
|
||||
"cppfilesettingspage.ui",
|
||||
"cppfindreferences.cpp",
|
||||
"cppfindreferences.h",
|
||||
"cppfollowsymbolundercursor.cpp",
|
||||
"cppfollowsymbolundercursor.h",
|
||||
"cppfunctionsfilter.cpp",
|
||||
"cppfunctionsfilter.h",
|
||||
"cppincludesfilter.cpp",
|
||||
@@ -157,6 +160,10 @@ Project {
|
||||
"cpptoolsreuse.h",
|
||||
"cpptoolssettings.cpp",
|
||||
"cpptoolssettings.h",
|
||||
"cppvirtualfunctionassistprovider.cpp",
|
||||
"cppvirtualfunctionassistprovider.h",
|
||||
"cppvirtualfunctionproposalitem.cpp",
|
||||
"cppvirtualfunctionproposalitem.h",
|
||||
"cppworkingcopy.cpp",
|
||||
"cppworkingcopy.h",
|
||||
"cursorineditor.h",
|
||||
|
||||
@@ -24,21 +24,19 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppvirtualfunctionassistprovider.h"
|
||||
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppvirtualfunctionproposalitem.h"
|
||||
|
||||
#include "cpptoolsreuse.h"
|
||||
#include "functionutils.h"
|
||||
#include "symbolfinder.h"
|
||||
#include "typehierarchybuilder.h"
|
||||
|
||||
#include <cplusplus/Icons.h>
|
||||
#include <cplusplus/Overview.h>
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
#include <cpptools/functionutils.h>
|
||||
#include <cpptools/symbolfinder.h>
|
||||
#include <cpptools/typehierarchybuilder.h>
|
||||
|
||||
#include <texteditor/codeassist/genericproposalmodel.h>
|
||||
#include <texteditor/codeassist/genericproposal.h>
|
||||
#include <texteditor/codeassist/genericproposalwidget.h>
|
||||
@@ -50,10 +48,10 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
using namespace CppEditor::Internal;
|
||||
using namespace CppTools;
|
||||
using namespace TextEditor;
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
/// Activate current item with the same shortcut that is configured for Follow Symbol Under Cursor.
|
||||
/// This is limited to single-key shortcuts without modifiers.
|
||||
class VirtualFunctionProposalWidget : public GenericProposalWidget
|
||||
@@ -211,3 +209,5 @@ IAssistProcessor *VirtualFunctionAssistProvider::createProcessor() const
|
||||
{
|
||||
return new VirtualFunctionAssistProcessor(m_params);
|
||||
}
|
||||
|
||||
} // namespace CppTools
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <texteditor/codeassist/iassistprovider.h>
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
@@ -34,10 +36,9 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QTextCursor>
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
namespace CppTools {
|
||||
|
||||
class VirtualFunctionAssistProvider : public TextEditor::IAssistProvider
|
||||
class CPPTOOLS_EXPORT VirtualFunctionAssistProvider : public TextEditor::IAssistProvider
|
||||
{
|
||||
public:
|
||||
VirtualFunctionAssistProvider();
|
||||
@@ -64,5 +65,4 @@ private:
|
||||
Parameters m_params;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
} // namespace CppTools
|
||||
@@ -25,11 +25,11 @@
|
||||
|
||||
#include "cppvirtualfunctionproposalitem.h"
|
||||
|
||||
#include "cppeditorconstants.h"
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
using namespace CppEditor::Internal;
|
||||
namespace CppTools {
|
||||
|
||||
VirtualFunctionProposalItem::VirtualFunctionProposalItem(
|
||||
const TextEditor::TextEditorWidget::Link &link, bool openInSplit)
|
||||
@@ -52,3 +52,5 @@ void VirtualFunctionProposalItem::apply(TextEditor::TextDocumentManipulatorInter
|
||||
CppEditor::Constants::CPPEDITOR_ID,
|
||||
flags);
|
||||
}
|
||||
|
||||
} // namespace CppTools
|
||||
@@ -25,13 +25,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/codeassist/assistproposalitem.h>
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
namespace CppTools {
|
||||
|
||||
class VirtualFunctionProposalItem final : public TextEditor::AssistProposalItem
|
||||
class CPPTOOLS_EXPORT VirtualFunctionProposalItem final : public TextEditor::AssistProposalItem
|
||||
{
|
||||
public:
|
||||
VirtualFunctionProposalItem(const TextEditor::TextEditorWidget::Link &link,
|
||||
@@ -46,5 +47,4 @@ private:
|
||||
bool m_openInSplit;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
@@ -25,12 +25,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QTextCursor>
|
||||
#include "cppeditorwidgetinterface.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
namespace TextEditor {
|
||||
class TextEditorWidget;
|
||||
} // namespace TextEditor
|
||||
#include <QTextCursor>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
@@ -38,18 +37,18 @@ class CursorInEditor
|
||||
{
|
||||
public:
|
||||
CursorInEditor(const QTextCursor &cursor, const Utils::FileName &filePath,
|
||||
TextEditor::TextEditorWidget *editorWidget = nullptr)
|
||||
CppEditorWidgetInterface *editorWidget = nullptr)
|
||||
: m_cursor(cursor)
|
||||
, m_filePath(filePath)
|
||||
, m_editorWidget(editorWidget)
|
||||
{}
|
||||
TextEditor::TextEditorWidget *editorWidget() const { return m_editorWidget; }
|
||||
CppEditorWidgetInterface *editorWidget() const { return m_editorWidget; }
|
||||
const QTextCursor &cursor() const { return m_cursor; }
|
||||
const Utils::FileName &filePath() const { return m_filePath; }
|
||||
private:
|
||||
QTextCursor m_cursor;
|
||||
Utils::FileName m_filePath;
|
||||
TextEditor::TextEditorWidget *m_editorWidget = nullptr;
|
||||
CppEditorWidgetInterface *m_editorWidget = nullptr;
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
Reference in New Issue
Block a user