Module: RuboCop::AST::ParserSource Private
| Relationships & Source Files | |
| Namespace Children | |
|
Modules:
| |
| Defined in: | lib/rubocop/ast/parser_source.rb |
Overview
Loads the part of the parser gem that every parser engine needs: the
node base class, the source layer (buffers, ranges, comments, source
maps, the tree rewriter) and the diagnostics.
They come from the gem when it is installed, because its parsers and
builders create objects of the very same classes. Without the gem, a
copy of those files that ships with this gem is loaded instead, which is
all that the prism parser engine needs.
Constant Summary
-
FILES =
# File 'lib/rubocop/ast/parser_source.rb', line 17%w[ version messages deprecation ast/node meta source/buffer source/range source/comment source/comment/associator source/tree_rewriter source/tree_rewriter/action source/map source/map/operator source/map/collection source/map/constant source/map/variable source/map/keyword source/map/definition source/map/method_definition source/map/send source/map/index source/map/condition source/map/ternary source/map/for source/map/rescue_body source/map/heredoc source/map/objc_kwarg syntax_error clobbering_error unknown_encoding_in_magic_comment_error diagnostic diagnostic/engine ].freeze
-
VENDORED =
private
# File 'lib/rubocop/ast/parser_source.rb', line 32begin require 'parser/version' false rescue LoadError true end
-
VENDOR_DIR =
# File 'lib/rubocop/ast/parser_source.rb', line 30File.join(__dir__, 'vendor', 'parser')
Class Attribute Summary
-
.vendored? ⇒ Boolean
readonly
Internal use only
Whether the classes come from the copy that ships with this gem, which is the case when the
parsergem is not installed.
Class Method Summary
- .ensure_parser_gem(parser_engine) Internal use only
Class Attribute Details
.vendored? ⇒ Boolean (readonly)
Whether the classes come from the copy that ships with this gem,
which is the case when the parser gem is not installed.
# File 'lib/rubocop/ast/parser_source.rb', line 42
def self.vendored? VENDORED end
Class Method Details
.ensure_parser_gem(parser_engine)
# File 'lib/rubocop/ast/parser_source.rb', line 46
def self.ensure_parser_gem(parser_engine) return unless vendored? raise LoadError, "The `#{parser_engine}` parser engine needs the `parser` gem. Add it " \ 'to your Gemfile, or use the `prism` parser engine, which supports ' \ 'target Ruby versions 3.3 and above.' end