Browse Source

Leafref completion for list keys and leaflist

Serj Kalichev 1 year ago
parent
commit
639412415f
2 changed files with 29 additions and 1 deletions
  1. 14 0
      src/pline.c
  2. 15 1
      ttt.yang

+ 14 - 0
src/pline.c

@@ -643,11 +643,18 @@ static bool_t pline_parse_module(const struct lys_module *module, faux_argv_t *a
 					// Completion
 					if (!str) {
 						char *tmp = NULL;
+						char *compl_xpath = NULL;
 
 						tmp = faux_str_sprintf("%s/%s",
 							pexpr->xpath, leaf->name);
 						pline_add_compl(pline,
 							PCOMPL_TYPE, iter, tmp);
+						compl_xpath = leafref_xpath(iter, tmp);
+						if (compl_xpath) {
+							pline_add_compl(pline, PCOMPL_TYPE,
+								NULL, compl_xpath);
+							faux_str_free(compl_xpath);
+						}
 						faux_str_free(tmp);
 						break_upper_loop = BOOL_TRUE;
 						break;
@@ -748,6 +755,13 @@ static bool_t pline_parse_module(const struct lys_module *module, faux_argv_t *a
 
 			// Completion
 			if (!str) {
+				char *compl_xpath = leafref_xpath(node, pexpr->xpath);
+
+				if (compl_xpath) {
+					pline_add_compl(pline,
+						PCOMPL_TYPE, NULL, compl_xpath);
+					faux_str_free(compl_xpath);
+				}
 				pline_add_compl(pline,
 					PCOMPL_TYPE, node, pexpr->xpath);
 				break;

+ 15 - 1
ttt.yang

@@ -77,12 +77,26 @@ module ttt {
 
     leaf-list multi {
       ordered-by user;
-      type string;
+      type leafref {
+        path "../../test/iface/name";
+      }
     }
 
   }
 
 
+  list ref {
+    ordered-by user;
+    key "name";
+
+    leaf name {
+      type leafref {
+        path "../../test/iface/name";
+      }
+    }
+
+  }
+
   list rule {
     key "from to";