class CodeRay::Encoders::DebugLint
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
Public Instance Methods
begin_group(kind)
click to toggle source
Calls superclass method
CodeRay::Encoders::Debug#begin_group
# File lib/coderay/encoders/debug_lint.rb, line 26 def begin_group kind @opened << kind super end
begin_line(kind)
click to toggle source
Calls superclass method
CodeRay::Encoders::Debug#begin_line
# File lib/coderay/encoders/debug_lint.rb, line 37 def begin_line kind @opened << kind super end
end_group(kind)
click to toggle source
Calls superclass method
CodeRay::Encoders::Debug#end_group
# File lib/coderay/encoders/debug_lint.rb, line 31 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
end_line(kind)
click to toggle source
Calls superclass method
CodeRay::Encoders::Debug#end_line
# File lib/coderay/encoders/debug_lint.rb, line 42 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
text_token(text, kind)
click to toggle source
Calls superclass method
CodeRay::Encoders::Debug#text_token
# File lib/coderay/encoders/debug_lint.rb, line 20 def text_token text, kind raise Lint::EmptyToken, 'empty token for %p' % [kind] if text.empty? raise Lint::UnknownTokenKind, 'unknown token kind %p (text was %p)' % [kind, text] unless TokenKinds.has_key? kind super end
Protected Instance Methods
finish(options)
click to toggle source
Calls superclass method
# File lib/coderay/encoders/debug_lint.rb, line 55 def finish options raise 'Some tokens still open at end of token stream: %p' % [@opened] unless @opened.empty? super end
setup(options)
click to toggle source
Calls superclass method
# File lib/coderay/encoders/debug_lint.rb, line 50 def setup options super @opened = [] end