@@ -1912,47 +1912,6 @@ namespace FourSlash {
19121912 }
19131913 }
19141914
1915- public verifyNavigationBarCount ( count : number ) {
1916- const actual = this . navigationBarItems ( ) . length ;
1917- if ( actual !== count ) {
1918- this . raiseError ( `Expected ${ count } items in navigation bar, got ${ actual } ` ) ;
1919- }
1920- }
1921-
1922- public verifyNavigationBarItem ( text : string , kind : string ) {
1923- this . verifyNavigationBarItemExists ( this . navigationBarItems ( ) , text , kind ) ;
1924- }
1925-
1926- public verifyNavigationBarChildItem ( parent : string , text : string , kind : string ) {
1927- const items = this . navigationBarItems ( ) ;
1928-
1929- // TODO: ts.find?
1930- for ( let i = 0 ; i < items . length ; i ++ ) {
1931- const item = items [ i ] ;
1932- if ( item . text === parent ) {
1933- this . verifyNavigationBarItemExists ( item . childItems , text , kind ) ;
1934- return ;
1935- }
1936- }
1937-
1938- this . raiseError ( `Could not find any parent named ${ parent } in: ${ JSON . stringify ( items , undefined , 2 ) } ` ) ;
1939- }
1940-
1941- private navigationBarItems ( ) {
1942- return this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
1943- }
1944-
1945- private verifyNavigationBarItemExists ( items : ts . NavigationBarItem [ ] , text : string , kind : string ) {
1946- for ( let i = 0 ; i < items . length ; i ++ ) {
1947- const item = items [ i ] ;
1948- if ( item . text === text && item . kind === kind ) {
1949- return ;
1950- }
1951- }
1952-
1953- this . raiseError ( `Could not find ${ JSON . stringify ( { text, kind} , undefined , 2 ) } in the navigation bar: ${ JSON . stringify ( items , undefined , 2 ) } ` ) ;
1954- }
1955-
19561915 /*
19571916 Check number of navigationItems which match both searchValue and matchKind.
19581917 Report an error if expected value and actual value do not match.
@@ -2009,12 +1968,12 @@ namespace FourSlash {
20091968 }
20101969 }
20111970
2012- public verifyGetScriptLexicalStructureListCount ( expected : number ) {
1971+ public verifyNavigationBarCount ( expected : number ) {
20131972 const items = this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
20141973 const actual = this . getNavigationBarItemsCount ( items ) ;
20151974
20161975 if ( expected !== actual ) {
2017- this . raiseError ( `verifyGetScriptLexicalStructureListCount failed - found: ${ actual } navigation items, expected: ${ expected } .` ) ;
1976+ this . raiseError ( `verifyNavigationBarCount failed - found: ${ actual } navigation items, expected: ${ expected } .` ) ;
20181977 }
20191978 }
20201979
@@ -2030,19 +1989,19 @@ namespace FourSlash {
20301989 return result ;
20311990 }
20321991
2033- public verifyGetScriptLexicalStructureListContains ( name : string , kind : string ) {
1992+ public verifyNavigationBarContains ( name : string , kind : string ) {
20341993 const items = this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
20351994
20361995 if ( ! items || items . length === 0 ) {
2037- this . raiseError ( "verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one." ) ;
1996+ this . raiseError ( "verifyNavigationBarContains failed - found 0 navigation items, expected at least one." ) ;
20381997 }
20391998
20401999 if ( this . navigationBarItemsContains ( items , name , kind ) ) {
20412000 return ;
20422001 }
20432002
2044- const missingItem = { name : name , kind : kind } ;
2045- this . raiseError ( `verifyGetScriptLexicalStructureListContains failed - could not find the item: ${ JSON . stringify ( missingItem , undefined , 2 ) } in the returned list: (${ JSON . stringify ( items , undefined , 2 ) } )` ) ;
2003+ const missingItem = { name, kind } ;
2004+ this . raiseError ( `verifyNavigationBarContains failed - could not find the item: ${ JSON . stringify ( missingItem , undefined , 2 ) } in the returned list: (${ JSON . stringify ( items , undefined , 2 ) } )` ) ;
20462005 }
20472006
20482007 private navigationBarItemsContains ( items : ts . NavigationBarItem [ ] , name : string , kind : string ) {
@@ -2062,6 +2021,20 @@ namespace FourSlash {
20622021 return false ;
20632022 }
20642023
2024+ public verifyNavigationBarChildItem ( parent : string , name : string , kind : string ) {
2025+ const items = this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
2026+
2027+ for ( let i = 0 ; i < items . length ; i ++ ) {
2028+ const item = items [ i ] ;
2029+ if ( item . text === parent ) {
2030+ if ( this . navigationBarItemsContains ( item . childItems , name , kind ) )
2031+ return ;
2032+ const missingItem = { name, kind } ;
2033+ this . raiseError ( `verifyNavigationBarChildItem failed - could not find the item: ${ JSON . stringify ( missingItem ) } in the children list: (${ JSON . stringify ( item . childItems , undefined , 2 ) } )` ) ;
2034+ }
2035+ }
2036+ }
2037+
20652038 public printNavigationItems ( searchValue : string ) {
20662039 const items = this . languageService . getNavigateToItems ( searchValue ) ;
20672040 const length = items && items . length ;
@@ -2074,7 +2047,7 @@ namespace FourSlash {
20742047 }
20752048 }
20762049
2077- public printScriptLexicalStructureItems ( ) {
2050+ public printNavigationBar ( ) {
20782051 const items = this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
20792052 const length = items && items . length ;
20802053
@@ -3070,31 +3043,23 @@ namespace FourSlashInterface {
30703043 this . DocCommentTemplate ( /*expectedText*/ undefined , /*expectedOffset*/ undefined , /*empty*/ true ) ;
30713044 }
30723045
3073- public getScriptLexicalStructureListCount ( count : number ) {
3074- this . state . verifyGetScriptLexicalStructureListCount ( count ) ;
3046+ public navigationBarCount ( count : number ) {
3047+ this . state . verifyNavigationBarCount ( count ) ;
30753048 }
30763049
30773050 // TODO: figure out what to do with the unused arguments.
3078- public getScriptLexicalStructureListContains (
3051+ public navigationBarContains (
30793052 name : string ,
30803053 kind : string ,
30813054 fileName ?: string ,
30823055 parentName ?: string ,
30833056 isAdditionalSpan ?: boolean ,
30843057 markerPosition ?: number ) {
3085- this . state . verifyGetScriptLexicalStructureListContains ( name , kind ) ;
3086- }
3087-
3088- public navigationBarCount ( count : number ) {
3089- this . state . verifyNavigationBarCount ( count ) ;
3090- }
3091-
3092- public navigationBarItem ( text : string , kind : string ) {
3093- this . state . verifyNavigationBarItem ( text , kind ) ;
3058+ this . state . verifyNavigationBarContains ( name , kind ) ;
30943059 }
30953060
3096- public navigationBarChildItem ( parent : string , text : string , kind : string ) {
3097- this . state . verifyNavigationBarChildItem ( parent , text , kind ) ;
3061+ public navigationBarChildItem ( parent : string , name : string , kind : string ) {
3062+ this . state . verifyNavigationBarChildItem ( parent , name , kind ) ;
30983063 }
30993064
31003065 public navigationItemsListCount ( count : number , searchValue : string , matchKind ?: string ) {
@@ -3287,8 +3252,8 @@ namespace FourSlashInterface {
32873252 this . state . printNavigationItems ( searchValue ) ;
32883253 }
32893254
3290- public printScriptLexicalStructureItems ( ) {
3291- this . state . printScriptLexicalStructureItems ( ) ;
3255+ public printNavigationBar ( ) {
3256+ this . state . printNavigationBar ( ) ;
32923257 }
32933258
32943259 public printReferences ( ) {
0 commit comments