Clang: Add commentary about column convertion

... to/from utf8 byte offset used by Clang.

Change-Id: I294d6cd61b416e5f2d64206ee2f3f1b4a91fb1d3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-01-26 17:04:38 +01:00
parent 0c50d54da7
commit fbbdfd2444
6 changed files with 20 additions and 4 deletions

View File

@@ -190,5 +190,15 @@ void setLastSentDocumentRevision(const QString &filePath, uint revision)
document->sendTracker().setLastSentRevision(int(revision));
}
int clangColumn(const QString &lineText, int cppEditorColumn)
{
// (1) cppEditorColumn is the actual column shown by CppEditor.
// (2) The return value is the column in Clang which is the utf8 byte offset from the beginning
// of the line.
// Here we convert column from (1) to (2).
// '+ 1' is for 1-based columns
return lineText.left(cppEditorColumn).toUtf8().size() + 1;
}
} // namespace Utils
} // namespace Clang