[Qt-creator] Offset issue with CPlusPlus::TranslationUnit::getPosition()

Carel Combrink carel.combrink at gmail.com
Tue Jan 27 20:10:21 CET 2015


Hi,

I have created a SpellChecker Plugin for QtCreator but I have an issue
where if a comment contains a 'non-standard' character, (รถ - QChar(246)).

I get a comment using the TranslationUnit::commentAt() function then split
the comment into words. For each word I get the row and column number of
the word in the file with the TranslationUnit::getPosition() function.

If a comment contains the above character, that comment is fine, no
problems.

But for any comment block after the comment with the char the getPosition()
function returns the position with a offset for each issue char from the
correct position. For instance if there are 4 characters in preceding
comment blocks the location of the word is 4 rows offset from where it
should be.

See attached an example of the issue cause by this. In the first comment,
the mistake is underlined correctly. In the second comment the character in
question appears and the mistakes in the comment are still underlined
correctly. While in the last comment the mistake is shown one char offset
from where it should be (column 16 instead of 15 in the output pane).

The code for my plugin can be found on GitHub: SpellChecker-Plugin
<https://github.com/CJCombrink/SpellChecker-Plugin>
The function that iterates the comments: parseCppDocument()
<https://github.com/CJCombrink/SpellChecker-Plugin/blob/master/Parsers/CppParser/cppdocumentparser.cpp#L190>
The function that calls getPosition(): tokenizeWords()
<https://github.com/CJCombrink/SpellChecker-Plugin/blob/master/Parsers/CppParser/cppdocumentparser.cpp#L229>

Is this a bug or am I doing something wrong?

Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20150127/9c88fb1b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SpellChecker_Issue28_2.png
Type: image/png
Size: 21262 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20150127/9c88fb1b/attachment.png>


More information about the Qt-creator mailing list