CppEditor: Remove WorkingCopy::{revision,source}(QString) overloads

... and fix fallout.

Change-Id: I3748d0f90345c0d92321d465abfc3d324ee49a0c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2022-11-23 17:21:15 +01:00
parent f2f1b7c2d7
commit 9ceaf39929
3 changed files with 31 additions and 37 deletions

View File

@@ -3,8 +3,6 @@
#include "cpprefactoringchanges.h"
#include "cppqtstyleindenter.h"
#include "cppcodeformatter.h"
#include "cppeditorconstants.h"
#include <projectexplorer/editorconfiguration.h>
@@ -12,16 +10,18 @@
#include <utils/qtcassert.h>
#include <texteditor/icodestylepreferencesfactory.h>
#include <texteditor/tabsettings.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditorsettings.h>
#include <QTextDocument>
using namespace CPlusPlus;
using namespace Utils;
namespace CppEditor {
static std::unique_ptr<TextEditor::Indenter> createIndenter(const Utils::FilePath &filePath,
static std::unique_ptr<TextEditor::Indenter> createIndenter(const FilePath &filePath,
QTextDocument *textDocument)
{
TextEditor::ICodeStylePreferencesFactory *factory
@@ -48,18 +48,17 @@ CppRefactoringFilePtr CppRefactoringChanges::file(TextEditor::TextEditorWidget *
return result;
}
CppRefactoringFilePtr CppRefactoringChanges::file(const Utils::FilePath &filePath) const
CppRefactoringFilePtr CppRefactoringChanges::file(const FilePath &filePath) const
{
CppRefactoringFilePtr result(new CppRefactoringFile(filePath, m_data));
return result;
}
CppRefactoringFileConstPtr CppRefactoringChanges::fileNoEditor(const Utils::FilePath &filePath) const
CppRefactoringFileConstPtr CppRefactoringChanges::fileNoEditor(const FilePath &filePath) const
{
QTextDocument *document = nullptr;
const QString fileName = filePath.toString();
if (data()->m_workingCopy.contains(fileName))
document = new QTextDocument(QString::fromUtf8(data()->m_workingCopy.source(fileName)));
if (data()->m_workingCopy.contains(filePath))
document = new QTextDocument(QString::fromUtf8(data()->m_workingCopy.source(filePath)));
CppRefactoringFilePtr result(new CppRefactoringFile(document, filePath));
result->m_data = m_data;
@@ -71,14 +70,14 @@ const Snapshot &CppRefactoringChanges::snapshot() const
return data()->m_snapshot;
}
CppRefactoringFile::CppRefactoringFile(const Utils::FilePath &filePath, const QSharedPointer<TextEditor::RefactoringChangesData> &data)
CppRefactoringFile::CppRefactoringFile(const FilePath &filePath, const QSharedPointer<TextEditor::RefactoringChangesData> &data)
: RefactoringFile(filePath, data)
{
const Snapshot &snapshot = this->data()->m_snapshot;
m_cppDocument = snapshot.document(filePath.toString());
}
CppRefactoringFile::CppRefactoringFile(QTextDocument *document, const Utils::FilePath &filePath)
CppRefactoringFile::CppRefactoringFile(QTextDocument *document, const FilePath &filePath)
: RefactoringFile(document, filePath)
{ }
@@ -134,7 +133,7 @@ bool CppRefactoringFile::isCursorOn(const AST *ast) const
return cursorBegin >= start && cursorBegin <= end;
}
Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
{
const Token &token = tokenAt(tokenIndex);
int line, column;
@@ -143,7 +142,7 @@ Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
return {start, start + token.utf16chars()};
}
Utils::ChangeSet::Range CppRefactoringFile::range(const AST *ast) const
ChangeSet::Range CppRefactoringFile::range(const AST *ast) const
{
return {startOf(ast), endOf(ast)};
}
@@ -218,7 +217,7 @@ CppRefactoringChangesData::CppRefactoringChangesData(const Snapshot &snapshot)
{}
void CppRefactoringChangesData::indentSelection(const QTextCursor &selection,
const Utils::FilePath &filePath,
const FilePath &filePath,
const TextEditor::TextDocument *textDocument) const
{
if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat
@@ -231,7 +230,7 @@ void CppRefactoringChangesData::indentSelection(const QTextCursor &selection,
}
void CppRefactoringChangesData::reindentSelection(const QTextCursor &selection,
const Utils::FilePath &filePath,
const FilePath &filePath,
const TextEditor::TextDocument *textDocument) const
{
if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat
@@ -243,9 +242,9 @@ void CppRefactoringChangesData::reindentSelection(const QTextCursor &selection,
}
}
void CppRefactoringChangesData::fileChanged(const Utils::FilePath &filePath)
void CppRefactoringChangesData::fileChanged(const FilePath &filePath)
{
m_modelManager->updateSourceFiles({filePath.toString()});
}
} // namespace CppEditor
} // CppEditor