Václav Kubernát | 329c6c3 | 2019-02-06 16:41:53 +0100 | [diff] [blame] | 1 | #include "ast_handlers.hpp" |
Václav Kubernát | c15fe82 | 2020-06-04 11:28:39 +0200 | [diff] [blame] | 2 | std::set<Completion> generateMissingKeyCompletionSet(std::set<std::string> keysNeeded, ListInstance 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 | } |
Václav Kubernát | 2db124c | 2020-05-28 21:58:36 +0200 | [diff] [blame] | 26 | |
| 27 | boost::optional<std::string> optModuleToOptString(const boost::optional<module_> module) |
| 28 | { |
| 29 | return module.flat_map([] (const auto& module) { return boost::optional<std::string>(module.m_name); }); |
| 30 | } |