TextEditor: Introduce PlainRefactoringFileFactory

This makes it immediately clear that there are more specialized variants
available, which helps users make a conscious decision.

Change-Id: I35feb4bed2d91fb4f83ede6e731d9ce89fd4af3f
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2023-11-17 12:56:27 +01:00
parent 78b9edd251
commit cf74409bac
8 changed files with 23 additions and 20 deletions

View File

@@ -20,12 +20,12 @@ class QTextDocument;
QT_END_NAMESPACE
namespace TextEditor {
class TextDocument;
class TextEditorWidget;
class PlainRefactoringFileFactory;
class RefactoringFile;
using RefactoringFilePtr = QSharedPointer<RefactoringFile>;
class RefactoringFileFactory;
using RefactoringSelections = QVector<QPair<QTextCursor, QTextCursor>>;
class TextDocument;
class TextEditorWidget;
// ### listen to the m_editor::destroyed signal?
class TEXTEDITOR_EXPORT RefactoringFile
@@ -103,17 +103,20 @@ protected:
bool m_appliedOnce = false;
bool m_formattingEnabled = false;
friend class RefactoringFileFactory; // access to constructor
friend class PlainRefactoringFileFactory; // access to constructor
};
class TEXTEDITOR_EXPORT RefactoringFileFactory
{
public:
virtual ~RefactoringFileFactory();
virtual RefactoringFilePtr file(const Utils::FilePath &filePath) const = 0;
};
// TODO: Make pure virtual and introduce dedicated subclass for generic refactoring,
// so no one instantiates this one by mistake.
virtual RefactoringFilePtr file(const Utils::FilePath &filePath) const;
class TEXTEDITOR_EXPORT PlainRefactoringFileFactory final : public RefactoringFileFactory
{
public:
RefactoringFilePtr file(const Utils::FilePath &filePath) const override;
};
} // namespace TextEditor