diff options
author | Gopal Patel <[email protected]> | 2023-12-18 14:22:21 -0800 |
---|---|---|
committer | git <[email protected]> | 2024-02-24 03:39:19 +0000 |
commit | b9b0712556980a3af91c976c3fee8ba0e21c39a0 () | |
tree | c8ed2454b0e26d4aed8ea5391f2a735e6f9327f1 /lib | |
parent | fc656acee9d17f72d9f7b09630d7f03e981beef3 (diff) |
[ruby/prism] Use steep to type check RBS and Ruby files
https://.com/ruby/prism/commit/eabed9f4fd
-rw-r--r-- | lib/prism/debug.rb | 6 | ||||
-rw-r--r-- | lib/prism/desugar_compiler.rb | 2 | ||||
-rw-r--r-- | lib/prism/lex_compat.rb | 32 | ||||
-rw-r--r-- | lib/prism/node_ext.rb | 4 | ||||
-rw-r--r-- | lib/prism/pack.rb | 2 | ||||
-rw-r--r-- | lib/prism/parse_result/comments.rb | 6 | ||||
-rw-r--r-- | lib/prism/prism.gemspec | 20 |
7 files changed, 47 insertions, 25 deletions
@@ -55,7 +55,7 @@ module Prism verbose, $VERBOSE = $VERBOSE, nil begin - locals = [] stack = [ISeq.new(RubyVM::InstructionSequence.compile(source).to_a)] while (iseq = stack.pop) @@ -96,8 +96,8 @@ module Prism # For the given source, parses with prism and returns a list of all of the # sets of local variables that were encountered. def self.prism_locals(source) - locals = [] - stack = [Prism.parse(source).value] while (node = stack.pop) case node @@ -82,7 +82,7 @@ module Prism 0, read_class.new(source, *arguments, node.name_loc), nil, - node.operator_loc.slice.chomp("="), node.operator_loc.copy(length: node.operator_loc.length - 1), nil, ArgumentsNode.new(source, 0, [node.value], node.value.location), @@ -185,6 +185,8 @@ module Prism # However, we add a couple of convenience methods onto them to make them a # little easier to work with. We delegate all other methods to the array. class Token < SimpleDelegator # The location of the token in the source. def location self[0] @@ -241,10 +243,10 @@ module Prism def ==(other) # :nodoc: return false unless self[0...-1] == other[0...-1] - if self[4] == Ripper::EXPR_ARG | Ripper::EXPR_LABELED - other[4] & Ripper::EXPR_ARG | Ripper::EXPR_LABELED > 0 else - self[4] == other[4] end end end @@ -308,7 +310,7 @@ module Prism def to_a embexpr_balance = 0 - tokens.each_with_object([]) do |token, results| case token.event when :on_embexpr_beg embexpr_balance += 1 @@ -409,7 +411,7 @@ module Prism # If every line in the heredoc is blank, we still need to split up the # string content token into multiple tokens. if dedent.nil? - results = [] embexpr_balance = 0 tokens.each do |token| @@ -444,7 +446,7 @@ module Prism # If the minimum common whitespace is 0, then we need to concatenate # string nodes together that are immediately adjacent. if dedent == 0 - results = [] embexpr_balance = 0 index = 0 @@ -477,7 +479,7 @@ module Prism # insert on_ignored_sp tokens for the amount of dedent that we need to # perform. We also need to remove the dedent from the beginning of # each line of plain string content tokens. - results = [] dedent_next = true embexpr_balance = 0 @@ -526,7 +528,7 @@ module Prism # dedent from the beginning of the line. if (dedent > 0) && (dedent_next || index > 0) deleting = 0 - deleted_chars = [] # Gather up all of the characters that we're going to # delete, stopping when you hit a character that would put @@ -603,15 +605,15 @@ module Prism end def result - tokens = [] state = :default - heredoc_stack = [[]] result = Prism.lex(source, **options) result_value = result.value - previous_state = nil - last_heredoc_end = nil # In previous versions of Ruby, Ripper wouldn't flush the bom before the # first token, so we had to have a hack in place to account for that. This @@ -842,7 +844,7 @@ module Prism # We sort by location to compare against Ripper's output tokens.sort_by!(&:location) - ParseResult.new(tokens, result.comments, result.magic_comments, result.data_loc, result.errors, result.warnings, []) end end @@ -858,8 +860,8 @@ module Prism end def result - previous = [] - results = [] lex(source).each do |token| case token[1] @@ -169,7 +169,7 @@ module Prism class ParametersNode < Node # Mirrors the Method#parameters method. def signature - names = [] requireds.each do |param| names << (param.is_a?(MultiTargetNode) ? [:req] : [:req, param.name]) @@ -184,7 +184,7 @@ module Prism # Regardless of the order in which the keywords were defined, the required # keywords always come first followed by the optional keywords. - keyopt = [] keywords.each do |param| if param.is_a?(OptionalKeywordParameterNode) keyopt << param @@ -148,6 +148,8 @@ module Prism end when LENGTH_MAX base + ", as many as possible" end when UTF8 "UTF-8 character" @@ -120,7 +120,7 @@ module Prism comment_start = comment.location.start_offset comment_end = comment.location.end_offset - targets = [] node.comment_targets.map do |value| case value when StatementsNode @@ -133,8 +133,8 @@ module Prism end targets.sort_by!(&:start_offset) - preceding = nil - following = nil left = 0 right = targets.length @@ -122,8 +122,26 @@ Gem::Specification.new do |spec| "src/options.c", "src/prism.c", "prism.gemspec", "sig/prism.rbs", - "sig/prism_static.rbs", "rbi/prism.rbi", "rbi/prism_static.rbi" ] |