Utils: Move common positionInText function to Utils::Text

Change-Id: I5d74a73058ca457b0fb3f13eaf945f224d5699fb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-06-15 14:33:01 +02:00
parent b6dfab804b
commit a91956f300
4 changed files with 29 additions and 26 deletions

View File

@@ -205,20 +205,16 @@ void ClangEditorDocumentProcessor::updateCodeWarnings(
}
namespace {
int positionInText(QTextDocument *textDocument,
const ClangBackEnd::SourceLocationContainer &sourceLocationContainer)
{
auto textBlock = textDocument->findBlockByNumber(int(sourceLocationContainer.line) - 1);
return textBlock.position() + int(sourceLocationContainer.column) - 1;
}
TextEditor::BlockRange
toTextEditorBlock(QTextDocument *textDocument,
const ClangBackEnd::SourceRangeContainer &sourceRangeContainer)
{
return TextEditor::BlockRange(positionInText(textDocument, sourceRangeContainer.start),
positionInText(textDocument, sourceRangeContainer.end));
return TextEditor::BlockRange(::Utils::Text::positionInText(textDocument,
sourceRangeContainer.start.line,
sourceRangeContainer.start.column),
::Utils::Text::positionInText(textDocument,
sourceRangeContainer.end.line,
sourceRangeContainer.end.column));
}
QList<TextEditor::BlockRange>