TypeFox / yang-lsp

A Language Server for YANG
http://www.yang-central.org
Apache License 2.0
51 stars 13 forks source link

leafref path serialization issue #216

Closed RimShao closed 2 years ago

RimShao commented 2 years ago

Hi,

yang-lsp serialization generate incorrect yang leafref path, please use the simplified pcg-yang-test-model.zip as input of yang serialization then check the output. Thanks.

input of e-pc-up-user-plane-predefined-rules.yang

          leaf-list predefined-pdrs {
            type leafref {
              path
                "/pcupe:user-plane/pcuppd:packet-detection/pcuppd:predefined-pdrs"
                + "/pcuppd:predefined-pdr/pcuppd:id";
            }
            description
              "Predefined PDR.";
          }

incorrect output of e-pc-up-user-plane-predefined-rules.yang

        leaf-list predefined-pdrs {
              type leafref {
                          path "/pcupe:user-plane/pcuppd:name/pcuppd:predefined-pdrs"
              + "/pcuppd:predefined-pdr/pcuppd:id";
               }
             description
            "Predefined PDR.";
      }

After yang-lsp serialization "pcuppd:packet-detection" is replaced as "pcuppd:name", which is incorrect.

pyang validation also proves the error of serialization output.

e-pc-up-user-plane-predefined-rules.yang:58: error: "e-pc-up-user-plane-packet-detection:name" in the path for predefined-pdrs at e-pc-up-user-plane-predefined-rules.yang:55 is not found

In our code, we use EcoreUtil.resolveAll resolving each yang module to compute yang module dependencies, if we comment EcoreUtil.resolveAll then the problem doesn't occur, perhaps this information help the problem analyze. Thanks.

EcoreUtil.resolveAll(AbstractModule)