Skip to content

Commit

Permalink
Rename local_variable_assign_code generator method name
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Oct 9, 2022
1 parent da04c25 commit 08c5575
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/irb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ def assignment_expression?(line)
# array of parsed expressions. The first element of each expression is the
# expression's type.
verbose, $VERBOSE = $VERBOSE, nil
code = "#{RubyLex.local_variables_assign_code(context: @context) || 'nil;'}\n#{line}"
code = "#{RubyLex.generate_local_variables_assign_code(context: @context) || 'nil;'}\n#{line}"
node_type = Ripper.sexp(code)&.dig(1)&.drop(1)&.dig(-1, 0)
result = ASSIGNMENT_NODE_TYPES.include?(node_type)
$VERBOSE = verbose
Expand Down
2 changes: 1 addition & 1 deletion lib/irb/color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def colorize_code(code, complete: true, ignore_error: false, colorable: colorabl

symbol_state = SymbolState.new
colored = +''
lvars_code = RubyLex.local_variables_assign_code(local_variables: local_variables)
lvars_code = RubyLex.generate_local_variables_assign_code(local_variables: local_variables)
code_with_lvars = lvars_code ? "#{lvars_code}\n#{code}" : code

scan(code_with_lvars, allow_last_error: !complete) do |token, str, expr|
Expand Down
6 changes: 3 additions & 3 deletions lib/irb/ruby-lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ def set_prompt(p = nil, &block)
:on_param_error
]

def self.local_variables_assign_code(context: nil, local_variables: [])
def self.generate_local_variables_assign_code(context: nil, local_variables: [])
context_local_variables = context&.workspace&.binding&.local_variables
local_variables |= context_local_variables if context_local_variables
"#{local_variables.join('=')}=nil;" unless local_variables.empty?
end

def self.ripper_lex_without_warning(code, context: nil)
verbose, $VERBOSE = $VERBOSE, nil
lvars_code = local_variables_assign_code(context: context)
lvars_code = generate_local_variables_assign_code(context: context)
if lvars_code
code = "#{lvars_code}\n#{code}"
line_no = 0
Expand Down Expand Up @@ -218,7 +218,7 @@ def check_state(code, tokens = nil, context: nil)
ltype = process_literal_type(tokens)
indent = process_nesting_level(tokens)
continue = process_continue(tokens)
lvars_code = self.class.local_variables_assign_code(context: context)
lvars_code = self.class.generate_local_variables_assign_code(context: context)
code = "#{lvars_code}\n#{code}" if lvars_code
code_block_open = check_code_block(code, tokens)
[ltype, indent, continue, code_block_open]
Expand Down

0 comments on commit 08c5575

Please sign in to comment.