Class: ThemeCheck::LanguageServer::DocumentLinkProvider
- Inherits:
-
Object
- Object
- ThemeCheck::LanguageServer::DocumentLinkProvider
- Includes:
- URIHelper, PositionHelper, RegexHelpers
- Defined in:
- lib/theme_check/language_server/document_link_provider.rb
Direct Known Subclasses
AssetDocumentLinkProvider, IncludeDocumentLinkProvider, RenderDocumentLinkProvider, SectionDocumentLinkProvider
Constant Summary
Constants included from RegexHelpers
RegexHelpers::HTML_LIQUID_PLACEHOLDER, RegexHelpers::LIQUID_TAG, RegexHelpers::LIQUID_TAG_OR_VARIABLE, RegexHelpers::LIQUID_VARIABLE, RegexHelpers::START_OR_END_QUOTE
Class Attribute Summary collapse
-
.destination_directory ⇒ Object
Returns the value of attribute destination_directory.
-
.destination_postfix ⇒ Object
Returns the value of attribute destination_postfix.
-
.partial_regexp ⇒ Object
Returns the value of attribute partial_regexp.
Class Method Summary collapse
Instance Method Summary collapse
- #destination_directory ⇒ Object
- #destination_postfix ⇒ Object
- #document_links(buffer) ⇒ Object
- #file_link(partial) ⇒ Object
-
#initialize(storage = InMemoryStorage.new) ⇒ DocumentLinkProvider
constructor
A new instance of DocumentLinkProvider.
- #partial_regexp ⇒ Object
Methods included from URIHelper
Methods included from PositionHelper
#bounded, #from_index_to_row_column, #from_row_column_to_index
Methods included from RegexHelpers
Constructor Details
#initialize(storage = InMemoryStorage.new) ⇒ DocumentLinkProvider
Returns a new instance of DocumentLinkProvider.
22 23 24 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 22 def initialize(storage = InMemoryStorage.new) @storage = storage end |
Class Attribute Details
.destination_directory ⇒ Object
Returns the value of attribute destination_directory.
11 12 13 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 11 def destination_directory @destination_directory end |
.destination_postfix ⇒ Object
Returns the value of attribute destination_postfix.
11 12 13 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 11 def destination_postfix @destination_postfix end |
.partial_regexp ⇒ Object
Returns the value of attribute partial_regexp.
11 12 13 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 11 def partial_regexp @partial_regexp end |
Class Method Details
.all ⇒ Object
13 14 15 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 13 def all @all ||= [] end |
.inherited(subclass) ⇒ Object
17 18 19 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 17 def inherited(subclass) all << subclass end |
Instance Method Details
#destination_directory ⇒ Object
30 31 32 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 30 def destination_directory self.class.destination_directory end |
#destination_postfix ⇒ Object
34 35 36 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 34 def destination_postfix self.class.destination_postfix end |
#document_links(buffer) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 38 def document_links(buffer) matches(buffer, partial_regexp).map do |match| start_row, start_column = from_index_to_row_column( buffer, match.begin(:partial), ) end_row, end_column = from_index_to_row_column( buffer, match.end(:partial) ) { target: file_link(match[:partial]), range: { start: { line: start_row, character: start_column, }, end: { line: end_row, character: end_column, }, }, } end end |
#file_link(partial) ⇒ Object
66 67 68 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 66 def file_link(partial) file_uri(@storage.path(destination_directory + '/' + partial + destination_postfix)) end |
#partial_regexp ⇒ Object
26 27 28 |
# File 'lib/theme_check/language_server/document_link_provider.rb', line 26 def partial_regexp self.class.partial_regexp end |