Class: RuboCop::AST::PrismPreparsed
- Inherits:
-
Object
- Object
- RuboCop::AST::PrismPreparsed
- 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.
Instance Method Summary collapse
-
#initialize(prism_result) ⇒ PrismPreparsed
constructor
A new instance of PrismPreparsed.
- #parse_lex(_source, **_prism_options) ⇒ Object
Constructor Details
#initialize(prism_result) ⇒ PrismPreparsed
Returns a new instance of PrismPreparsed.
13 14 15 16 17 18 19 20 21 |
# 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) ⇒ Object
23 24 25 |
# File 'lib/rubocop/ast/processed_source.rb', line 23 def parse_lex(_source, **) @prism_result end |