QML Static Analysis 3 - Fixit Hints
In this chapter we learn how to improve our custom warnings by amending them with fixit hints.
So far, we only created warning messages. However, sometimes we also want to add a tip for the user how to fix the code. For that, we can pass an instance of FixSuggestion
to emitWarning. A fix suggestion always consists of a description of what should be fixed, and the location where it should apply. It can also feature a replacement text. By default, the replacement text is only shown in the diagnostic message. By calling setAutoApplicable(true)
on the FixSuggestion
, the user can however apply the fix automatically via qmllint or the QML language server. It is important to only mark the suggestion as auto-applicable if the resulting code is valid.
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.