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:
		| @@ -29,6 +29,8 @@ | ||||
|  | ||||
| #include <texteditor/codeassist/assistenums.h> | ||||
|  | ||||
| #include <QString> | ||||
|  | ||||
| namespace TextEditor { class IAssistProvider; } | ||||
|  | ||||
| namespace CppTools { | ||||
| @@ -36,8 +38,14 @@ namespace CppTools { | ||||
| class CPPTOOLS_EXPORT CppEditorWidgetInterface | ||||
| { | ||||
| public: | ||||
|     void renameUsages(const QString &replacement = QString()) | ||||
|     { | ||||
|         return renameUsagesInternal(replacement); | ||||
|     } | ||||
|  | ||||
|     virtual void showPreProcessorWidget() = 0; | ||||
|     virtual void updateSemanticInfo() = 0; | ||||
|     virtual void renameUsagesInternal(const QString &replacement) = 0; | ||||
|  | ||||
|     virtual void invokeTextEditorWidgetAssist(TextEditor::AssistKind assistKind, | ||||
|                                               TextEditor::IAssistProvider *provider) = 0; | ||||
|   | ||||
| @@ -33,6 +33,7 @@ | ||||
| #include "cppindexingsupport.h" | ||||
| #include "cppmodelmanagersupportinternal.h" | ||||
| #include "cpprefactoringchanges.h" | ||||
| #include "cpprefactoringengine.h" | ||||
| #include "cppsourceprocessor.h" | ||||
| #include "cpptoolsconstants.h" | ||||
| #include "cpptoolsplugin.h" | ||||
| @@ -165,7 +166,8 @@ public: | ||||
|     QTimer m_delayedGcTimer; | ||||
|  | ||||
|     // Refactoring | ||||
|     RefactoringEngineInterface *m_refactoringEngine = nullptr; | ||||
|     CppRefactoringEngine m_builtInRefactoringEngine; | ||||
|     RefactoringEngineInterface *m_refactoringEngine { &m_builtInRefactoringEngine }; | ||||
| }; | ||||
|  | ||||
| } // namespace Internal | ||||
| @@ -267,12 +269,15 @@ QString CppModelManager::editorConfigurationFileName() | ||||
|  | ||||
| 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 | ||||
|   | ||||
| @@ -180,7 +180,7 @@ public: | ||||
|     static QString editorConfigurationFileName(); | ||||
|  | ||||
|     static void setRefactoringEngine(RefactoringEngineInterface *refactoringEngine); | ||||
|     static RefactoringEngineInterface *refactoringEngine(); | ||||
|     static RefactoringEngineInterface &refactoringEngine(); | ||||
|  | ||||
|     void renameIncludes(const QString &oldFileName, const QString &newFileName); | ||||
|  | ||||
|   | ||||
							
								
								
									
										55
									
								
								src/plugins/cpptools/cpprefactoringengine.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								src/plugins/cpptools/cpprefactoringengine.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| /**************************************************************************** | ||||
| ** | ||||
| ** Copyright (C) 2017 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. | ||||
| ** | ||||
| ****************************************************************************/ | ||||
|  | ||||
| #include "cpprefactoringengine.h" | ||||
| #include "texteditor/texteditor.h" | ||||
|  | ||||
| #include "utils/qtcassert.h" | ||||
|  | ||||
| namespace CppTools { | ||||
|  | ||||
| void CppRefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data, | ||||
|                                               CppTools::ProjectPart *, | ||||
|                                               RenameCallback &&renameSymbolsCallback) | ||||
| { | ||||
|     CppEditorWidgetInterface *editorWidget = data.editorWidget(); | ||||
|     QTC_ASSERT(editorWidget, renameSymbolsCallback(QString(), | ||||
|                                                    ClangBackEnd::SourceLocationsContainer(), | ||||
|                                                    0); return;); | ||||
|     editorWidget->updateSemanticInfo(); | ||||
|     // Call empty callback | ||||
|     renameSymbolsCallback(QString(), | ||||
|                           ClangBackEnd::SourceLocationsContainer(), | ||||
|                           data.cursor().document()->revision()); | ||||
| } | ||||
|  | ||||
| void CppRefactoringEngine::startGlobalRenaming(const CppTools::CursorInEditor &data) | ||||
| { | ||||
|     CppEditorWidgetInterface *editorWidget = data.editorWidget(); | ||||
|     QTC_ASSERT(editorWidget, return;); | ||||
|     editorWidget->renameUsages(); | ||||
| } | ||||
|  | ||||
| } // namespace CppEditor | ||||
							
								
								
									
										43
									
								
								src/plugins/cpptools/cpprefactoringengine.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/plugins/cpptools/cpprefactoringengine.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| /**************************************************************************** | ||||
| ** | ||||
| ** Copyright (C) 2017 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 "refactoringengineinterface.h" | ||||
|  | ||||
| namespace CppTools { | ||||
|  | ||||
| class CPPTOOLS_EXPORT CppRefactoringEngine : public RefactoringEngineInterface | ||||
| { | ||||
| public: | ||||
|     void startLocalRenaming(const CppTools::CursorInEditor &data, | ||||
|                             CppTools::ProjectPart *projectPart, | ||||
|                             RenameCallback &&renameSymbolsCallback) override; | ||||
|     void startGlobalRenaming(const CppTools::CursorInEditor &data) override; | ||||
|  | ||||
|     bool isUsable() const override { return true; } | ||||
| }; | ||||
|  | ||||
| } // namespace CppEditor | ||||
| @@ -51,6 +51,7 @@ HEADERS += \ | ||||
|     cppqtstyleindenter.h \ | ||||
|     cpprawprojectpart.h \ | ||||
|     cpprefactoringchanges.h \ | ||||
|     cpprefactoringengine.h \ | ||||
|     cppselectionchanger.h \ | ||||
|     cppsemanticinfo.h \ | ||||
|     cppsemanticinfoupdater.h \ | ||||
| @@ -143,6 +144,7 @@ SOURCES += \ | ||||
|     cppqtstyleindenter.cpp \ | ||||
|     cpprawprojectpart.cpp \ | ||||
|     cpprefactoringchanges.cpp \ | ||||
|     cpprefactoringengine.cpp \ | ||||
|     cppselectionchanger.cpp \ | ||||
|     cppsemanticinfoupdater.cpp \ | ||||
|     cppsourceprocessor.cpp \ | ||||
|   | ||||
| @@ -136,6 +136,8 @@ Project { | ||||
|             "cpprawprojectpart.h", | ||||
|             "cpprefactoringchanges.cpp", | ||||
|             "cpprefactoringchanges.h", | ||||
|             "cpprefactoringengine.cpp", | ||||
|             "cpprefactoringengine.h", | ||||
|             "cppselectionchanger.cpp", | ||||
|             "cppselectionchanger.h", | ||||
|             "cppsemanticinfo.h", | ||||
|   | ||||
| @@ -25,7 +25,9 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include "cpptools_global.h" | ||||
| #include "cursorineditor.h" | ||||
|  | ||||
| #include <utils/fileutils.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 | ||||
| class RefactoringEngineInterface | ||||
| class CPPTOOLS_EXPORT RefactoringEngineInterface | ||||
| { | ||||
| public: | ||||
|     using RenameCallback = ClangBackEnd::RefactoringClientInterface::RenameCallback; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user