Skip to content
Louis Kueh edited this page Nov 1, 2018 · 3 revisions

Every hint is formed of two parts: the match and the suggestion.

Match AST is analysed against the code looking for any expressions in the code that matches. If there is a match then the suggestion AST is used to display a suggestion on how the code can be refactored.

Matching

  • variable x
  • wildcard _

Use variables to match expressions

not ((4 + 4) >= (x + 77 * (9 * y)))

into

(4 + 4) < (x + 77 * (9 * y))
  • (4+4) = a
  • x + 77 * (9 * y)) = b and so the rule becomes
not (a >= b) ===> a <  b

Clone this wiki locally