Sha256: 867cb8b147402b985d3ecbcabdaaa17dee1510e3e99db575c2e455d4bd4256a6
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
module CodeRay module Encoders load :lint # = Debug Lint Encoder # # Debug encoder with additional checks for: # # - empty tokens # - incorrect nesting # # It will raise an InvalidTokenStream exception when any of the above occurs. # # See also: Encoders::Debug class DebugLint < Debug register_for :debug_lint def text_token text, kind raise Lint::EmptyToken, 'empty token' if text.empty? super end def begin_group kind @opened << kind super end def end_group kind raise Lint::IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_group)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind @opened.pop super end def begin_line kind @opened << kind super end def end_line kind raise Lint::IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_line)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind @opened.pop super end protected def setup options super @opened = [] end def finish options raise 'Some tokens still open at end of token stream: %p' % [@opened] unless @opened.empty? super end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
coderay-1.1.0.rc2 | lib/coderay/encoders/debug_lint.rb |
coderay-1.1.0.rc1 | lib/coderay/encoders/debug_lint.rb |