TextEditor: Remove RefactoringFile::m_data

There is no use for a generic data member.

Change-Id: Iabfbc0587db2cffcc1c19baed832aa866f696ffe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2023-11-16 17:24:51 +01:00
parent 1c8ac2e7d3
commit 5d6fc1fc3b
6 changed files with 19 additions and 36 deletions

View File

@@ -52,7 +52,7 @@ CppRefactoringFilePtr CppRefactoringChanges::file(TextEditor::TextEditorWidget *
TextEditor::RefactoringFilePtr CppRefactoringChanges::file(const FilePath &filePath) const
{
CppRefactoringFilePtr result(new CppRefactoringFile(filePath, m_data));
CppRefactoringFilePtr result(new CppRefactoringFile(filePath, m_data.staticCast<CppRefactoringChangesData>()));
return result;
}
@@ -67,7 +67,7 @@ CppRefactoringFileConstPtr CppRefactoringChanges::fileNoEditor(const FilePath &f
if (const auto source = data()->m_workingCopy.source(filePath))
document = new QTextDocument(QString::fromUtf8(*source));
CppRefactoringFilePtr result(new CppRefactoringFile(document, filePath));
result->m_data = m_data;
result->m_data = m_data.staticCast<CppRefactoringChangesData>();
return result;
}
@@ -77,10 +77,10 @@ const Snapshot &CppRefactoringChanges::snapshot() const
return data()->m_snapshot;
}
CppRefactoringFile::CppRefactoringFile(const FilePath &filePath, const QSharedPointer<TextEditor::RefactoringChangesData> &data)
: RefactoringFile(filePath, data)
CppRefactoringFile::CppRefactoringFile(const FilePath &filePath, const QSharedPointer<CppRefactoringChangesData> &data)
: RefactoringFile(filePath), m_data(data)
{
const Snapshot &snapshot = this->data()->m_snapshot;
const Snapshot &snapshot = data->m_snapshot;
m_cppDocument = snapshot.document(filePath);
m_formattingEnabled = true;
}
@@ -102,7 +102,7 @@ Document::Ptr CppRefactoringFile::cppDocument() const
if (!m_cppDocument || !m_cppDocument->translationUnit() ||
!m_cppDocument->translationUnit()->ast()) {
const QByteArray source = document()->toPlainText().toUtf8();
const Snapshot &snapshot = data()->m_snapshot;
const Snapshot &snapshot = m_data->m_snapshot;
m_cppDocument = snapshot.preprocessedDocument(source, filePath());
m_cppDocument->check();
@@ -239,11 +239,6 @@ const Token &CppRefactoringFile::tokenAt(unsigned index) const
return cppDocument()->translationUnit()->tokenAt(index);
}
CppRefactoringChangesData *CppRefactoringFile::data() const
{
return static_cast<CppRefactoringChangesData *>(m_data.data());
}
void CppRefactoringFile::fileChanged()
{
QTC_ASSERT(!m_filePath.isEmpty(), return);