Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/prism/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def self.with_file(filepath)
# The version constant is set by reading the result of calling pm_version.
VERSION = LibRubyParser.pm_version.read_string.freeze

class << self
class << self # :nodoc:
# Mirror the Prism.dump API by using the serialization API.
def dump(source, **options)
LibRubyParser::PrismString.with_string(source) { |string| dump_common(string, options) }
Expand Down Expand Up @@ -554,7 +554,7 @@ def dump_options(options)

# Here we are going to patch StringQuery to put in the class-level methods so
# that it can maintain a consistent interface
class StringQuery
class StringQuery # :nodoc:
class << self
# Mirrors the C extension's StringQuery::local? method.
def local?(string)
Expand Down
2 changes: 1 addition & 1 deletion lib/prism/lex_compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(value, comments, magic_comments, data_loc, errors, warnings, sour
end

# Implement the hash pattern matching interface for Result.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
super.merge!(value: value)
end
end
Expand Down
40 changes: 20 additions & 20 deletions lib/prism/parse_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def deep_freeze

# Binary search through the offsets to find the line number for the given
# byte offset.
def find_line(byte_offset)
def find_line(byte_offset) # :nodoc:
index = offsets.bsearch_index { |offset| offset > byte_offset } || offsets.length
index - 1
end
Expand Down Expand Up @@ -350,7 +350,7 @@ def chop
end

# Returns a string representation of this location.
def inspect
def inspect # :nodoc:
"#<Prism::Location @start_offset=#{@start_offset} @length=#{@length} start_line=#{start_line}>"
end

Expand Down Expand Up @@ -477,12 +477,12 @@ def cached_end_code_units_column(cache)
end

# Implement the hash pattern matching interface for Location.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
{ start_offset: start_offset, end_offset: end_offset }
end

# Implement the pretty print interface for Location.
def pretty_print(q)
def pretty_print(q) # :nodoc:
q.text("(#{start_line},#{start_column})-(#{end_line},#{end_column})")
end

Expand Down Expand Up @@ -528,7 +528,7 @@ def initialize(location)
end

# Implement the hash pattern matching interface for Comment.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
{ location: location }
end

Expand All @@ -548,7 +548,7 @@ def trailing?
end

# Returns a string representation of this comment.
def inspect
def inspect # :nodoc:
"#<Prism::InlineComment @location=#{location.inspect}>"
end
end
Expand All @@ -562,7 +562,7 @@ def trailing?
end

# Returns a string representation of this comment.
def inspect
def inspect # :nodoc:
"#<Prism::EmbDocComment @location=#{location.inspect}>"
end
end
Expand Down Expand Up @@ -592,12 +592,12 @@ def value
end

# Implement the hash pattern matching interface for MagicComment.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
{ key_loc: key_loc, value_loc: value_loc }
end

# Returns a string representation of this magic comment.
def inspect
def inspect # :nodoc:
"#<Prism::MagicComment @key=#{key.inspect} @value=#{value.inspect}>"
end
end
Expand Down Expand Up @@ -626,12 +626,12 @@ def initialize(type, message, location, level)
end

# Implement the hash pattern matching interface for ParseError.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
{ type: type, message: message, location: location, level: level }
end

# Returns a string representation of this error.
def inspect
def inspect # :nodoc:
"#<Prism::ParseError @type=#{@type.inspect} @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>"
end
end
Expand Down Expand Up @@ -660,12 +660,12 @@ def initialize(type, message, location, level)
end

# Implement the hash pattern matching interface for ParseWarning.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
{ type: type, message: message, location: location, level: level }
end

# Returns a string representation of this warning.
def inspect
def inspect # :nodoc:
"#<Prism::ParseWarning @type=#{@type.inspect} @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>"
end
end
Expand Down Expand Up @@ -705,7 +705,7 @@ def initialize(comments, magic_comments, data_loc, errors, warnings, source)
end

# Implement the hash pattern matching interface for Result.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
{ comments: comments, magic_comments: magic_comments, data_loc: data_loc, errors: errors, warnings: warnings }
end

Expand Down Expand Up @@ -752,7 +752,7 @@ def initialize(value, comments, magic_comments, data_loc, errors, warnings, sour
end

# Implement the hash pattern matching interface for ParseResult.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
super.merge!(value: value)
end

Expand Down Expand Up @@ -786,7 +786,7 @@ def initialize(value, comments, magic_comments, data_loc, errors, warnings, sour
end

# Implement the hash pattern matching interface for LexResult.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
super.merge!(value: value)
end
end
Expand All @@ -804,7 +804,7 @@ def initialize(value, comments, magic_comments, data_loc, errors, warnings, sour
end

# Implement the hash pattern matching interface for ParseLexResult.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
super.merge!(value: value)
end
end
Expand All @@ -830,7 +830,7 @@ def initialize(source, type, value, location)
end

# Implement the hash pattern matching interface for Token.
def deconstruct_keys(keys)
def deconstruct_keys(keys) # :nodoc:
{ type: type, value: value, location: location }
end

Expand All @@ -842,7 +842,7 @@ def location
end

# Implement the pretty print interface for Token.
def pretty_print(q)
def pretty_print(q) # :nodoc:
q.group do
q.text(type.to_s)
self.location.pretty_print(q)
Expand All @@ -864,7 +864,7 @@ def ==(other)
end

# Returns a string representation of this token.
def inspect
def inspect # :nodoc:
location
super
end
Expand Down
28 changes: 14 additions & 14 deletions lib/prism/pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,23 @@ def scan(root)

# Shortcut for combining two procs into one that returns true if both return
# true.
def combine_and(left, right)
def combine_and(left, right) # :nodoc:
->(other) { left.call(other) && right.call(other) }
end

# Shortcut for combining two procs into one that returns true if either
# returns true.
def combine_or(left, right)
def combine_or(left, right) # :nodoc:
->(other) { left.call(other) || right.call(other) }
end

# Raise an error because the given node is not supported.
def compile_error(node)
def compile_error(node) # :nodoc:
raise CompilationError, node.inspect
end

# in [foo, bar, baz]
def compile_array_pattern_node(node)
def compile_array_pattern_node(node) # :nodoc:
compile_error(node) if !node.rest.nil? || node.posts.any?

constant = node.constant
Expand All @@ -141,12 +141,12 @@ def compile_array_pattern_node(node)
end

# in foo | bar
def compile_alternation_pattern_node(node)
def compile_alternation_pattern_node(node) # :nodoc:
combine_or(compile_node(node.left), compile_node(node.right))
end

# in Prism::ConstantReadNode
def compile_constant_path_node(node)
def compile_constant_path_node(node) # :nodoc:
parent = node.parent

if parent.is_a?(ConstantReadNode) && parent.slice == "Prism"
Expand All @@ -161,12 +161,12 @@ def compile_constant_path_node(node)

# in ConstantReadNode
# in String
def compile_constant_read_node(node)
def compile_constant_read_node(node) # :nodoc:
compile_constant_name(node, node.name)
end

# Compile a name associated with a constant.
def compile_constant_name(node, name)
def compile_constant_name(node, name) # :nodoc:
if Prism.const_defined?(name, false)
clazz = Prism.const_get(name)

Expand All @@ -182,7 +182,7 @@ def compile_constant_name(node, name)

# in InstanceVariableReadNode[name: Symbol]
# in { name: Symbol }
def compile_hash_pattern_node(node)
def compile_hash_pattern_node(node) # :nodoc:
compile_error(node) if node.rest
compiled_constant = compile_node(node.constant) if node.constant

Expand Down Expand Up @@ -212,36 +212,36 @@ def compile_hash_pattern_node(node)
end

# in nil
def compile_nil_node(node)
def compile_nil_node(node) # :nodoc:
->(attribute) { attribute.nil? }
end

# in /foo/
def compile_regular_expression_node(node)
def compile_regular_expression_node(node) # :nodoc:
regexp = Regexp.new(node.unescaped, node.closing[1..])

->(attribute) { regexp === attribute }
end

# in ""
# in "foo"
def compile_string_node(node)
def compile_string_node(node) # :nodoc:
string = node.unescaped

->(attribute) { string === attribute }
end

# in :+
# in :foo
def compile_symbol_node(node)
def compile_symbol_node(node) # :nodoc:
symbol = node.unescaped.to_sym

->(attribute) { symbol === attribute }
end

# Compile any kind of node. Dispatch out to the individual compilation
# methods based on the type of node.
def compile_node(node)
def compile_node(node) # :nodoc:
case node
when AlternationPatternNode
compile_alternation_pattern_node(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/prism/translation/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Parser < ::Parser::Base
# The parser gem has a list of diagnostics with a hard-coded set of error
# messages. We create our own diagnostic class in order to set our own
# error messages.
class PrismDiagnostic < Diagnostic
class PrismDiagnostic < Diagnostic # :nodoc:
# This is the cached message coming from prism.
attr_reader :message

Expand Down
4 changes: 2 additions & 2 deletions lib/prism/translation/parser/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module Translation
class Parser
# A visitor that knows how to convert a prism syntax tree into the
# whitequark/parser gem's syntax tree.
class Compiler < ::Prism::Compiler
class Compiler < ::Prism::Compiler # :nodoc:
# Raised when the tree is malformed or there is a bug in the compiler.
class CompilationError < StandardError
class CompilationError < StandardError # :nodoc:
end

# The Parser::Base instance that is being used to build the AST.
Expand Down
8 changes: 4 additions & 4 deletions lib/prism/translation/parser/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Translation
class Parser
# Accepts a list of prism tokens and converts them into the expected
# format for the parser gem.
class Lexer
class Lexer # :nodoc:
# These tokens are always skipped
TYPES_ALWAYS_SKIP = Set.new(%i[IGNORED_NEWLINE __END__ EOF])
private_constant :TYPES_ALWAYS_SKIP
Expand Down Expand Up @@ -188,8 +188,8 @@ class Lexer
# without them. We should find another way to do this, but in the
# meantime we'll hide them from the documentation and mark them as
# private constants.
EXPR_BEG = 0x1 # :nodoc:
EXPR_LABEL = 0x400 # :nodoc:
EXPR_BEG = 0x1
EXPR_LABEL = 0x400

# It is used to determine whether `do` is of the token type `kDO` or `kDO_LAMBDA`.
#
Expand Down Expand Up @@ -232,7 +232,7 @@ def initialize(source_buffer, lexed, offset_cache)
@offset_cache = offset_cache
end

Range = ::Parser::Source::Range # :nodoc:
Range = ::Parser::Source::Range
private_constant :Range

# Convert the prism tokens into the expected format for the parser gem.
Expand Down
4 changes: 4 additions & 0 deletions lib/prism/translation/ripper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ def parse
# Visitor methods
##########################################################################

# :stopdoc:

# alias foo bar
# ^^^^^^^^^^^^^
def visit_alias_method_node(node)
Expand Down Expand Up @@ -3458,6 +3460,8 @@ def bounds(location)
@column = location.start_column
end

# :startdoc:

##########################################################################
# Ripper interface
##########################################################################
Expand Down
7 changes: 2 additions & 5 deletions lib/prism/translation/ripper/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ module Prism
module Translation
class Ripper
class Lexer < Ripper # :nodoc:
# :stopdoc:
class State
class State # :nodoc:
attr_reader :to_int, :to_s

def initialize(i)
Expand Down Expand Up @@ -48,7 +47,7 @@ def self.[](i)
end
end

class Elem
class Elem # :nodoc:
attr_accessor :pos, :event, :tok, :state, :message

def initialize(pos, event, tok, state, message = nil)
Expand Down Expand Up @@ -128,8 +127,6 @@ def parse(...)
def scan(...)
parse(...)
end

# :startdoc:
end
end
end
Expand Down
Loading