MPS 2020.3 ヘルプ


MPS で高品質のコードを維持するための非常に効果的な方法の 1 つは、エラー、警告、または潜在的な問題をコード内で直接ハイライトする即時のコード分析です。他のコード品質報告ツールと同様に、ユーザーが誤検知をマークして繰り返し報告されないようにできることが不可欠です。MPS はエラーを抑制するために 2 つのメカニズムを提供し、それらがエディターおよびモデルチェッカーツールに表示されるのを防ぎます。

The first is the general one that can be utilized by language developers. When designing a language extention or embedding existing language into the new one there can appear some places which are considered as errors by the checker of existing language but in fact are valid in terms of languages' combination. In such cases false errors can be suppressed by implementing the ISuppressErrors interface by the binding concept of the new language. Another place where this feature is also useful are the generators, since type errors, for example, are sometimes unavoidable in the templates. By default, if some concept implements the ISuppressErrors interface, all language issues on this node and all its descendants will be hidden. For example, comments in BaseLanguage implement ISupressErrors. Additionally, if a node has an attribute of a concept that implements ISuppressErrors, issues in such node will be suppressed too. It is also possible to suppress issues selectively, defining certain descendants in which issues should be suppressed and kinds of such issues. Customization can be implemented by overriding the boolean method suppress(ReportItem) of the ISupressErrors interface.

The second mechanism is implemented as the special case of the first one but is intended not for language developers but for the users of the languages. If some checker is known to issue false positives, user might want to mark these places in his model. Though language developer can make such possibility part of the language, MPS has a convenience default implementation of an ISuppressErrors node attribute called SuppressErrorsAttribute. It can be applied to only those nodes that are instances of ICanSuppressErrors.

An example of using the SuppressErrorsAttribute attribute and the corresponding intention.

エディターには 3 つのエラーがあり、そのうちの 2 つは文字列リテラルに関するものです。


BaseLanguage Statement implements ICanSuppressErrors, so the user can apply intention to suppress either this very kind of errors (string literals) anywhere within the statement or every typesystem errors: