Preconditions.checkArgument(dataNode != null, "Failed to find leafref target: %s in module %s (%s)",
strXPath, this.getParentModule(parentNode).getName(), parentNode.getQName().getModule());
+ // FIXME: this block seems to be some weird magic hack. Analyze and refactor it.
if (leafContainsEnumDefinition(dataNode)) {
returnType = referencedTypes.get(dataNode.getPath());
} else if (leafListContainsEnumDefinition(dataNode)) {
returnType = Types.listTypeFor(referencedTypes.get(dataNode.getPath()));
- } else {
+ }
+ if (returnType == null) {
returnType = resolveTypeFromDataSchemaNode(dataNode);
}
} else {
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies, 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 Mdsal352Test {
+
+ @Test
+ public void mdsal352Test() {
+ final SchemaContext context = YangParserTestUtils.parseYangResource("/mdsal352.yang");
+
+ final List<Type> generateTypes = new BindingGeneratorImpl().generateTypes(context);
+ assertNotNull(generateTypes);
+ assertEquals(6, generateTypes.size());
+ }
+}
--- /dev/null
+module enum-leafref {
+ namespace "urn:donaldh:yang:leafref:bug";
+ prefix l;
+
+ typedef action-effort {
+ type enumeration {
+ enum best-effort {
+ }
+ enum exact-match {
+ }
+ }
+ }
+
+ container operations {
+ list operation {
+ key 'effort';
+ uses operation-g;
+ }
+ }
+
+ grouping operation-g {
+ leaf effort {
+ type action-effort;
+ }
+ leaf-list operation {
+ type leafref {
+ path '/operations/operation/effort';
+ }
+ }
+ }
+}
+