Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 1 | #include "ast_handlers.hpp" |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 2 | std::set<Completion> generateMissingKeyCompletionSet(std::set<std::string> keysNeeded, std::map<std::string, leaf_data_> currentKeys) |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 3 | { |
| 4 | std::set<std::string> missingKeys; |
Václav Kubernát | 43908fb | 2020-01-02 19:05:51 +0100 | [diff] [blame] | 5 | |
| 6 | for (const auto& key : keysNeeded) { |
| 7 | if (currentKeys.find(key) == currentKeys.end()) { |
| 8 | missingKeys.insert(key); |
| 9 | } |
| 10 | } |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 11 | |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 12 | std::set<Completion> res; |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 13 | |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 14 | std::transform(missingKeys.begin(), missingKeys.end(), std::inserter(res, res.end()), [](auto it) { return Completion{it + "="}; }); |
Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 15 | return res; |
| 16 | } |
Václav Kubernát | 43908fb | 2020-01-02 19:05:51 +0100 | [diff] [blame] | 17 | |
| 18 | std::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 | } |