@@ -1961,45 +1961,23 @@ namespace FourSlash {
1961
1961
1962
1962
public verifyNavigationBar ( json : any ) {
1963
1963
let items = this . languageService . getNavigationBarItems ( this . activeFile . fileName ) ;
1964
- items = this . simplifyNavigationBar ( items ) ;
1965
- if ( JSON . stringify ( items ) !== JSON . stringify ( json ) ) {
1966
- this . raiseError ( `verifyNavigationBar failed - expected: ${ JSON . stringify ( json , undefined , 2 ) } , got: ${ JSON . stringify ( items , undefined , 2 ) } ` ) ;
1967
- }
1968
- }
1969
-
1970
- // Remove any properties that tend to all have the same value so that test data is easier to read.
1971
- private simplifyNavigationBar ( items : ts . NavigationBarItem [ ] ) : any {
1972
- return items . map ( item => {
1973
- item = ts . clone ( item ) ;
1974
- if ( item . kindModifiers === "" ) {
1975
- delete item . kindModifiers ;
1976
- }
1977
- // We won't check this.
1978
- delete item . spans ;
1979
- item . childItems = item . childItems . map ( child => {
1980
- child = ts . clone ( child ) ;
1981
- delete child . spans ;
1982
- ts . Debug . assert ( child . childItems . length === 0 ) ;
1983
- delete child . childItems ;
1984
- ts . Debug . assert ( child . indent === 0 ) ;
1985
- delete child . indent ;
1986
- ts . Debug . assert ( child . bolded === false ) ;
1987
- delete child . bolded ;
1988
- ts . Debug . assert ( child . grayed === false ) ;
1989
- delete child . grayed ;
1990
- if ( child . kindModifiers === "" ) {
1991
- delete child . kindModifiers ;
1992
- }
1993
- return child ;
1994
- } ) ;
1995
- if ( item . bolded === false ) {
1996
- delete item . bolded ;
1997
- }
1998
- if ( item . grayed === false ) {
1999
- delete item . grayed ;
1964
+ if ( JSON . stringify ( items , replacer ) !== JSON . stringify ( json ) ) {
1965
+ this . raiseError ( `verifyNavigationBar failed - expected: ${ JSON . stringify ( json , undefined , 2 ) } , got: ${ JSON . stringify ( items , replacer , 2 ) } ` ) ;
1966
+ }
1967
+
1968
+ // Make the data easier to read.
1969
+ function replacer ( key : string , value : any ) {
1970
+ switch ( key ) {
1971
+ case 'spans' :
1972
+ // We won't ever check this.
1973
+ return undefined ;
1974
+ case 'childItems' :
1975
+ return value . length === 0 ? undefined : value ;
1976
+ default :
1977
+ // Omit falsy values, those are presumed to be the default.
1978
+ return value || undefined ;
2000
1979
}
2001
- return item ;
2002
- } ) ;
1980
+ }
2003
1981
}
2004
1982
2005
1983
public printNavigationItems ( searchValue : string ) {
0 commit comments