Sha256: 495c1374ea32e04e22422348339140ffb2896635be0eb31a85db7ce12870d92b
Contents?: true
Size: 1 KB
Versions: 4
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module PlatformosCheck module LanguageServer class ObjectCompletionProvider < CompletionProvider def completions(context) content = context.content return [] if content.nil? return [] unless (variable_lookup = VariableLookupFinder.lookup(context)) return [] unless variable_lookup.lookups.empty? return [] if content[context.cursor - 1] == "." PlatformosLiquid::SourceIndex .objects .select { |object| object.name.start_with?(partial(variable_lookup)) } .map { |object| object_to_completion(object) } end def partial(variable_lookup) variable_lookup.name || '' end private def object_to_completion(object) content = PlatformosLiquid::Documentation.render_doc(object) { label: object.name, kind: CompletionItemKinds::VARIABLE, **format_hash(object), **doc_hash(content) } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems