Utils: remove now unused Utils::Text::Replacement

They have been completely replaced by Utils::ChangeSet.

Change-Id: I857816c1b2730699ba481da2e271dde358f394f3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2023-07-04 10:56:11 +02:00
parent 4743724d4c
commit 13ccc24a35
2 changed files with 0 additions and 39 deletions

View File

@@ -252,26 +252,6 @@ bool utf8AdvanceCodePoint(const char *&current)
return true; return true;
} }
void applyReplacements(QTextDocument *doc, const Replacements &replacements)
{
if (replacements.empty())
return;
int fullOffsetShift = 0;
QTextCursor editCursor(doc);
editCursor.beginEditBlock();
for (const Text::Replacement &replacement : replacements) {
editCursor.setPosition(replacement.offset + fullOffsetShift);
editCursor.movePosition(QTextCursor::NextCharacter,
QTextCursor::KeepAnchor,
replacement.length);
editCursor.removeSelectedText();
editCursor.insertText(replacement.text);
fullOffsetShift += replacement.text.length() - replacement.length;
}
editCursor.endEditBlock();
}
QDebug &operator<<(QDebug &stream, const Position &pos) QDebug &operator<<(QDebug &stream, const Position &pos)
{ {
stream << "line: " << pos.line << ", column: " << pos.column; stream << "line: " << pos.line << ", column: " << pos.column;

View File

@@ -49,25 +49,6 @@ public:
bool operator!=(const Range &other) const { return !(operator==(other)); } bool operator!=(const Range &other) const { return !(operator==(other)); }
}; };
struct Replacement
{
Replacement() = default;
Replacement(int offset, int length, const QString &text)
: offset(offset)
, length(length)
, text(text)
{}
int offset = -1;
int length = -1;
QString text;
bool isValid() const { return offset >= 0 && length >= 0; }
};
using Replacements = std::vector<Replacement>;
QTCREATOR_UTILS_EXPORT void applyReplacements(QTextDocument *doc, const Replacements &replacements);
// line is 1-based, column is 0-based // line is 1-based, column is 0-based
QTCREATOR_UTILS_EXPORT bool convertPosition(const QTextDocument *document, QTCREATOR_UTILS_EXPORT bool convertPosition(const QTextDocument *document,
int pos, int pos,