Class: Jade::CLI::Q::Context
- Inherits:
-
Object
- Object
- Jade::CLI::Q::Context
- Defined in:
- lib/jade/cli/q.rb
Instance Attribute Summary collapse
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
-
#source_root ⇒ Object
readonly
Returns the value of attribute source_root.
Instance Method Summary collapse
-
#initialize(file) ⇒ Context
constructor
A new instance of Context.
- #path_at(line, col) ⇒ Object
Constructor Details
#initialize(file) ⇒ Context
Returns a new instance of Context.
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/jade/cli/q.rb', line 91 def initialize(file) @file = file @source_root = Dir.pwd @registry = Jade::ModuleLoader.load( @source_root, file, cache_dir: File.join(@source_root, '.jade/cache'), tolerant: true, ) @entry = @registry .modules .each_value .find { it.source&.uri == file } || fail("no module at #{file}") end |
Instance Attribute Details
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
89 90 91 |
# File 'lib/jade/cli/q.rb', line 89 def entry @entry end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
89 90 91 |
# File 'lib/jade/cli/q.rb', line 89 def file @file end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
89 90 91 |
# File 'lib/jade/cli/q.rb', line 89 def registry @registry end |
#source_root ⇒ Object (readonly)
Returns the value of attribute source_root.
89 90 91 |
# File 'lib/jade/cli/q.rb', line 89 def source_root @source_root end |
Instance Method Details
#path_at(line, col) ⇒ Object
105 106 107 108 109 |
# File 'lib/jade/cli/q.rb', line 105 def path_at(line, col) Jade::LSP::Converters .position_to_offset(entry.source, line, col) .then { entry.ast.find_at_path(it) } end |