[ruby/prism] Replace awkward code changes with steep:ignore

Also remove RBS for currently ignored files. Will follow-up when those
check fully in later PRs.

https://github.com/ruby/prism/commit/2cae58f86d
This commit is contained in:
Gopal Patel 2024-02-20 13:48:31 -08:00 committed by git
parent 66565e36ea
commit dfee033746
7 changed files with 7 additions and 19 deletions

View File

@ -44,7 +44,7 @@ module Prism
# #
# For supported options, see Prism::parse. # For supported options, see Prism::parse.
def self.lex_compat(source, **options) def self.lex_compat(source, **options)
LexCompat.new(source, **options).result #: ParseResult[Array[[[Integer, Integer], Symbol, String, untyped]]] LexCompat.new(source, **options).result # steep:ignore
end end
# :call-seq: # :call-seq:
@ -54,7 +54,7 @@ module Prism
# returns the same tokens. Raises SyntaxError if the syntax in source is # returns the same tokens. Raises SyntaxError if the syntax in source is
# invalid. # invalid.
def self.lex_ripper(source) def self.lex_ripper(source)
LexRipper.new(source).result LexRipper.new(source).result # steep:ignore
end end
# :call-seq: # :call-seq:

View File

@ -188,12 +188,7 @@ module Prism
# Attach the list of comments to their respective locations in the tree. # Attach the list of comments to their respective locations in the tree.
def attach_comments! def attach_comments!
if ProgramNode === value Comments.new(self).attach! # steep:ignore
this = self #: ParseResult[ProgramNode]
Comments.new(this).attach!
else
raise
end
end end
end end
end end

View File

@ -58,11 +58,7 @@ module Prism
# Walk the tree and mark nodes that are on a new line. # Walk the tree and mark nodes that are on a new line.
def mark_newlines! def mark_newlines!
if ProgramNode === value value.accept(Newlines.new(Array.new(1 + source.offsets.size, false))) # steep:ignore
value.accept(Newlines.new(Array.new(1 + source.offsets.size, false)))
else
raise "ParseResult does not contain ProgramNode value"
end
end end
end end
end end

View File

@ -87,11 +87,10 @@ module Prism
return to_enum(__method__ || raise, root) unless block_given? return to_enum(__method__ || raise, root) unless block_given?
@compiled ||= compile @compiled ||= compile
compiled = @compiled #: Proc
queue = [root] queue = [root]
while (node = queue.shift) while (node = queue.shift)
yield node if compiled.call(node) yield node if @compiled.call(node) # steep:ignore
queue.concat(node.compact_child_nodes) queue.concat(node.compact_child_nodes)
end end
end end

View File

@ -133,7 +133,6 @@ Gem::Specification.new do |spec|
"sig/prism/pack.rbs", "sig/prism/pack.rbs",
"sig/prism/parse_result.rbs", "sig/prism/parse_result.rbs",
"sig/prism/pattern.rbs", "sig/prism/pattern.rbs",
"sig/prism/ripper_compat.rbs",
"sig/prism/serialize.rbs", "sig/prism/serialize.rbs",
"sig/prism/visitor.rbs", "sig/prism/visitor.rbs",
"rbi/prism.rbi", "rbi/prism.rbi",

View File

@ -3,7 +3,7 @@
module Prism module Prism
# This module is responsible for converting the prism syntax tree into other # This module is responsible for converting the prism syntax tree into other
# syntax trees. # syntax trees.
module Translation module Translation # steep:ignore
autoload :Parser, "prism/translation/parser" autoload :Parser, "prism/translation/parser"
autoload :Ripper, "prism/translation/ripper" autoload :Ripper, "prism/translation/ripper"
autoload :RubyParser, "prism/translation/ruby_parser" autoload :RubyParser, "prism/translation/ruby_parser"

View File

@ -588,8 +588,7 @@ module Prism
"sig/prism/mutation_compiler.rbs", "sig/prism/mutation_compiler.rbs",
"sig/prism/node.rbs", "sig/prism/node.rbs",
"sig/prism/visitor.rbs", "sig/prism/visitor.rbs",
"sig/prism/_private/dot_visitor.rbs", "sig/prism/_private/dot_visitor.rbs"
"sig/prism/_private/ripper_compat.rbs",
] ]
end end