[ONOS-4842] Leafref implementation for augment and uses
Change-Id: I919553a64d683aff65a8f16e2de783702dd5a45f
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang b/plugin/src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
new file mode 100644
index 0000000..a0bd03b
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
@@ -0,0 +1,19 @@
+module SelfResolutionWhenLeafrefInModuleReferToGroupingInModule {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ grouping networks {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ container current {
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang b/plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
new file mode 100644
index 0000000..c10ba2b
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
@@ -0,0 +1,19 @@
+module SelfResolutionWhenLeafrefInModuleReferToInvalidNode {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/define/network-id";
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithnorefleaf/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang b/plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithnorefleaf/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
new file mode 100644
index 0000000..e5de10b
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithnorefleaf/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type status;
+ description
+ "Identifies a network.";
+ }
+ }
+ typedef status {
+ type uint8;
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefInAugment/SelfResolutionIfLeafrefInGroupingIsCopiedToAugment.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefInAugment/SelfResolutionIfLeafrefInGroupingIsCopiedToAugment.yang
new file mode 100644
index 0000000..a208903
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefInAugment/SelfResolutionIfLeafrefInGroupingIsCopiedToAugment.yang
@@ -0,0 +1,64 @@
+module topology {
+ yang-version 1;
+ namespace "onos-yang-19:level1:newlevel";
+ prefix test;
+ organization "huawei";
+ contact "adarsh.m@huawei.com";
+ description "leaf scenario";
+ container networks {
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ip {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ augment "/networks/network" {
+ container config {
+ description
+ "Configuration data.";
+ choice bundle-stack-level {
+ description
+ "The TE link can be partitioned into bundled
+ links, or component links.";
+ case bundle {
+ container bundled-links {
+ description
+ "A set of bundled links.";
+ reference
+ "RFC4201: Link Bundling in MPLS Traffic Engineering
+ (TE).";
+ list bundled-link {
+ key "src-tp-ref";
+ leaf src-tp-ref {
+ type leafref {
+ path "../../../../../network-ip";
+ require-instance true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefingroupingonly/SelfResolutionWithLeafrefInGrouping.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefingroupingonly/SelfResolutionWithLeafrefInGrouping.yang
new file mode 100644
index 0000000..80b6ab0
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefingroupingonly/SelfResolutionWithLeafrefInGrouping.yang
@@ -0,0 +1,37 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+
+ leaf xyz {
+ type string;
+ }
+ typedef network-id {
+ type inet:uri;
+ description
+ "Identifier for a network.";
+ }
+ grouping network-ref {
+ description
+ "Contains the information necessary to reference a network,
+ for example an underlay network.";
+ leaf network-ref {
+ type leafref {
+ path "/nd:xyz";
+ require-instance false;
+ }
+ description
+ "Used to reference a network, for example an underlay
+ network.";
+ }
+ }
+ }
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
new file mode 100644
index 0000000..ae42100
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type network-ref;
+ description
+ "Identifies a network.";
+ }
+ leaf id {
+ type uint8;
+ }
+ }
+ typedef network-ref {
+ type leafref {
+ path "/networks/id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/ietf-network.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/ietf-network.yang
new file mode 100644
index 0000000..4eaa2bf
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/ietf-network.yang
@@ -0,0 +1,33 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ import network {
+ prefix "nw";
+ }
+ grouping xyz {
+ leaf network-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network/nw:network-id";
+ require-instance false;
+ }
+ description
+ "A reference to a network-id in base ietf-network module.";
+ }
+ }
+ grouping yzx {
+ container hi {
+ uses xyz;
+ }
+ }
+ container fine {
+ uses yzx;
+ }
+ container networks {
+ leaf network {
+ type string;
+ }
+ }
+}
+
+
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/network.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/network.yang
new file mode 100644
index 0000000..30e8b80
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/network.yang
@@ -0,0 +1,212 @@
+ module network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for a collection
+ of nodes in a network. Node definitions are further used
+ in network topologies and inventories.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02";
+ }
+
+ typedef node-id {
+ type string;
+ description
+ "Identifier for a node.";
+ }
+
+ typedef network-id {
+ type string;
+ description
+ "Identifier for a network.";
+ }
+ grouping network-ref {
+ description
+ "Contains the information necessary to reference a network,
+ for example an underlay network.";
+ leaf network-ref {
+ type leafref {
+ path "/nd:networks/nd:network/nd:network-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a network, for example an underlay
+ network.";
+ }
+ }
+
+ grouping node-ref {
+ description
+ "Contains the information necessary to reference a node.";
+ leaf node-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node/nd:node-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a node.
+ Nodes are identified relative to the network they are
+ contained in.";
+ }
+ uses network-ref;
+ }
+
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type network-id;
+ description
+ "Identifies a network.";
+ }
+ list supporting-network {
+ key "network-ref";
+ description
+ "An underlay network, used to represent layered network
+ topologies.";
+ leaf network-ref {
+ type leafref {
+ path "/networks/network/network-id";
+ require-instance false;
+ }
+ description
+ "References the underlay network.";
+ }
+ }
+ list node {
+ key "node-id";
+ description
+ "The inventory of nodes of this network.";
+ leaf node-id {
+ type node-id;
+ description
+ "Identifies a node uniquely within the containing
+ network.";
+ }
+ list supporting-node {
+ key "network-ref node-ref";
+ description
+ "Represents another node, in an underlay network, that
+ this node is supported by. Used to represent layering
+ structure.";
+ leaf network-ref {
+ type leafref {
+ path "../../../supporting-network/network-ref";
+ require-instance false;
+ }
+ description
+ "References the underlay network that the
+ underlay node is part of.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ description
+ "References the underlay node itself.";
+ }
+ }
+ }
+ }
+ }
+ container networks-state {
+ config false;
+ description
+ "Serves as top-level container for a list of state information
+ for networks";
+ list network {
+ key "network-ref";
+ description
+ "Data nodes representing operational data and state of
+ networks.
+ An instance is automatically created for every network
+ in the corresponding list under the networks container.";
+ uses network-ref;
+ leaf server-provided {
+ type boolean;
+ description
+ "Indicates whether the information concerning this
+ particular network is populated by the server
+ (server-provided true, the general case for network
+ information discovered from the server),
+ or whether it is configured by a client
+ (server-provided true, possible e.g. for
+ service overlays managed through a controller).";
+ }
+ }
+ }
+ }
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafreflinking/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreflinking/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
new file mode 100644
index 0000000..edf6bfa
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafreflinking/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
@@ -0,0 +1,28 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf name {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ }
+ }
+ }
+ leaf invalid-interval {
+ type union {
+ type int32;
+ type enumeration {
+ enum "unbounded";
+ }
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefreferingtoleaflist/SelfResolutionWhenLeafrefReferToContainerLeafList.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefreferingtoleaflist/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
new file mode 100644
index 0000000..ec9a6d3
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefreferingtoleaflist/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf-list network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafreftoderivedtype/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoderivedtype/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
new file mode 100644
index 0000000..eb2668e
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoderivedtype/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type status;
+ description
+ "Identifies a network.";
+ }
+ }
+ typedef status {
+ type uint8;
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafreftoinputinrpc/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoinputinrpc/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
new file mode 100644
index 0000000..917c434
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoinputinrpc/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
@@ -0,0 +1,23 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ input {
+ leaf-list network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ output {
+ }
+ }
+ leaf-list network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafref/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafref/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
new file mode 100644
index 0000000..26ccd1f
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafref/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
@@ -0,0 +1,26 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type leafref {
+ path "/status/current";
+ }
+ description
+ "Identifies a network.";
+ }
+ }
+ container status {
+ leaf current {
+ type uint8;
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafrefwithtypedef/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafrefwithtypedef/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
new file mode 100644
index 0000000..b61be6a
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafrefwithtypedef/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
@@ -0,0 +1,33 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ typedef node {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ container present {
+ typedef name {
+ type node;
+ }
+ leaf interval {
+ type name;
+ }
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
new file mode 100644
index 0000000..fd75d32
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
@@ -0,0 +1,50 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type leafref {
+ path "/transmitter/send";
+ }
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "/valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ list transmitter {
+ key "send";
+ leaf send {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafreftomultitypedef/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftomultitypedef/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
new file mode 100644
index 0000000..4b286d2
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafreftomultitypedef/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
@@ -0,0 +1,43 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type transmitter;
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "/valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ typedef transmitter {
+ type invalid-interval;
+ }
+ typedef invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafreftorpcinputleaflist/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftorpcinputleaflist/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
new file mode 100644
index 0000000..59e7a98
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafreftorpcinputleaflist/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
@@ -0,0 +1,26 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ input {
+ leaf-list network-id {
+ type network-ref;
+ description
+ "Identifies a network.";
+ }
+ leaf id {
+ type uint8;
+ }
+ }
+ output {
+ }
+ }
+ typedef network-ref {
+ type leafref {
+ path "/networks/input/id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafreftotypedefwithleafref/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftotypedefwithleafref/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
new file mode 100644
index 0000000..1bf423d
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafreftotypedefwithleafref/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
@@ -0,0 +1,45 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type transmitter;
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "/valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ typedef transmitter {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ leaf invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefundernodeingrouping/ietf-network.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefundernodeingrouping/ietf-network.yang
new file mode 100644
index 0000000..3db511e
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefundernodeingrouping/ietf-network.yang
@@ -0,0 +1,95 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+ grouping node-ref {
+ description
+ "Contains the information necessary to reference a node.";
+ container node-from-grouping {
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ }
+ }
+ }
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ list supporting-network {
+ key "network-ref";
+ description
+ "An underlay network, used to represent layered network
+ topologies.";
+ leaf network-ref {
+ type leafref {
+ path "/networks/network/network-id";
+ require-instance false;
+ }
+ description
+ "References the underlay network.";
+ }
+ }
+ list node {
+ key "node-id";
+ description
+ "The inventory of nodes of this network.";
+ leaf node-id {
+ type uint8;
+ description
+ "Identifies a node uniquely within the containing
+ network.";
+ }
+ list supporting-node {
+ key "network-ref node-ref";
+ description
+ "Represents another node, in an underlay network, that
+ this node is supported by. Used to represent layering
+ structure.";
+ leaf network-ref {
+ type leafref {
+ path "../../../supporting-network/network-ref";
+ require-instance false;
+ }
+ description
+ "References the underlay network that the
+ underlay node is part of.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ description
+ "References the underlay node itself.";
+ }
+ }
+ }
+ }
+ uses node-ref;
+ }
+
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrefleafderived/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrefleafderived/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
new file mode 100644
index 0000000..a3e0f29
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrefleafderived/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
@@ -0,0 +1,27 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpc/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpc/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
new file mode 100644
index 0000000..3dce93e
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpc/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
@@ -0,0 +1,23 @@
+module SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ output {
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
new file mode 100644
index 0000000..e8debbd
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
@@ -0,0 +1,28 @@
+module SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ grouping input {
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
new file mode 100644
index 0000000..9681d76
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../define/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidrelativeancestoraccess/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidrelativeancestoraccess/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
new file mode 100644
index 0000000..7e3d216
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidrelativeancestoraccess/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../../../define/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
new file mode 100644
index 0000000..93d8e94
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type network-ref;
+ description
+ "Identifies a network.";
+ }
+ leaf id {
+ type uint8;
+ }
+ }
+ typedef network-ref {
+ type leafref {
+ path "../id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftoinputwithgroupinginrpc/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftoinputwithgroupinginrpc/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
new file mode 100644
index 0000000..477832d
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftoinputwithgroupinginrpc/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
@@ -0,0 +1,28 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ grouping input {
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../networks/input/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
new file mode 100644
index 0000000..890bbaa
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
@@ -0,0 +1,50 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type leafref {
+ path "../../../../transmitter/send";
+ }
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "../../../../valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ list transmitter {
+ key "send";
+ leaf send {
+ type leafref {
+ path "../../invalid-interval";
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftotypedef/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftotypedef/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
new file mode 100644
index 0000000..5570f38
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftotypedef/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
@@ -0,0 +1,45 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type transmitter;
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "../../../../valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ typedef transmitter {
+ type leafref {
+ path "../../../../invalid-interval";
+ }
+ }
+ leaf invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/relativepath/pathlistener/PathListener.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/pathlistener/PathListener.yang
new file mode 100644
index 0000000..c4dae28
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/pathlistener/PathListener.yang
@@ -0,0 +1,31 @@
+module PathListener {
+ namespace "test";
+ prefix test;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type string;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type string;
+ }
+ }
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "../../test:interface/test:name";
+ }
+ }
+ leaf status {
+ type leafref {
+ path "/test:interface[name = current()/../ifname]/test:admin-status";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/relativepath/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
new file mode 100644
index 0000000..05ef0d2
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeaf.yang b/plugin/src/test/resources/leafreflinker/intrafile/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
new file mode 100644
index 0000000..375cace
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
@@ -0,0 +1,19 @@
+module SelfResolutionWhenLeafrefReferToContainerLeaf {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}