Class: ThemeCheck::LanguageServer::DocumentLinkEngine
- Inherits:
-
Object
- Object
- ThemeCheck::LanguageServer::DocumentLinkEngine
- Includes:
- PositionHelper, RegexHelpers
- Defined in:
- lib/theme_check/language_server/document_link_engine.rb
Constant Summary
Constants included from RegexHelpers
RegexHelpers::START_OR_END_QUOTE, RegexHelpers::VARIABLE
Instance Method Summary collapse
- #document_links(relative_path) ⇒ Object
-
#initialize(storage) ⇒ DocumentLinkEngine
constructor
A new instance of DocumentLinkEngine.
- #link(partial) ⇒ Object
Methods included from RegexHelpers
Methods included from PositionHelper
#bounded, #from_index_to_row_column, #from_row_column_to_index
Constructor Details
#initialize(storage) ⇒ DocumentLinkEngine
Returns a new instance of DocumentLinkEngine.
9 10 11 |
# File 'lib/theme_check/language_server/document_link_engine.rb', line 9 def initialize(storage) @storage = storage end |
Instance Method Details
#document_links(relative_path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/theme_check/language_server/document_link_engine.rb', line 13 def document_links(relative_path) buffer = @storage.read(relative_path) return [] unless buffer matches(buffer, PARTIAL_RENDER).map do |match| start_line, start_character = from_index_to_row_column( buffer, match.begin(:partial), ) end_line, end_character = from_index_to_row_column( buffer, match.end(:partial) ) { target: link(match[:partial]), range: { start: { line: start_line, character: start_character, }, end: { line: end_line, character: end_character, }, }, } end end |
#link(partial) ⇒ Object
43 44 45 |
# File 'lib/theme_check/language_server/document_link_engine.rb', line 43 def link(partial) "file://#{@storage.path('snippets/' + partial + '.liquid')}" end |