@@ -1912,47 +1912,6 @@ namespace FourSlash {
1912
1912
}
1913
1913
}
1914
1914
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
-
1956
1915
/*
1957
1916
Check number of navigationItems which match both searchValue and matchKind.
1958
1917
Report an error if expected value and actual value do not match.
@@ -2009,12 +1968,12 @@ namespace FourSlash {
2009
1968
}
2010
1969
}
2011
1970
2012
- public verifyGetScriptLexicalStructureListCount ( expected : number ) {
1971
+ public verifyNavigationBarCount ( expected : number ) {
2013
1972
const items = this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
2014
1973
const actual = this . getNavigationBarItemsCount ( items ) ;
2015
1974
2016
1975
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 } .` ) ;
2018
1977
}
2019
1978
}
2020
1979
@@ -2030,19 +1989,19 @@ namespace FourSlash {
2030
1989
return result ;
2031
1990
}
2032
1991
2033
- public verifyGetScriptLexicalStructureListContains ( name : string , kind : string ) {
1992
+ public verifyNavigationBarContains ( name : string , kind : string ) {
2034
1993
const items = this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
2035
1994
2036
1995
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." ) ;
2038
1997
}
2039
1998
2040
1999
if ( this . navigationBarItemsContains ( items , name , kind ) ) {
2041
2000
return ;
2042
2001
}
2043
2002
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 ) } )` ) ;
2046
2005
}
2047
2006
2048
2007
private navigationBarItemsContains ( items : ts . NavigationBarItem [ ] , name : string , kind : string ) {
@@ -2062,6 +2021,20 @@ namespace FourSlash {
2062
2021
return false ;
2063
2022
}
2064
2023
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
+
2065
2038
public printNavigationItems ( searchValue : string ) {
2066
2039
const items = this . languageService . getNavigateToItems ( searchValue ) ;
2067
2040
const length = items && items . length ;
@@ -2074,7 +2047,7 @@ namespace FourSlash {
2074
2047
}
2075
2048
}
2076
2049
2077
- public printScriptLexicalStructureItems ( ) {
2050
+ public printNavigationBar ( ) {
2078
2051
const items = this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
2079
2052
const length = items && items . length ;
2080
2053
@@ -3070,31 +3043,23 @@ namespace FourSlashInterface {
3070
3043
this . DocCommentTemplate ( /*expectedText*/ undefined , /*expectedOffset*/ undefined , /*empty*/ true ) ;
3071
3044
}
3072
3045
3073
- public getScriptLexicalStructureListCount ( count : number ) {
3074
- this . state . verifyGetScriptLexicalStructureListCount ( count ) ;
3046
+ public navigationBarCount ( count : number ) {
3047
+ this . state . verifyNavigationBarCount ( count ) ;
3075
3048
}
3076
3049
3077
3050
// TODO: figure out what to do with the unused arguments.
3078
- public getScriptLexicalStructureListContains (
3051
+ public navigationBarContains (
3079
3052
name : string ,
3080
3053
kind : string ,
3081
3054
fileName ?: string ,
3082
3055
parentName ?: string ,
3083
3056
isAdditionalSpan ?: boolean ,
3084
3057
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 ) ;
3094
3059
}
3095
3060
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 ) ;
3098
3063
}
3099
3064
3100
3065
public navigationItemsListCount ( count : number , searchValue : string , matchKind ?: string ) {
@@ -3287,8 +3252,8 @@ namespace FourSlashInterface {
3287
3252
this . state . printNavigationItems ( searchValue ) ;
3288
3253
}
3289
3254
3290
- public printScriptLexicalStructureItems ( ) {
3291
- this . state . printScriptLexicalStructureItems ( ) ;
3255
+ public printNavigationBar ( ) {
3256
+ this . state . printNavigationBar ( ) ;
3292
3257
}
3293
3258
3294
3259
public printReferences ( ) {
0 commit comments