blob: 24866b255f70b3b42f20d0862e2af22deac03317 [file] [log] [blame]
Václav Kubernát329c6c32019-02-06 16:41:53 +01001#include "ast_handlers.hpp"
Václav Kubernátcb3af402020-02-12 16:49:17 +01002std::set<Completion> generateMissingKeyCompletionSet(std::set<std::string> keysNeeded, std::map<std::string, leaf_data_> currentKeys)
Václav Kubernát329c6c32019-02-06 16:41:53 +01003{
4 std::set<std::string> missingKeys;
Václav Kubernát43908fb2020-01-02 19:05:51 +01005
6 for (const auto& key : keysNeeded) {
7 if (currentKeys.find(key) == currentKeys.end()) {
8 missingKeys.insert(key);
9 }
10 }
Václav Kubernát329c6c32019-02-06 16:41:53 +010011
Václav Kubernátcb3af402020-02-12 16:49:17 +010012 std::set<Completion> res;
Václav Kubernát329c6c32019-02-06 16:41:53 +010013
Václav Kubernátcb3af402020-02-12 16:49:17 +010014 std::transform(missingKeys.begin(), missingKeys.end(), std::inserter(res, res.end()), [](auto it) { return Completion{it + "="}; });
Václav Kubernát329c6c32019-02-06 16:41:53 +010015 return res;
16}
Václav Kubernát43908fb2020-01-02 19:05:51 +010017
18std::string leafDataToCompletion(const leaf_data_& value)
19{
20 // Only string-like values need to be quoted
21 if (value.type() == typeid(std::string)) {
22 return escapeListKeyString(leafDataToString(value));
23 }
24 return leafDataToString(value);
25}