Module: RuboCop::Erb::ProcessedSourceHelper

Defined in:
lib/rubocop/erb/processed_source_helper.rb

Class Method Summary collapse

Class Method Details

.code_to_processed_source(input_processed_source, path, code) ⇒ RuboCop::ProcessedSource

Creates a new ProcessedSource, inheriting state from a donor

Parameters:

  • input_processed_source (RuboCop::ProcessedSource)
  • code (String)

Returns:

  • (RuboCop::ProcessedSource)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubocop/erb/processed_source_helper.rb', line 11

def self.code_to_processed_source(input_processed_source, path, code)
  supports_prism = input_processed_source.respond_to?(:parser_engine)
  processed_source = if supports_prism
                       ::RuboCop::ProcessedSource.new(
                         code,
                         input_processed_source.ruby_version,
                         path,
                         parser_engine: input_processed_source.parser_engine
                       )
                     else
                       ::RuboCop::ProcessedSource.new(
                         code,
                         input_processed_source.ruby_version,
                         path
                       )
                     end
  processed_source.config = input_processed_source.config
  processed_source.registry = input_processed_source.registry
  processed_source
end