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
jade.json is what says where sources live and which extension gems ship the modules they import.
- #path_at(line, col) ⇒ Object
Constructor Details
#initialize(file) ⇒ Context
jade.json is what says where sources live and which extension gems
ship the modules they import. Without it Sql.Uuid resolves
against cwd and the load dies.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/jade/cli/q.rb', line 140 def initialize(file) project = Jade::Project.find! @file = project.source_relative(file) @source_root = project.source_root @registry = Jade::ModuleLoader.load( @source_root, @file, cache_dir: project.cache_path, 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.
135 136 137 |
# File 'lib/jade/cli/q.rb', line 135 def entry @entry end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
135 136 137 |
# File 'lib/jade/cli/q.rb', line 135 def file @file end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
135 136 137 |
# File 'lib/jade/cli/q.rb', line 135 def registry @registry end |
#source_root ⇒ Object (readonly)
Returns the value of attribute source_root.
135 136 137 |
# File 'lib/jade/cli/q.rb', line 135 def source_root @source_root end |
Instance Method Details
#path_at(line, col) ⇒ Object
155 156 157 158 159 |
# File 'lib/jade/cli/q.rb', line 155 def path_at(line, col) Jade::LSP::Converters .position_to_offset(entry.source, line, col) .then { entry.ast.find_at_path(it) } end |