Class: RuboCop::AST::PrismPreparsed
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rubocop/ast/processed_source.rb |
Overview
A Prism
interface’s class that provides a fixed Prism::ParseLexResult
instead of parsing.
This class implements the #parse_lex method to return a preparsed Prism::ParseLexResult
rather than parsing the source code. When the parse result is already available externally,
such as in Ruby LSP, the Prism parsing process can be bypassed.
Class Method Summary
- .new(prism_result) ⇒ PrismPreparsed constructor
Instance Method Summary
Constructor Details
.new(prism_result) ⇒ PrismPreparsed
# File 'lib/rubocop/ast/processed_source.rb', line 13
def initialize(prism_result) unless prism_result.is_a?(Prism::ParseLexResult) raise ArgumentError, <<~MESSAGE Expected a `Prism::ParseLexResult` object, but received `#{prism_result.class}`. MESSAGE end @prism_result = prism_result end
Instance Method Details
#parse_lex(_source, **_prism_options)
[ GitHub ]# File 'lib/rubocop/ast/processed_source.rb', line 23
def parse_lex(_source, ** ) @prism_result end