Class: PlatformosCheck::LanguageServer::HoverProvider

Inherits:
Object
  • Object
show all
Includes:
CompletionHelper, RegexHelpers
Defined in:
lib/platformos_check/language_server/hover_provider.rb

Direct Known Subclasses

FilterHoverProvider, TagHoverProvider

Defined Under Namespace

Classes: CurrentToken

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

Constants included from CompletionHelper

CompletionHelper::WORD

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RegexHelpers

#matches

Methods included from CompletionHelper

#cursor_on_first_word?, #cursor_on_start_content?, #first_word

Constructor Details

#initialize(storage = InMemoryStorage.new) ⇒ HoverProvider

Returns a new instance of HoverProvider.



23
24
25
# File 'lib/platformos_check/language_server/hover_provider.rb', line 23

def initialize(storage = InMemoryStorage.new)
  @storage = storage
end

Instance Attribute Details

#storageObject (readonly)

Returns the value of attribute storage.



9
10
11
# File 'lib/platformos_check/language_server/hover_provider.rb', line 9

def storage
  @storage
end

Class Method Details

.allObject



14
15
16
# File 'lib/platformos_check/language_server/hover_provider.rb', line 14

def all
  @all ||= []
end

.inherited(subclass) ⇒ Object



18
19
20
# File 'lib/platformos_check/language_server/hover_provider.rb', line 18

def inherited(subclass)
  all << subclass
end

Instance Method Details

#completions(relative_path, line, col) ⇒ Object

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/platformos_check/language_server/hover_provider.rb', line 27

def completions(relative_path, line, col)
  raise NotImplementedError
end

#doc_hash(content) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/platformos_check/language_server/hover_provider.rb', line 31

def doc_hash(content)
  return {} if content.nil? || content.empty?

  {
    documentation: {
      kind: MarkupKinds::MARKDOWN,
      value: content
    }
  }
end

#format_hash(entry) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/platformos_check/language_server/hover_provider.rb', line 42

def format_hash(entry)
  return {} unless entry
  return { sortText: entry.name } unless entry.deprecated?

  {
    tags: [CompletionItemTag::DEPRECATED],
    sortText: "~#{entry.name}"
  }
end