Skip to content

Commit

Permalink
[ruby/prism] Replace awkward code changes with steep:ignore
Browse files Browse the repository at this point in the history
Also remove RBS for currently ignored files. Will follow-up when those
check fully in later PRs.

ruby/prism@2cae58f86d
  • Loading branch information
nixme authored and matzbot committed Feb 24, 2024
1 parent 66565e3 commit dfee033
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/prism.rb
Expand Up @@ -44,7 +44,7 @@ module Prism
#
# For supported options, see Prism::parse.
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

# :call-seq:
Expand All @@ -54,7 +54,7 @@ def self.lex_compat(source, **options)
# returns the same tokens. Raises SyntaxError if the syntax in source is
# invalid.
def self.lex_ripper(source)
LexRipper.new(source).result
LexRipper.new(source).result # steep:ignore
end

# :call-seq:
Expand Down
7 changes: 1 addition & 6 deletions lib/prism/parse_result/comments.rb
Expand Up @@ -188,12 +188,7 @@ def nearest_targets(node, comment)

# Attach the list of comments to their respective locations in the tree.
def attach_comments!
if ProgramNode === value
this = self #: ParseResult[ProgramNode]
Comments.new(this).attach!
else
raise
end
Comments.new(self).attach! # steep:ignore
end
end
end
6 changes: 1 addition & 5 deletions lib/prism/parse_result/newlines.rb
Expand Up @@ -58,11 +58,7 @@ def visit_statements_node(node)

# Walk the tree and mark nodes that are on a new line.
def mark_newlines!
if ProgramNode === value
value.accept(Newlines.new(Array.new(1 + source.offsets.size, false)))
else
raise "ParseResult does not contain ProgramNode value"
end
value.accept(Newlines.new(Array.new(1 + source.offsets.size, false))) # steep:ignore
end
end
end
3 changes: 1 addition & 2 deletions lib/prism/pattern.rb
Expand Up @@ -87,11 +87,10 @@ def scan(root)
return to_enum(__method__ || raise, root) unless block_given?

@compiled ||= compile
compiled = @compiled #: Proc
queue = [root]

while (node = queue.shift)
yield node if compiled.call(node)
yield node if @compiled.call(node) # steep:ignore
queue.concat(node.compact_child_nodes)
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/prism/prism.gemspec
Expand Up @@ -133,7 +133,6 @@ Gem::Specification.new do |spec|
"sig/prism/pack.rbs",
"sig/prism/parse_result.rbs",
"sig/prism/pattern.rbs",
"sig/prism/ripper_compat.rbs",
"sig/prism/serialize.rbs",
"sig/prism/visitor.rbs",
"rbi/prism.rbi",
Expand Down
2 changes: 1 addition & 1 deletion lib/prism/translation.rb
Expand Up @@ -3,7 +3,7 @@
module Prism
# This module is responsible for converting the prism syntax tree into other
# syntax trees.
module Translation
module Translation # steep:ignore
autoload :Parser, "prism/translation/parser"
autoload :Ripper, "prism/translation/ripper"
autoload :RubyParser, "prism/translation/ruby_parser"
Expand Down
3 changes: 1 addition & 2 deletions prism/templates/template.rb
Expand Up @@ -588,8 +588,7 @@ def locals
"sig/prism/mutation_compiler.rbs",
"sig/prism/node.rbs",
"sig/prism/visitor.rbs",
"sig/prism/_private/dot_visitor.rbs",
"sig/prism/_private/ripper_compat.rbs",
"sig/prism/_private/dot_visitor.rbs"
]
end

Expand Down

0 comments on commit dfee033

Please sign in to comment.