Class: I18n::Tasks::Scanners::AstMatchers::DefaultI18nSubjectMatcher

Inherits:
BaseMatcher
  • Object
show all
Defined in:
lib/i18n/tasks/scanners/ast_matchers/default_i18n_subject_matcher.rb

Instance Method Summary collapse

Methods inherited from BaseMatcher

#initialize

Constructor Details

This class inherits a constructor from I18n::Tasks::Scanners::AstMatchers::BaseMatcher

Instance Method Details

#convert_to_key_occurrences(send_node, method_name, location: send_node.loc) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/i18n/tasks/scanners/ast_matchers/default_i18n_subject_matcher.rb', line 8

def convert_to_key_occurrences(send_node, method_name, location: send_node.loc)
  children = Array(send_node&.children)
  return unless children[1] == :default_i18n_subject

  key = @scanner.absolute_key(
    '.subject',
    location.expression.source_buffer.name,
    calling_method: method_name
  )
  [
    key,
    I18n::Tasks::Scanners::Results::Occurrence.from_range(
      raw_key: key,
      range: location.expression
    )
  ]
end