1
#include "script/ScriptDocumentOperation.h"
2
#include "simodo/lsp/CompletionItemKind.h"
7
/// \see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion
9
variable::Value ScriptDocumentOperation::produceCompletionResponse(const lsp::CompletionParams & /*completionParams*/) const
11
std::vector<variable::Value> completion_items;
13
variable::VariableSet_t vars;
15
std::u16string last_production;
16
for(const variable::Variable & var : _semantic_data.declared())
17
if (vars.end() == std::ranges::find_if(vars, [var](const variable::Variable & v){ return v.name() == var.name(); }))
20
for(const variable::Variable & var : vars)
21
completion_items.push_back(makeCompletionItem(var.name(), u"", u"", static_cast<int64_t>(lsp::CompletionItemKind::Variable)));
23
// std::vector<std::u16string> keywords {
24
// u"main", u"include", u"remove",
26
// for(const std::u16string & w : keywords)
27
// completion_items.push_back(makeCompletionItem(w, u"keyword", u"", int64_t(lsp::CompletionItemKind::Keyword)));
29
return completion_items;
32
variable::Value ScriptDocumentOperation::makeCompletionItem(const std::u16string & name,
33
const std::u16string & detail,
34
const std::u16string & description,
37
return variable::Object{{
39
{ u"labelDetails", variable::Object{{
40
{ u"detail", detail },
41
{ u"description", description },