Find mis-matched syntax based on lexical count

Used for detecting missing pairs of elements each keyword needs an end, each ‘{’ needs a ‘}’ etc.

Example:

left_right = LeftRightLexCount.new
left_right.count_kw
left_right.missing.first
# => "end"

left_right = LeftRightLexCount.new
source = "{ a: b, c: d" # Note missing '}'
LexAll.new(source: source).each do |lex|
  left_right.count_lex(lex)
end
left_right.missing.first
# => "}"
Constants
No documentation available
Class Methods
No documentation available
Instance Methods
No documentation available
No documentation available
No documentation available

Count source code characters

Example:

left_right = LeftRightLexCount.new
left_right.count_lex(LexValue.new(1, :on_lbrace, "{", Ripper::EXPR_BEG))
left_right.count_for_char("{")
# => 1
left_right.count_for_char("}")
# => 0

Returns an array of missing syntax characters or ‘“end”` or `“keyword”`

left_right.missing
# => ["}"]

Keywords need ends and ends need keywords

If we have more keywords, there’s a missing ‘end` if we have more `end`-s, there’s a missing keyword

Opening characters like ‘{` need closing characters # like `}`.

When a mis-match count is detected, suggest the missing member.

For example if there are 3 ‘}` and only two `{` return `“{”`

Pipes come in pairs. If there’s an odd number of pipes then we are missing one