QML 静的解析 3 - Fixit ヒント

この章では、fixit ヒントを使ってカスタム警告を改善する方法を学びます。

ここまでは、警告メッセージを作成するだけでした。しかし、コードを修正するためのヒントを追加したいこともあります。そのために、FixSuggestion のインスタンスをemitWarning に渡します。修正提案は常に、何を修正すべきかについての説明と、それが適用されるべき場所から構成されます。また、置換テキストを指定することもできます。デフォルトでは、置換テキストは診断メッセージにのみ表示されます。しかし、FixSuggestionsetAutoApplicable(true) を呼び出すと、qmllint や QML Language Server 経由で自動的に修正を適用することができます。ただし、自動適用されるコードが有効である場合のみ、自動適用可能としてマークすることが重要です。

© 2025 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.