[ruby/prism] Fix up linting in ripper translation
https://github.com/ruby/prism/commit/5cf5f15ee7
This commit is contained in:
parent
1966b5c8c6
commit
532ddc1745
@ -2943,6 +2943,7 @@ module Prism
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Visit a heredoc node that is representing a string.
|
||||||
private def visit_heredoc_string_node(node)
|
private def visit_heredoc_string_node(node)
|
||||||
bounds(node.opening_loc)
|
bounds(node.opening_loc)
|
||||||
on_heredoc_beg(node.opening)
|
on_heredoc_beg(node.opening)
|
||||||
@ -2959,6 +2960,7 @@ module Prism
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Visit a heredoc node that is representing an xstring.
|
||||||
private def visit_heredoc_x_string_node(node)
|
private def visit_heredoc_x_string_node(node)
|
||||||
bounds(node.opening_loc)
|
bounds(node.opening_loc)
|
||||||
on_heredoc_beg(node.opening)
|
on_heredoc_beg(node.opening)
|
||||||
|
@ -8,6 +8,8 @@ module Prism
|
|||||||
# This class mirrors the ::Ripper::SexpBuilder subclass of ::Ripper that
|
# This class mirrors the ::Ripper::SexpBuilder subclass of ::Ripper that
|
||||||
# returns the arrays of [type, *children].
|
# returns the arrays of [type, *children].
|
||||||
class SexpBuilder < Ripper
|
class SexpBuilder < Ripper
|
||||||
|
# :stopdoc:
|
||||||
|
|
||||||
attr_reader :error
|
attr_reader :error
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -62,12 +64,16 @@ module Prism
|
|||||||
remove_method :on_parse_error
|
remove_method :on_parse_error
|
||||||
alias on_parse_error on_error
|
alias on_parse_error on_error
|
||||||
alias compile_error on_error
|
alias compile_error on_error
|
||||||
|
|
||||||
|
# :startdoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
# This class mirrors the ::Ripper::SexpBuilderPP subclass of ::Ripper that
|
# This class mirrors the ::Ripper::SexpBuilderPP subclass of ::Ripper that
|
||||||
# returns the same values as ::Ripper::SexpBuilder except with a couple of
|
# returns the same values as ::Ripper::SexpBuilder except with a couple of
|
||||||
# niceties that flatten linked lists into arrays.
|
# niceties that flatten linked lists into arrays.
|
||||||
class SexpBuilderPP < SexpBuilder
|
class SexpBuilderPP < SexpBuilder
|
||||||
|
# :stopdoc:
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def on_heredoc_dedent(val, width)
|
def on_heredoc_dedent(val, width)
|
||||||
@ -111,6 +117,8 @@ module Prism
|
|||||||
alias_method "on_#{event}", :_dispatch_event_push
|
alias_method "on_#{event}", :_dispatch_event_push
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :startdoc:
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# This writes the prism ripper translation into the Ripper constant so that
|
||||||
|
# users can transparently use Ripper without any changes.
|
||||||
Ripper = Prism::Translation::Ripper
|
Ripper = Prism::Translation::Ripper
|
||||||
|
@ -6,7 +6,7 @@ module Prism
|
|||||||
module Translation
|
module Translation
|
||||||
# This module is the entry-point for converting a prism syntax tree into the
|
# This module is the entry-point for converting a prism syntax tree into the
|
||||||
# seattlerb/ruby_parser gem's syntax tree.
|
# seattlerb/ruby_parser gem's syntax tree.
|
||||||
module RubyParser
|
class RubyParser
|
||||||
# A prism visitor that builds Sexp objects.
|
# A prism visitor that builds Sexp objects.
|
||||||
class Compiler < ::Prism::Compiler
|
class Compiler < ::Prism::Compiler
|
||||||
# This is the name of the file that we are compiling. We set it on every
|
# This is the name of the file that we are compiling. We set it on every
|
||||||
@ -1490,7 +1490,6 @@ module Prism
|
|||||||
|
|
||||||
private_constant :Compiler
|
private_constant :Compiler
|
||||||
|
|
||||||
class << self
|
|
||||||
# Parse the given source and translate it into the seattlerb/ruby_parser
|
# Parse the given source and translate it into the seattlerb/ruby_parser
|
||||||
# gem's Sexp format.
|
# gem's Sexp format.
|
||||||
def parse(source, filepath = "(string)")
|
def parse(source, filepath = "(string)")
|
||||||
@ -1503,6 +1502,20 @@ module Prism
|
|||||||
translate(Prism.parse_file(filepath), filepath)
|
translate(Prism.parse_file(filepath), filepath)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class << self
|
||||||
|
# Parse the given source and translate it into the seattlerb/ruby_parser
|
||||||
|
# gem's Sexp format.
|
||||||
|
def parse(source, filepath = "(string)")
|
||||||
|
new.parse(source, filepath)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Parse the given file and translate it into the seattlerb/ruby_parser
|
||||||
|
# gem's Sexp format.
|
||||||
|
def parse_file(filepath)
|
||||||
|
new.parse_file(filepath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Translate the given parse result and filepath into the
|
# Translate the given parse result and filepath into the
|
||||||
@ -1517,5 +1530,4 @@ module Prism
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user