Add enum completion
Change-Id: I5ee7d6359812535d0eef9f70e1b66e205d93cf39
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 943af19..7eed8be 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -569,3 +569,22 @@
_pass(context) = false;
}
};
+
+struct createEnumSuggestions_class {
+ template <typename T, typename Iterator, typename Context>
+ void on_success(Iterator const& begin, Iterator const&, T&, Context const& context)
+ {
+ auto& parserContext = x3::get<parser_context_tag>(context);
+ parserContext.m_completionIterator = begin;
+ const Schema& schema = parserContext.m_schema;
+
+ boost::optional<std::string> module;
+ if (parserContext.m_curPath.m_nodes.back().m_prefix)
+ module = parserContext.m_curPath.m_nodes.back().m_prefix.value().m_name;
+
+ leaf_ leaf = boost::get<leaf_>(parserContext.m_curPath.m_nodes.back().m_suffix);
+ schemaPath_ location = pathWithoutLastNode(parserContext.m_curPath);
+
+ parserContext.m_suggestions = schema.enumValues(location, {module, leaf.m_name});
+ }
+};