Class: LanguageServer::CompletionProvider::AdHoc
- Inherits:
-
Object
- Object
- LanguageServer::CompletionProvider::AdHoc
- Defined in:
- lib/language_server/completion_provider/ad_hoc.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(uri:, line:, character:, project:) ⇒ AdHoc
constructor
A new instance of AdHoc.
Constructor Details
#initialize(uri:, line:, character:, project:) ⇒ AdHoc
Returns a new instance of AdHoc.
6 7 8 9 10 11 |
# File 'lib/language_server/completion_provider/ad_hoc.rb', line 6 def initialize(uri:, line:, character:, project:) @uri = uri @line = line @character = character @project = project end |
Instance Method Details
#call ⇒ 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 |
# File 'lib/language_server/completion_provider/ad_hoc.rb', line 13 def call (project.constants(uri: uri, line: line, character: character).map { |c| Protocol::Interface::CompletionItem.new( label: c.name, detail: c.full_name, documentation: "#{c.remote_path}##{c.lineno}", kind: Protocol::Constant::CompletionItemKind::ENUM, ) } + project.classes(uri: uri, line: line, character: character).map { |c| Protocol::Interface::CompletionItem.new( label: c.name, detail: c.full_name, documentation: "#{c.remote_path}##{c.lineno}", kind: Protocol::Constant::CompletionItemKind::CLASS, ) } + project.modules(uri: uri, line: line, character: character).map { |m| Protocol::Interface::CompletionItem.new( label: m.name, detail: m.full_name, documentation: "#{m.remote_path}##{m.lineno}", kind: Protocol::Constant::CompletionItemKind::MODULE, ) }).uniq(&:label) end |