[Qt-creator] Issue parsing QStringLiteral() in SpellChecker Plugin

Typz thetypz at gmail.com
Sun Jul 26 18:41:45 CEST 2015


Hello,

At the moment, there are two "levels" of preprocessing: full preprocessor is used for code analysis, while "fast preprocessor" is used for highlighting...

With fast preprocessor, QStringLiteral should not be expanded. So just running fast preprocessor on the source code before parsing strings should solve the problem.

As for matching position, I remember there used to be some functions in c++ editor, which are used for highlighting macros... That was some time ago though, it may have changed since...

Congratulations for making this great plugin, Best Regards,

-- 
Francois

> On 25 juil. 2015, at 22:30, Carel Combrink <carel.combrink at gmail.com> wrote:
> 
> 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
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20150726/0a9b1d13/attachment.html>


More information about the Qt-creator mailing list