[Qt-creator] Issue parsing QStringLiteral() in SpellChecker Plugin
Carel Combrink
carel.combrink at gmail.com
Sat Jul 25 22:30:59 CEST 2015
Hi Guys,
I saw that my SpellChecker Plugin does not handle string literals enclosed
in QStringLiteral(). correctly. I am pretty sure it is because
QStringLiteral() is a macro that expands to the actual code to handle the
literal.
The issue with this is, that I need to parse the string to check for
spelling mistakes and then if there are mistakes, underline the misspelled
word and give the user the options to replace the misspelled word.
Due to the expansion of the macro, I am finding it rather hard to get the
position of the words as the user sees it, not my plugin. For example if I
have a mistake on "line: 8, Col: 63" (reported by QtC), my parser sees 2
instances of the word at (10:65) and (10:232).
How do I extract the 'correct location' (Location in the IDE) for the
QStringLiteral() expansion?
I have started searching and looked a bit at the WrapStringLiteral class
(part of CppQuickfixes) and it seems like the WrapStringLiteral::analyze()
function can do what I need. I am not sure how to use this, or implement
something similar.
Any help will be greatly appreciated.
PS: I will also be very grateful if this solution can be used to also know
which strings are translatable strings (enclosed in tr()). I would like to
add the option to my plugin to let the user request that only string
literals that will be translated be parsed.
---
Check out my SpellChecker Plugin for Qt Creator on github @
https://github.com/CJCombrink/SpellChecker-Plugin
Regards,
Carel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20150725/0905cc59/attachment.html>
More information about the Qt-creator
mailing list