forked from qt-creator/qt-creator
C++: remove builtin RefactoringEngine dependency from CppEditor
Move CppRefactoringEngine to CppTools and builtin member ownership to model manager. Change-Id: I3e72308559fd2928229f9f25d4dd09beb3f56c34 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -96,6 +96,7 @@ void ClangRefactoringPlugin::extensionsInitialized()
|
|||||||
ExtensionSystem::IPlugin::ShutdownFlag ClangRefactoringPlugin::aboutToShutdown()
|
ExtensionSystem::IPlugin::ShutdownFlag ClangRefactoringPlugin::aboutToShutdown()
|
||||||
{
|
{
|
||||||
ExtensionSystem::PluginManager::removeObject(&d->qtCreatorfindFilter);
|
ExtensionSystem::PluginManager::removeObject(&d->qtCreatorfindFilter);
|
||||||
|
CppTools::CppModelManager::setRefactoringEngine(nullptr);
|
||||||
d->refactoringClient.setRefactoringConnectionClient(nullptr);
|
d->refactoringClient.setRefactoringConnectionClient(nullptr);
|
||||||
d->refactoringClient.setRefactoringEngine(nullptr);
|
d->refactoringClient.setRefactoringEngine(nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ HEADERS += \
|
|||||||
cppquickfix.h \
|
cppquickfix.h \
|
||||||
cppquickfixassistant.h \
|
cppquickfixassistant.h \
|
||||||
cppquickfixes.h \
|
cppquickfixes.h \
|
||||||
cpprefactoringengine.h \
|
|
||||||
cpptypehierarchy.h \
|
cpptypehierarchy.h \
|
||||||
cppuseselectionsupdater.h \
|
cppuseselectionsupdater.h \
|
||||||
resourcepreviewhoverhandler.h
|
resourcepreviewhoverhandler.h
|
||||||
@@ -53,7 +52,6 @@ SOURCES += \
|
|||||||
cppquickfix.cpp \
|
cppquickfix.cpp \
|
||||||
cppquickfixassistant.cpp \
|
cppquickfixassistant.cpp \
|
||||||
cppquickfixes.cpp \
|
cppquickfixes.cpp \
|
||||||
cpprefactoringengine.cpp \
|
|
||||||
cpptypehierarchy.cpp \
|
cpptypehierarchy.cpp \
|
||||||
cppuseselectionsupdater.cpp \
|
cppuseselectionsupdater.cpp \
|
||||||
resourcepreviewhoverhandler.cpp
|
resourcepreviewhoverhandler.cpp
|
||||||
|
|||||||
@@ -68,8 +68,6 @@ QtcPlugin {
|
|||||||
"cppquickfixassistant.h",
|
"cppquickfixassistant.h",
|
||||||
"cppquickfixes.cpp",
|
"cppquickfixes.cpp",
|
||||||
"cppquickfixes.h",
|
"cppquickfixes.h",
|
||||||
"cpprefactoringengine.cpp",
|
|
||||||
"cpprefactoringengine.h",
|
|
||||||
"cpptypehierarchy.cpp",
|
"cpptypehierarchy.cpp",
|
||||||
"cpptypehierarchy.h",
|
"cpptypehierarchy.h",
|
||||||
"cppuseselectionsupdater.cpp",
|
"cppuseselectionsupdater.cpp",
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
#include "cppminimizableinfobars.h"
|
#include "cppminimizableinfobars.h"
|
||||||
#include "cpppreprocessordialog.h"
|
#include "cpppreprocessordialog.h"
|
||||||
#include "cppquickfixassistant.h"
|
#include "cppquickfixassistant.h"
|
||||||
#include "cpprefactoringengine.h"
|
|
||||||
#include "cppuseselectionsupdater.h"
|
#include "cppuseselectionsupdater.h"
|
||||||
|
|
||||||
#include <clangsupport/sourcelocationscontainer.h>
|
#include <clangsupport/sourcelocationscontainer.h>
|
||||||
@@ -130,7 +129,6 @@ public:
|
|||||||
CppLocalRenaming m_localRenaming;
|
CppLocalRenaming m_localRenaming;
|
||||||
CppUseSelectionsUpdater m_useSelectionsUpdater;
|
CppUseSelectionsUpdater m_useSelectionsUpdater;
|
||||||
CppSelectionChanger m_cppSelectionChanger;
|
CppSelectionChanger m_cppSelectionChanger;
|
||||||
CppRefactoringEngine m_builtinRefactoringEngine;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CppEditorWidgetPrivate::CppEditorWidgetPrivate(CppEditorWidget *q)
|
CppEditorWidgetPrivate::CppEditorWidgetPrivate(CppEditorWidget *q)
|
||||||
@@ -361,7 +359,7 @@ void CppEditorWidget::findUsages()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorWidget::renameUsages(const QString &replacement)
|
void CppEditorWidget::renameUsagesInternal(const QString &replacement)
|
||||||
{
|
{
|
||||||
if (!d->m_modelManager)
|
if (!d->m_modelManager)
|
||||||
return;
|
return;
|
||||||
@@ -522,7 +520,7 @@ void CppEditorWidget::renameSymbolUnderCursor()
|
|||||||
using ClangBackEnd::SourceLocationsContainer;
|
using ClangBackEnd::SourceLocationsContainer;
|
||||||
|
|
||||||
ProjectPart *projPart = projectPart();
|
ProjectPart *projPart = projectPart();
|
||||||
if (!refactoringEngine()->isUsable() || !projPart)
|
if (!refactoringEngine().isUsable() || !projPart)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d->m_useSelectionsUpdater.abortSchedule();
|
d->m_useSelectionsUpdater.abortSchedule();
|
||||||
@@ -546,14 +544,14 @@ void CppEditorWidget::renameSymbolUnderCursor()
|
|||||||
d->m_localRenaming.updateSelectionsForVariableUnderCursor(selections);
|
d->m_localRenaming.updateSelectionsForVariableUnderCursor(selections);
|
||||||
}
|
}
|
||||||
if (!d->m_localRenaming.start()) {
|
if (!d->m_localRenaming.start()) {
|
||||||
refactoringEngine()->startGlobalRenaming(
|
refactoringEngine().startGlobalRenaming(
|
||||||
CppTools::CursorInEditor{textCursor(), textDocument()->filePath(), this});
|
CppTools::CursorInEditor{textCursor(), textDocument()->filePath(), this});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
viewport()->setCursor(Qt::BusyCursor);
|
viewport()->setCursor(Qt::BusyCursor);
|
||||||
refactoringEngine()->startLocalRenaming(CppTools::CursorInEditor{textCursor(),
|
refactoringEngine().startLocalRenaming(CppTools::CursorInEditor{textCursor(),
|
||||||
textDocument()->filePath(),
|
textDocument()->filePath(),
|
||||||
this},
|
this},
|
||||||
projPart,
|
projPart,
|
||||||
@@ -682,11 +680,9 @@ RefactorMarkers CppEditorWidget::refactorMarkersWithoutClangMarkers() const
|
|||||||
return clearedRefactorMarkers;
|
return clearedRefactorMarkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefactoringEngineInterface *CppEditorWidget::refactoringEngine() const
|
RefactoringEngineInterface &CppEditorWidget::refactoringEngine() const
|
||||||
{
|
{
|
||||||
RefactoringEngineInterface *engine = CppTools::CppModelManager::refactoringEngine();
|
return CppTools::CppModelManager::refactoringEngine();
|
||||||
return engine ? engine
|
|
||||||
: static_cast<RefactoringEngineInterface *>(&d->m_builtinRefactoringEngine);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CppTools::FollowSymbolInterface &CppEditorWidget::followSymbolInterface() const
|
CppTools::FollowSymbolInterface &CppEditorWidget::followSymbolInterface() const
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ public:
|
|||||||
|
|
||||||
void findUsages();
|
void findUsages();
|
||||||
void renameSymbolUnderCursor();
|
void renameSymbolUnderCursor();
|
||||||
void renameUsages(const QString &replacement = QString());
|
|
||||||
|
|
||||||
bool selectBlockUp() override;
|
bool selectBlockUp() override;
|
||||||
bool selectBlockDown() override;
|
bool selectBlockDown() override;
|
||||||
@@ -106,6 +105,8 @@ protected:
|
|||||||
|
|
||||||
void slotCodeStyleSettingsChanged(const QVariant &) override;
|
void slotCodeStyleSettingsChanged(const QVariant &) override;
|
||||||
|
|
||||||
|
void renameUsagesInternal(const QString &replacement) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateFunctionDeclDefLink();
|
void updateFunctionDeclDefLink();
|
||||||
void updateFunctionDeclDefLinkNow();
|
void updateFunctionDeclDefLinkNow();
|
||||||
@@ -138,7 +139,7 @@ private:
|
|||||||
TextEditor::RefactorMarkers refactorMarkersWithoutClangMarkers() const;
|
TextEditor::RefactorMarkers refactorMarkersWithoutClangMarkers() const;
|
||||||
|
|
||||||
CppTools::FollowSymbolInterface &followSymbolInterface() const;
|
CppTools::FollowSymbolInterface &followSymbolInterface() const;
|
||||||
CppTools::RefactoringEngineInterface *refactoringEngine() const;
|
CppTools::RefactoringEngineInterface &refactoringEngine() const;
|
||||||
|
|
||||||
CppTools::ProjectPart *projectPart() const;
|
CppTools::ProjectPart *projectPart() const;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include <texteditor/codeassist/assistenums.h>
|
#include <texteditor/codeassist/assistenums.h>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
namespace TextEditor { class IAssistProvider; }
|
namespace TextEditor { class IAssistProvider; }
|
||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
@@ -36,8 +38,14 @@ namespace CppTools {
|
|||||||
class CPPTOOLS_EXPORT CppEditorWidgetInterface
|
class CPPTOOLS_EXPORT CppEditorWidgetInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
void renameUsages(const QString &replacement = QString())
|
||||||
|
{
|
||||||
|
return renameUsagesInternal(replacement);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void showPreProcessorWidget() = 0;
|
virtual void showPreProcessorWidget() = 0;
|
||||||
virtual void updateSemanticInfo() = 0;
|
virtual void updateSemanticInfo() = 0;
|
||||||
|
virtual void renameUsagesInternal(const QString &replacement) = 0;
|
||||||
|
|
||||||
virtual void invokeTextEditorWidgetAssist(TextEditor::AssistKind assistKind,
|
virtual void invokeTextEditorWidgetAssist(TextEditor::AssistKind assistKind,
|
||||||
TextEditor::IAssistProvider *provider) = 0;
|
TextEditor::IAssistProvider *provider) = 0;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "cppindexingsupport.h"
|
#include "cppindexingsupport.h"
|
||||||
#include "cppmodelmanagersupportinternal.h"
|
#include "cppmodelmanagersupportinternal.h"
|
||||||
#include "cpprefactoringchanges.h"
|
#include "cpprefactoringchanges.h"
|
||||||
|
#include "cpprefactoringengine.h"
|
||||||
#include "cppsourceprocessor.h"
|
#include "cppsourceprocessor.h"
|
||||||
#include "cpptoolsconstants.h"
|
#include "cpptoolsconstants.h"
|
||||||
#include "cpptoolsplugin.h"
|
#include "cpptoolsplugin.h"
|
||||||
@@ -165,7 +166,8 @@ public:
|
|||||||
QTimer m_delayedGcTimer;
|
QTimer m_delayedGcTimer;
|
||||||
|
|
||||||
// Refactoring
|
// Refactoring
|
||||||
RefactoringEngineInterface *m_refactoringEngine = nullptr;
|
CppRefactoringEngine m_builtInRefactoringEngine;
|
||||||
|
RefactoringEngineInterface *m_refactoringEngine { &m_builtInRefactoringEngine };
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -267,12 +269,15 @@ QString CppModelManager::editorConfigurationFileName()
|
|||||||
|
|
||||||
void CppModelManager::setRefactoringEngine(RefactoringEngineInterface *refactoringEngine)
|
void CppModelManager::setRefactoringEngine(RefactoringEngineInterface *refactoringEngine)
|
||||||
{
|
{
|
||||||
instance()->d->m_refactoringEngine = refactoringEngine;
|
if (refactoringEngine)
|
||||||
|
instance()->d->m_refactoringEngine = refactoringEngine;
|
||||||
|
else
|
||||||
|
instance()->d->m_refactoringEngine = &instance()->d->m_builtInRefactoringEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefactoringEngineInterface *CppModelManager::refactoringEngine()
|
RefactoringEngineInterface &CppModelManager::refactoringEngine()
|
||||||
{
|
{
|
||||||
return instance()->d->m_refactoringEngine;
|
return *instance()->d->m_refactoringEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
FollowSymbolInterface &CppModelManager::followSymbolInterface() const
|
FollowSymbolInterface &CppModelManager::followSymbolInterface() const
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public:
|
|||||||
static QString editorConfigurationFileName();
|
static QString editorConfigurationFileName();
|
||||||
|
|
||||||
static void setRefactoringEngine(RefactoringEngineInterface *refactoringEngine);
|
static void setRefactoringEngine(RefactoringEngineInterface *refactoringEngine);
|
||||||
static RefactoringEngineInterface *refactoringEngine();
|
static RefactoringEngineInterface &refactoringEngine();
|
||||||
|
|
||||||
void renameIncludes(const QString &oldFileName, const QString &newFileName);
|
void renameIncludes(const QString &oldFileName, const QString &newFileName);
|
||||||
|
|
||||||
|
|||||||
@@ -24,18 +24,17 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "cpprefactoringengine.h"
|
#include "cpprefactoringengine.h"
|
||||||
#include "cppeditorwidget.h"
|
#include "texteditor/texteditor.h"
|
||||||
|
|
||||||
#include "utils/qtcassert.h"
|
#include "utils/qtcassert.h"
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppTools {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
void CppRefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
|
void CppRefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||||
CppTools::ProjectPart *,
|
CppTools::ProjectPart *,
|
||||||
RenameCallback &&renameSymbolsCallback)
|
RenameCallback &&renameSymbolsCallback)
|
||||||
{
|
{
|
||||||
CppEditorWidget *editorWidget = dynamic_cast<CppEditorWidget *>(data.editorWidget());
|
CppEditorWidgetInterface *editorWidget = data.editorWidget();
|
||||||
QTC_ASSERT(editorWidget, renameSymbolsCallback(QString(),
|
QTC_ASSERT(editorWidget, renameSymbolsCallback(QString(),
|
||||||
ClangBackEnd::SourceLocationsContainer(),
|
ClangBackEnd::SourceLocationsContainer(),
|
||||||
0); return;);
|
0); return;);
|
||||||
@@ -43,16 +42,14 @@ void CppRefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &da
|
|||||||
// Call empty callback
|
// Call empty callback
|
||||||
renameSymbolsCallback(QString(),
|
renameSymbolsCallback(QString(),
|
||||||
ClangBackEnd::SourceLocationsContainer(),
|
ClangBackEnd::SourceLocationsContainer(),
|
||||||
editorWidget->document()->revision());
|
data.cursor().document()->revision());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppRefactoringEngine::startGlobalRenaming(const CppTools::CursorInEditor &data)
|
void CppRefactoringEngine::startGlobalRenaming(const CppTools::CursorInEditor &data)
|
||||||
{
|
{
|
||||||
CppEditorWidget *editorWidget = dynamic_cast<CppEditorWidget *>(data.editorWidget());
|
CppEditorWidgetInterface *editorWidget = data.editorWidget();
|
||||||
if (!editorWidget)
|
QTC_ASSERT(editorWidget, return;);
|
||||||
return;
|
|
||||||
editorWidget->renameUsages();
|
editorWidget->renameUsages();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace CppEditor
|
} // namespace CppEditor
|
||||||
@@ -25,14 +25,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cpptools/refactoringengineinterface.h>
|
#include "refactoringengineinterface.h"
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppTools {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class CppEditorWidget;
|
class CPPTOOLS_EXPORT CppRefactoringEngine : public RefactoringEngineInterface
|
||||||
|
|
||||||
class CppRefactoringEngine : public CppTools::RefactoringEngineInterface
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void startLocalRenaming(const CppTools::CursorInEditor &data,
|
void startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||||
@@ -43,5 +40,4 @@ public:
|
|||||||
bool isUsable() const override { return true; }
|
bool isUsable() const override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace CppEditor
|
} // namespace CppEditor
|
||||||
@@ -51,6 +51,7 @@ HEADERS += \
|
|||||||
cppqtstyleindenter.h \
|
cppqtstyleindenter.h \
|
||||||
cpprawprojectpart.h \
|
cpprawprojectpart.h \
|
||||||
cpprefactoringchanges.h \
|
cpprefactoringchanges.h \
|
||||||
|
cpprefactoringengine.h \
|
||||||
cppselectionchanger.h \
|
cppselectionchanger.h \
|
||||||
cppsemanticinfo.h \
|
cppsemanticinfo.h \
|
||||||
cppsemanticinfoupdater.h \
|
cppsemanticinfoupdater.h \
|
||||||
@@ -143,6 +144,7 @@ SOURCES += \
|
|||||||
cppqtstyleindenter.cpp \
|
cppqtstyleindenter.cpp \
|
||||||
cpprawprojectpart.cpp \
|
cpprawprojectpart.cpp \
|
||||||
cpprefactoringchanges.cpp \
|
cpprefactoringchanges.cpp \
|
||||||
|
cpprefactoringengine.cpp \
|
||||||
cppselectionchanger.cpp \
|
cppselectionchanger.cpp \
|
||||||
cppsemanticinfoupdater.cpp \
|
cppsemanticinfoupdater.cpp \
|
||||||
cppsourceprocessor.cpp \
|
cppsourceprocessor.cpp \
|
||||||
|
|||||||
@@ -136,6 +136,8 @@ Project {
|
|||||||
"cpprawprojectpart.h",
|
"cpprawprojectpart.h",
|
||||||
"cpprefactoringchanges.cpp",
|
"cpprefactoringchanges.cpp",
|
||||||
"cpprefactoringchanges.h",
|
"cpprefactoringchanges.h",
|
||||||
|
"cpprefactoringengine.cpp",
|
||||||
|
"cpprefactoringengine.h",
|
||||||
"cppselectionchanger.cpp",
|
"cppselectionchanger.cpp",
|
||||||
"cppselectionchanger.h",
|
"cppselectionchanger.h",
|
||||||
"cppsemanticinfo.h",
|
"cppsemanticinfo.h",
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "cpptools_global.h"
|
||||||
#include "cursorineditor.h"
|
#include "cursorineditor.h"
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <clangsupport/sourcelocationscontainer.h>
|
#include <clangsupport/sourcelocationscontainer.h>
|
||||||
@@ -46,7 +48,7 @@ enum class CallType
|
|||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: This interface is not supposed to be owned as an interface pointer
|
// NOTE: This interface is not supposed to be owned as an interface pointer
|
||||||
class RefactoringEngineInterface
|
class CPPTOOLS_EXPORT RefactoringEngineInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using RenameCallback = ClangBackEnd::RefactoringClientInterface::RenameCallback;
|
using RenameCallback = ClangBackEnd::RefactoringClientInterface::RenameCallback;
|
||||||
|
|||||||
Reference in New Issue
Block a user