Module: SyntaxTree::Index
- Defined in:
- lib/syntax_tree/index.rb
Overview
This class can be used to build an index of the structure of Ruby files. We define an index as the list of constants and methods defined within a file.
This index strives to be as fast as possible to better support tools like IDEs. Because of that, it has different backends depending on what functionality is available.
Defined Under Namespace
Classes: AliasMethodDefinition, ClassDefinition, ConstantDefinition, EntryComments, FileComments, ISeqBackend, Location, MethodDefinition, ModuleDefinition, ParserBackend, SingletonMethodDefinition
Constant Summary collapse
- INDEX_BACKEND =
The class defined here is used to perform the indexing, depending on what functionality is available from the runtime.
defined?(RubyVM::InstructionSequence) ? ISeqBackend : ParserBackend
Class Method Summary collapse
-
.index(source, backend: INDEX_BACKEND.new) ⇒ Object
This method accepts source code and then indexes it.
-
.index_file(filepath, backend: INDEX_BACKEND.new) ⇒ Object
This method accepts a filepath and then indexes it.
Class Method Details
.index(source, backend: INDEX_BACKEND.new) ⇒ Object
This method accepts source code and then indexes it.
674 675 676 |
# File 'lib/syntax_tree/index.rb', line 674 def self.index(source, backend: INDEX_BACKEND.new) backend.index(source) end |
.index_file(filepath, backend: INDEX_BACKEND.new) ⇒ Object
This method accepts a filepath and then indexes it.
679 680 681 |
# File 'lib/syntax_tree/index.rb', line 679 def self.index_file(filepath, backend: INDEX_BACKEND.new) backend.index_file(filepath) end |