Module: PlatformosCheck::LanguageServer::CompletionHelper
- Included in:
- CompletionProvider, HoverProvider
- Defined in:
- lib/platformos_check/language_server/completion_helper.rb
Constant Summary collapse
- WORD =
/\w+/
Instance Method Summary collapse
- #cursor_on_first_word?(content, cursor) ⇒ Boolean
- #cursor_on_start_content?(content, cursor, regex) ⇒ Boolean
- #first_word(content) ⇒ Object
Instance Method Details
#cursor_on_first_word?(content, cursor) ⇒ Boolean
12 13 14 15 16 17 18 19 |
# File 'lib/platformos_check/language_server/completion_helper.rb', line 12 def cursor_on_first_word?(content, cursor) word = content.match(WORD) return false if word.nil? word_start = word.begin(0) word_end = word.end(0) word_start <= cursor && cursor <= word_end end |
#cursor_on_start_content?(content, cursor, regex) ⇒ Boolean
8 9 10 |
# File 'lib/platformos_check/language_server/completion_helper.rb', line 8 def cursor_on_start_content?(content, cursor, regex) content.slice(0, cursor).match?(/#{regex}(?:\s|\n)*$/m) end |