TypeFox / yang-lsp

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

Augment In DeepUses Grouping #161

Closed huyuwen closed 4 years ago

huyuwen commented 5 years ago

There is a module which has very deep uses grouping stack. In a certain level, there defines an augment which augmented a container which defined in an grouping.

module ik {
  grouping ct_akpwcg {
    container pkt {
     leaf lf_hpri_key {
       type empty;
     }
   }
 }
 grouping ks_akpwcg {
   uses ct_akpwcg {
     augment pkt {
       container c_en_pri_key {
      uses evg;
        }
      }
    }
  }
  grouping evg {
    leaf value {
       type binary;
    }
  }
  uses ks_akpwcg;

//  Deviation Target:  ug is short for uses-grouping
//  /pkt (container-in-ug<ct_akpwcg>-in-ug<ks_akpwcg>)
//      /lf_hpri_key (leaf)
//
    deviation /pkt/lf_hpri_key {
        deviate not-supported;
    }

 //  Deviation Target: ug is short for uses-grouping
 //  /pkt (container-in-ug<ct_akpwcg>-in-ug<ks_akpwcg>)
 //      /c_en_pri_key (container-in-augmented-container-of-pkt-in-ug<ct_akpwcg>-under<ks_akpwcg>)
 //
   deviation /pkt/c_en_pri_key {
    deviate not-supported;
   }
 }

There are two deviation's

  1. /pkt/lf_hpri_key should point to the leaf defined in the original container pkt of grouping ct_akpwcg
  2. /pkt/c_en_pri_key should point to the leaf augmented from the augement pkt in uses ct_akpwcg.

Actually, the leaf c_en_pri_key in second path couldn't be linked correctly. Here is the test case. AugmentInDeepUsesGroupingTest.txt

According to debug, I think this is a tricky issue. There missing some logic in ScopeContextProvider.

computeScope(Augment node, QualifiedName nodePath, IScopeContext ctx, boolean isConfig) 
inlineGrouping(Augment augment, QualifiedName name, GroupingInliningScopeContext context, boolean isConfig)
private def dispatch void inlineGrouping(Uses statement, QualifiedName name, GroupingInliningScopeContext context, boolean isConfig)