Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Checking, (or Non-typesystem) rules can inspect the model searching for known error patterns in code and report them to the user. This code kind of pre-compilation code inspection is generally known as static code analysis. Error patterns in typical tools for static code analysis can fall into several categories, such as correctness problems, multi-threaded correctness, I18N problems, vulnerability-increasing errors, styling issues, performance problems, etc. The found issues are reported to the user either on-demand through an interactive report:

...

The jetbrains.mps.lang.typesystem language offers corresponding statements , plus a statement ensure, which that emit these problem categories together with their description and the node to highlight. The additional ensure statement gives the user a more succinct syntax to report an error in case a condition is not met:

...

Checking rules typically check for one or a few related issues in a given node or a small part of the model and report to the user, if a problem is discovered:

Quick-fixes

quick-fix provides a single model-transforming function, which will automatically eliminate the reported problem:

Image Added

quick-fix must provide a description to represent it in the Intentions context menu, unless it is only ever referred to from callers with apply immediately set to true. A quick-fix may also declare fields, to hold reused values, and it can accept arguments from the caller.

Invoking quick-fixes

A quick-fix may be associated with each reported problem through the Inspector tool window:

...

Normally the user invokes the quick-fix through the Intentions context menu, which is displayed after pressing the Alt + Enter key shortcut. If the apply immediately flag is set, however, MPS will run the associated quick-fix as soon as the problem is discovered during on-the-fly analysis without waiting for the user trigger.

quick-fix provides a single model-transforming function, which will automatically eliminate the reported problem:

Image Removed

quick-fix bus provide a description to represent it in the Intentions context menu, unless it is only ever referred to from callers with apply immediately set to true. A quick-fix may also declare fields, to hold reused values, and it can accept arguments from the caller.

The two other options are rarely needed:

  • node feature to highlight - specifies a node's property of reference to highlight, instead of highlighting the whole node
  • foreign message source - TODO

 

Previous Next