Sha256: 990d0cdb4fbdec0625d588686737692ce5716ca933acd3c349d2e773cbaa51d3

Contents?: true

Size: 696 Bytes

Versions: 11

Compression:

Stored size: 696 Bytes

Contents

module Parser
  class Rewriter < Parser::AST::Processor
    def rewrite(source_buffer, ast)
      @source_rewriter = Source::Rewriter.new(source_buffer)

      process(ast)

      @source_rewriter.process
    end

    private

    def assignment?(node)
      [:lvasgn, :ivasgn, :gvasgn, :cvasgn, :casgn].include?(node.type)
    end

    def remove(range)
      @source_rewriter.remove(range)
    end

    def insert_before(range, content)
      @source_rewriter.insert_before(range, content)
    end

    def insert_after(range, content)
      @source_rewriter.insert_after(range, content)
    end

    def replace(range, content)
      @source_rewriter.replace(range, content)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
parser-2.0.0.pre1 lib/parser/rewriter.rb
parser-2.0.0.beta10 lib/parser/rewriter.rb
parser-2.0.0.beta9 lib/parser/rewriter.rb
parser-2.0.0.beta8 lib/parser/rewriter.rb
parser-2.0.0.beta7 lib/parser/rewriter.rb
parser-2.0.0.beta6 lib/parser/rewriter.rb
parser-2.0.0.beta5 lib/parser/rewriter.rb
parser-2.0.0.beta4 lib/parser/rewriter.rb
parser-2.0.0.beta3 lib/parser/rewriter.rb
parser-2.0.0.beta2 lib/parser/rewriter.rb
parser-2.0.0.beta1 lib/parser/rewriter.rb