Sha256: ca0da2962dc1b9c220f40ce8aa1d74b45ebed30e4516c0899784c1694c7e3bc1

Contents?: true

Size: 1.43 KB

Versions: 6913

Compression:

Stored size: 1.43 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 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
    
    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

6,913 entries across 6,901 versions & 70 rubygems

Version Path
lazy_record-0.1.4 vendor/bundle/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
tdiary-5.0.4 vendor/bundle/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
lazy_record-0.1.3 vendor/bundle/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
lazy_record-0.1.2 vendor/bundle/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
lazy_record-0.1.1 vendor/bundle/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
lazy_record-0.1.0 vendor/bundle/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
logstash-input-fifo-0.9.1 vendor/bundle/jruby/1.9/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
logstash-input-fifo-0.9.0 vendor/bundle/jruby/1.9/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
abaci-0.3.0 vendor/bundle/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
gameboard-3.1.0 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
gameboard-3.0.0 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/coderay-1.1.1/lib/coderay/encoders/debug_lint.rb