Merge changes Ia27f6aa1,I919c7175

* changes:
  Remove Schema::is* methods
  Remove unused overloads in Schema
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 870d255..f344ac2 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -157,19 +157,8 @@
             return;
         }
 
-        try {
-            boost::optional<std::string> module;
-            if (ast.m_nodes.back().m_prefix)
-                module = ast.m_nodes.back().m_prefix.value().m_name;
-            container_ cont = std::get<container_>(ast.m_nodes.back().m_suffix);
-            auto location = pathWithoutLastNode(parserContext.currentSchemaPath());
-
-            if (!schema.isPresenceContainer(location, {module, cont.m_name})) {
-                parserContext.m_errorMsg = "This container is not a presence container.";
-                _pass(context) = false;
-            }
-        } catch (std::bad_variant_access&) {
-            parserContext.m_errorMsg = "This is not a container.";
+        if (schema.nodeType(pathToSchemaString(parserContext.currentSchemaPath(), Prefixes::Always)) != yang::NodeTypes::PresenceContainer) {
+            parserContext.m_errorMsg = "This container is not a presence container.";
             _pass(context) = false;
         }
     }
diff --git a/src/schema.cpp b/src/schema.cpp
index e092569..c390e31 100644
--- a/src/schema.cpp
+++ b/src/schema.cpp
@@ -9,49 +9,3 @@
 #include "schema.hpp"
 
 Schema::~Schema() = default;
-
-bool Schema::isList(const schemaPath_& location, const ModuleNodePair& node) const
-{
-    try {
-        return nodeType(location, node) == yang::NodeTypes::List;
-    } catch (InvalidNodeException&) {
-        return false;
-    }
-}
-
-bool Schema::isPresenceContainer(const schemaPath_& location, const ModuleNodePair& node) const
-{
-    try {
-        return nodeType(location, node) == yang::NodeTypes::PresenceContainer;
-    } catch (InvalidNodeException&) {
-        return false;
-    }
-}
-
-bool Schema::isContainer(const schemaPath_& location, const ModuleNodePair& node) const
-{
-    try {
-        auto type = nodeType(location, node);
-        return type == yang::NodeTypes::Container || type == yang::NodeTypes::PresenceContainer;
-    } catch (InvalidNodeException&) {
-        return false;
-    }
-}
-
-bool Schema::isLeaf(const schemaPath_& location, const ModuleNodePair& node) const
-{
-    try {
-        return nodeType(location, node) == yang::NodeTypes::Leaf;
-    } catch (InvalidNodeException&) {
-        return false;
-    }
-}
-
-bool Schema::isLeafList(const std::string& path) const
-{
-    try {
-        return nodeType(path) == yang::NodeTypes::LeafList;
-    } catch (InvalidNodeException&) {
-        return false;
-    }
-}
diff --git a/src/schema.hpp b/src/schema.hpp
index 42d0728..75c1f8f 100644
--- a/src/schema.hpp
+++ b/src/schema.hpp
@@ -54,20 +54,14 @@
 public:
     virtual ~Schema();
 
-    bool isContainer(const schemaPath_& location, const ModuleNodePair& node) const;
-    bool isLeaf(const schemaPath_& location, const ModuleNodePair& node) const;
-    bool isList(const schemaPath_& location, const ModuleNodePair& node) const;
-    bool isPresenceContainer(const schemaPath_& location, const ModuleNodePair& node) const;
     bool isLeafList(const std::string& path) const;
     virtual yang::NodeTypes nodeType(const std::string& path) const = 0;
     virtual yang::NodeTypes nodeType(const schemaPath_& location, const ModuleNodePair& node) const = 0;
     virtual bool isModule(const std::string& name) const = 0;
-    virtual bool listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const = 0;
     virtual bool listHasKey(const schemaPath_& listPath, const std::string& key) const = 0;
     virtual bool leafIsKey(const std::string& leafPath) const = 0;
     virtual bool isConfig(const std::string& path) const = 0;
     virtual std::optional<std::string> defaultValue(const std::string& leafPath) const = 0;
-    virtual const std::set<std::string> listKeys(const schemaPath_& location, const ModuleNodePair& node) const = 0;
     virtual const std::set<std::string> listKeys(const schemaPath_& listPath) const = 0;
     virtual yang::TypeInfo leafType(const schemaPath_& location, const ModuleNodePair& node) const = 0;
     virtual yang::TypeInfo leafType(const std::string& path) const = 0;
diff --git a/src/static_schema.cpp b/src/static_schema.cpp
index 203b61e..a7130b3 100644
--- a/src/static_schema.cpp
+++ b/src/static_schema.cpp
@@ -34,31 +34,11 @@
     m_nodes.emplace(key, std::unordered_map<std::string, NodeInfo>());
 }
 
-bool StaticSchema::listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const
-{
-    std::string locationString = pathToSchemaString(location, Prefixes::Always);
-    assert(isList(location, node));
-
-    const auto& child = children(locationString).at(fullNodeName(location, node));
-    const auto& list = std::get<yang::list>(child.m_nodeType);
-    return list.m_keys.find(key) != list.m_keys.end();
-}
-
 bool StaticSchema::listHasKey(const schemaPath_& listPath, const std::string& key) const
 {
     return listKeys(listPath).count(key);
 }
 
-const std::set<std::string> StaticSchema::listKeys(const schemaPath_& location, const ModuleNodePair& node) const
-{
-    std::string locationString = pathToSchemaString(location, Prefixes::Always);
-    assert(isList(location, node));
-
-    const auto& child = children(locationString).at(fullNodeName(location, node));
-    const auto& list = std::get<yang::list>(child.m_nodeType);
-    return list.m_keys;
-}
-
 std::string lastNodeOfSchemaPath(const std::string& path)
 {
     std::string res = path;
@@ -264,9 +244,12 @@
     throw std::runtime_error{"Internal error: StaticSchema::status(std::string) not implemented. The tests should not have called this overload."};
 }
 
-yang::NodeTypes StaticSchema::nodeType([[maybe_unused]] const std::string& path) const
+yang::NodeTypes StaticSchema::nodeType(const std::string& path) const
 {
-    throw std::runtime_error{"Internal error: StaticSchema::nodeType(std::string) not implemented. The tests should not have called this overload."};
+    auto locationString = stripLastNodeFromPath(path);
+
+    auto node = fullNodeName(locationString, lastNodeOfSchemaPath(path));
+    return std::visit(impl_nodeType{}, children(locationString).at(node).m_nodeType);
 }
 
 std::string StaticSchema::leafrefPath([[maybe_unused]] const std::string& leafrefPath) const
diff --git a/src/static_schema.hpp b/src/static_schema.hpp
index 09b6271..9d897b1 100644
--- a/src/static_schema.hpp
+++ b/src/static_schema.hpp
@@ -62,12 +62,10 @@
     yang::NodeTypes nodeType(const std::string& path) const override;
     yang::NodeTypes nodeType(const schemaPath_& location, const ModuleNodePair& node) const override;
     bool isModule(const std::string& name) const override;
-    bool listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const override;
     bool listHasKey(const schemaPath_& listPath, const std::string& key) const override;
     bool leafIsKey(const std::string& leafPath) const override;
     bool isConfig(const std::string& leafPath) const override;
     std::optional<std::string> defaultValue(const std::string& leafPath) const override;
-    const std::set<std::string> listKeys(const schemaPath_& location, const ModuleNodePair& node) const override;
     const std::set<std::string> listKeys(const schemaPath_& listPath) const override;
     yang::TypeInfo leafType(const schemaPath_& location, const ModuleNodePair& node) const override;
     yang::TypeInfo leafType(const std::string& path) const override;
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index 3af5f79..3278766 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -196,7 +196,7 @@
             return;
         for (unsigned int i = 0; i < items->val_cnt(); i++) {
             auto value = leafValueFromVal(items->val(i));
-            if (m_schema->isLeafList(items->val(i)->xpath())) {
+            if (m_schema->nodeType(items->val(i)->xpath()) == yang::NodeTypes::LeafList) {
                 res.push_back({items->val(i)->xpath(), special_{SpecialValue::LeafList}});
                 std::string leafListPath = items->val(i)->xpath();
                 while (i < items->val_cnt() && leafListPath == items->val(i)->xpath()) {
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index b44ef5f..c8bf540 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -93,14 +93,6 @@
     return set.find(name) != set.end();
 }
 
-bool YangSchema::listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const
-{
-    if (!isList(location, node))
-        return false;
-    const auto keys = listKeys(location, node);
-    return keys.find(key) != keys.end();
-}
-
 bool YangSchema::listHasKey(const schemaPath_& listPath, const std::string& key) const
 {
     const auto keys = listKeys(listPath);
@@ -153,30 +145,20 @@
     return impl_getSchemaNode(absPath);
 }
 
-namespace {
-const std::set<std::string> impl_listKeys(const libyang::S_Schema_Node_List& list)
+const std::set<std::string> YangSchema::listKeys(const schemaPath_& listPath) const
 {
+    auto node = getSchemaNode(listPath);
+    if (node->nodetype() != LYS_LIST) {
+        return {};
+    }
+
+    auto list = std::make_shared<libyang::Schema_Node_List>(node);
     std::set<std::string> keys;
     const auto& keysVec = list->keys();
 
     std::transform(keysVec.begin(), keysVec.end(), std::inserter(keys, keys.begin()), [](const auto& it) { return it->name(); });
     return keys;
 }
-}
-
-const std::set<std::string> YangSchema::listKeys(const schemaPath_& location, const ModuleNodePair& node) const
-{
-    if (!isList(location, node))
-        return {};
-    auto list = std::make_shared<libyang::Schema_Node_List>(getSchemaNode(location, node));
-    return impl_listKeys(list);
-}
-
-const std::set<std::string> YangSchema::listKeys(const schemaPath_& listPath) const
-{
-    auto list = std::make_shared<libyang::Schema_Node_List>(getSchemaNode(listPath));
-    return impl_listKeys(list);
-}
 
 namespace {
 std::set<enum_> enumValues(const libyang::S_Type& typeArg)
diff --git a/src/yang_schema.hpp b/src/yang_schema.hpp
index aed1a5d..3663ccd 100644
--- a/src/yang_schema.hpp
+++ b/src/yang_schema.hpp
@@ -34,12 +34,10 @@
     yang::NodeTypes nodeType(const std::string& path) const override;
     yang::NodeTypes nodeType(const schemaPath_& location, const ModuleNodePair& node) const override;
     bool isModule(const std::string& name) const override;
-    bool listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const override;
     bool listHasKey(const schemaPath_& listPath, const std::string& key) const override;
     bool leafIsKey(const std::string& leafPath) const override;
     bool isConfig(const std::string& path) const override;
     std::optional<std::string> defaultValue(const std::string& leafPath) const override;
-    const std::set<std::string> listKeys(const schemaPath_& location, const ModuleNodePair& node) const override;
     const std::set<std::string> listKeys(const schemaPath_& listPath) const override;
     yang::TypeInfo leafType(const schemaPath_& location, const ModuleNodePair& node) const override;
     yang::TypeInfo leafType(const std::string& path) const override;
diff --git a/tests/ls_interpreter.cpp b/tests/ls_interpreter.cpp
index 4a60762..2ae0b7c 100644
--- a/tests/ls_interpreter.cpp
+++ b/tests/ls_interpreter.cpp
@@ -26,11 +26,9 @@
     IMPLEMENT_CONST_MOCK1(leafTypeName);
     IMPLEMENT_CONST_MOCK1(isModule);
     IMPLEMENT_CONST_MOCK1(leafrefPath);
-    MAKE_CONST_MOCK3(listHasKey, bool(const schemaPath_& location, const ModuleNodePair& node, const std::string& key), override);
-    MAKE_CONST_MOCK2(listHasKey, bool(const schemaPath_& listPath, const std::string& key), override);
+    IMPLEMENT_CONST_MOCK2(listHasKey);
     IMPLEMENT_CONST_MOCK1(leafIsKey);
-    MAKE_CONST_MOCK2(listKeys, const std::set<std::string>(const schemaPath_& location, const ModuleNodePair& node), override);
-    MAKE_CONST_MOCK1(listKeys, const std::set<std::string>(const schemaPath_& listPath), override);
+    IMPLEMENT_CONST_MOCK1(listKeys);
     MAKE_CONST_MOCK1(nodeType, yang::NodeTypes(const std::string&), override);
     MAKE_CONST_MOCK2(nodeType, yang::NodeTypes(const schemaPath_&, const ModuleNodePair&), override);
     IMPLEMENT_CONST_MOCK1(status);
diff --git a/tests/yang.cpp b/tests/yang.cpp
index 71cb69d..9419051 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -459,106 +459,10 @@
 
     SECTION("positive")
     {
-        SECTION("isContainer")
-        {
-            SECTION("example-schema:a")
-            {
-                node.first = "example-schema";
-                node.second = "a";
-            }
-
-            SECTION("example-schema:a/a2")
-            {
-                path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
-                node.second = "a2";
-            }
-
-            SECTION("example-schema:ethernet")
-            {
-                node.first = "example-schema";
-                node.second = "ethernet";
-            }
-
-            SECTION("example-schema:loopback")
-            {
-                node.first = "example-schema";
-                node.second = "loopback";
-            }
-
-            REQUIRE(ys.isContainer(path, node));
-        }
-        SECTION("isLeaf")
-        {
-            SECTION("example-schema:leafString")
-            {
-                node.first = "example-schema";
-                node.second = "leafString";
-            }
-
-            SECTION("example-schema:a/leafa")
-            {
-                path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
-                node.first = "example-schema";
-                node.second = "leafa";
-            }
-
-            SECTION("example-schema:carry")
-            {
-                node.first = "example-schema";
-                node.second = "carry";
-            }
-
-            SECTION("example-schema:zero")
-            {
-                node.first = "example-schema";
-                node.second = "zero";
-            }
-
-            SECTION("example-schema:direction")
-            {
-                node.first = "example-schema";
-                node.second = "direction";
-            }
-
-            SECTION("example-schema:interrupt")
-            {
-                node.first = "example-schema";
-                node.second = "interrupt";
-            }
-
-            REQUIRE(ys.isLeaf(path, node));
-        }
         SECTION("isModule")
         {
             REQUIRE(ys.isModule("example-schema"));
         }
-        SECTION("isList")
-        {
-            SECTION("example-schema:_list")
-            {
-                node.first = "example-schema";
-                node.second = "_list";
-            }
-
-            SECTION("example-schema:twoKeyList")
-            {
-                node.first = "example-schema";
-                node.second = "twoKeyList";
-            }
-
-            REQUIRE(ys.isList(path, node));
-        }
-        SECTION("isPresenceContainer")
-        {
-            SECTION("example-schema:a/a2/a3")
-            {
-                path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
-                path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a2")));
-                node.second = "a3";
-            }
-
-            REQUIRE(ys.isPresenceContainer(path, node));
-        }
 
         SECTION("listHasKey")
         {
@@ -566,23 +470,27 @@
 
             SECTION("_list")
             {
-                node.first = "example-schema";
-                node.second = "_list";
+                path.m_nodes.push_back(schemaNode_{module_{"example-schema"}, list_{"_list"}});
                 SECTION("number")
-                key = "number";
+                {
+                    key = "number";
+                }
             }
 
             SECTION("twoKeyList")
             {
-                node.first = "example-schema";
-                node.second = "twoKeyList";
+                path.m_nodes.push_back(schemaNode_{module_{"example-schema"}, list_{"twoKeyList"}});
                 SECTION("number")
-                key = "number";
+                {
+                    key = "number";
+                }
                 SECTION("name")
-                key = "name";
+                {
+                    key = "name";
+                }
             }
 
-            REQUIRE(ys.listHasKey(path, node, key));
+            REQUIRE(ys.listHasKey(path, key));
         }
         SECTION("listKeys")
         {
@@ -590,19 +498,17 @@
 
             SECTION("_list")
             {
+                path.m_nodes.push_back(schemaNode_{module_{"example-schema"}, list_{"_list"}});
                 set = {"number"};
-                node.first = "example-schema";
-                node.second = "_list";
             }
 
             SECTION("twoKeyList")
             {
+                path.m_nodes.push_back(schemaNode_{module_{"example-schema"}, list_{"twoKeyList"}});
                 set = {"number", "name"};
-                node.first = "example-schema";
-                node.second = "twoKeyList";
             }
 
-            REQUIRE(ys.listKeys(path, node) == set);
+            REQUIRE(ys.listKeys(path) == set);
         }
         SECTION("leafType")
         {
@@ -1229,37 +1135,15 @@
                 node.second = "nevim";
             }
 
-            REQUIRE(!ys.isPresenceContainer(path, node));
-            REQUIRE(!ys.isList(path, node));
-            REQUIRE(!ys.isLeaf(path, node));
-            REQUIRE(!ys.isContainer(path, node));
-        }
-
-        SECTION("\"is\" methods return false for existing nodes for different nodetypes")
-        {
-            SECTION("example-schema:a")
-            {
-                node.first = "example-schema";
-                node.second = "a";
-            }
-
-            SECTION("example-schema:a/a2")
-            {
-                path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
-                node.second = "a2";
-            }
-
-            REQUIRE(!ys.isPresenceContainer(path, node));
-            REQUIRE(!ys.isList(path, node));
-            REQUIRE(!ys.isLeaf(path, node));
+            REQUIRE_THROWS(ys.nodeType(path, node));
         }
 
         SECTION("nodetype-specific methods called with different nodetypes")
         {
             path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
-            node.second = "a2";
+            path.m_nodes.push_back(schemaNode_(container_("a2")));
 
-            REQUIRE(!ys.listHasKey(path, node, "chacha"));
+            REQUIRE(!ys.listHasKey(path, "chacha"));
         }
 
         SECTION("nonexistent module")
@@ -1281,10 +1165,7 @@
                 node.second = "startAndStop";
             }
 
-            REQUIRE(!ys.isPresenceContainer(path, node));
-            REQUIRE(!ys.isList(path, node));
-            REQUIRE(!ys.isLeaf(path, node));
-            REQUIRE(!ys.isContainer(path, node));
+            REQUIRE_THROWS(ys.nodeType(path, node));
         }
 
         SECTION("choice is not a node")
@@ -1295,10 +1176,7 @@
                 node.second = "interface";
             }
 
-            REQUIRE(!ys.isPresenceContainer(path, node));
-            REQUIRE(!ys.isList(path, node));
-            REQUIRE(!ys.isLeaf(path, node));
-            REQUIRE(!ys.isContainer(path, node));
+            REQUIRE_THROWS(ys.nodeType(path, node));
         }
 
         SECTION("case is not a node")
@@ -1315,10 +1193,7 @@
                 node.second = "caseEthernet";
             }
 
-            REQUIRE(!ys.isPresenceContainer(path, node));
-            REQUIRE(!ys.isList(path, node));
-            REQUIRE(!ys.isLeaf(path, node));
-            REQUIRE(!ys.isContainer(path, node));
+            REQUIRE_THROWS(ys.nodeType(path, node));
         }
     }
 }