import static java.util.Objects.requireNonNull;
import static org.opendaylight.mdsal.binding.model.util.BindingTypes.TYPE_OBJECT;
-import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
+import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataTreeSchemaNode;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
import com.google.common.annotations.Beta;
// Then try to look up the expression.
final PathExpression leafRefXPath = leafref.getPathStatement();
- final PathExpression leafRefStrippedXPath = new PathExpressionImpl(
- GROUPS_PATTERN.matcher(leafRefXPath.getOriginalString()).replaceAll(""), leafRefXPath.isAbsolute());
final Module parentModule = getParentModule(parentNode);
final SchemaNode leafRefValueNode;
- if (!leafRefStrippedXPath.isAbsolute()) {
- leafRefValueNode = SchemaContextUtil.findDataSchemaNodeForRelativeXPath(schemaContext, parentModule,
- parentNode, leafRefStrippedXPath);
+ if (leafRefXPath.isAbsolute()) {
+ leafRefValueNode = SchemaContextUtil.findDataTreeSchemaNode(schemaContext, parentModule.getQNameModule(),
+ leafRefXPath);
} else {
- leafRefValueNode = SchemaContextUtil.findDataSchemaNode(schemaContext, parentModule, leafRefStrippedXPath);
+ leafRefValueNode = SchemaContextUtil.findDataSchemaNodeForRelativeXPath(schemaContext, parentModule,
+ parentNode, new PathExpressionImpl(
+ GROUPS_PATTERN.matcher(leafRefXPath.getOriginalString()).replaceAll(""), false));
}
+
return leafRefValueNode != null && leafRefValueNode.equals(parentNode);
}
final SchemaNode dataNode;
if (xpath.isAbsolute()) {
- dataNode = findDataSchemaNode(schemaContext, module, xpath);
+ dataNode = findDataTreeSchemaNode(schemaContext, module.getQNameModule(), xpath);
} else {
dataNode = findDataSchemaNodeForRelativeXPath(schemaContext, module, parentNode, xpath);
if (dataNode == null && inGrouping) {
if (module != null) {
final SchemaNode dataNode;
if (xpath.isAbsolute()) {
- dataNode = findDataSchemaNode(schemaContext, module, xpath);
+ dataNode = findDataTreeSchemaNode(schemaContext, module.getQNameModule(), xpath);
} else {
dataNode = findDataSchemaNodeForRelativeXPath(schemaContext, module, parentNode, xpath);
}
--- /dev/null
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.binding.generator.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+import org.junit.Test;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+
+public class Mdsal499Test {
+
+ @Test
+ public void testSubmoduleImport() {
+ SchemaContext context = YangParserTestUtils.parseYangResourceDirectory("/mdsal-499");
+
+ List<Type> generateTypes = new BindingGeneratorImpl().generateTypes(context);
+ assertNotNull(generateTypes);
+ assertEquals(5, generateTypes.size());
+ }
+}