blob: 8aa6470b61ca58b03bbd885df6ef6993f6b558bb [file] [log] [blame]
Václav Kubernát329c6c32019-02-06 16:41:53 +01001#include "ast_handlers.hpp"
Václav Kubernát43908fb2020-01-02 19:05:51 +01002std::set<std::string> 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
12 std::set<std::string> res;
13
14 std::transform(missingKeys.begin(), missingKeys.end(),
15 std::inserter(res, res.end()),
16 [] (auto it) { return it + "="; });
17 return res;
18}
Václav Kubernát43908fb2020-01-02 19:05:51 +010019
20std::string leafDataToCompletion(const leaf_data_& value)
21{
22 // Only string-like values need to be quoted
23 if (value.type() == typeid(std::string)) {
24 return escapeListKeyString(leafDataToString(value));
25 }
26 return leafDataToString(value);
27}