@@ -46,7 +46,7 @@ namespace ts.NavigationBar {
46
46
}
47
47
48
48
function getChildNodes ( nodes : Node [ ] ) : Node [ ] {
49
- let childNodes : Node [ ] = [ ] ;
49
+ const childNodes : Node [ ] = [ ] ;
50
50
51
51
function visit ( node : Node ) {
52
52
switch ( node . kind ) {
@@ -109,7 +109,7 @@ namespace ts.NavigationBar {
109
109
}
110
110
}
111
111
112
- //for (let i = 0, n = nodes.length; i < n; i++) {
112
+ // for (let i = 0, n = nodes.length; i < n; i++) {
113
113
// let node = nodes[i];
114
114
115
115
// if (node.kind === SyntaxKind.ClassDeclaration ||
@@ -123,13 +123,13 @@ namespace ts.NavigationBar {
123
123
// else if (node.kind === SyntaxKind.VariableStatement) {
124
124
// childNodes.push.apply(childNodes, (<VariableStatement>node).declarations);
125
125
// }
126
- //}
126
+ // }
127
127
forEach ( nodes , visit ) ;
128
128
return sortNodes ( childNodes ) ;
129
129
}
130
130
131
131
function getTopLevelNodes ( node : SourceFile ) : Node [ ] {
132
- let topLevelNodes : Node [ ] = [ ] ;
132
+ const topLevelNodes : Node [ ] = [ ] ;
133
133
topLevelNodes . push ( node ) ;
134
134
135
135
addTopLevelNodes ( node . statements , topLevelNodes ) ;
@@ -157,7 +157,7 @@ namespace ts.NavigationBar {
157
157
function addTopLevelNodes ( nodes : Node [ ] , topLevelNodes : Node [ ] ) : void {
158
158
nodes = sortNodes ( nodes ) ;
159
159
160
- for ( let node of nodes ) {
160
+ for ( const node of nodes ) {
161
161
switch ( node . kind ) {
162
162
case SyntaxKind . ClassDeclaration :
163
163
topLevelNodes . push ( node ) ;
@@ -198,7 +198,7 @@ namespace ts.NavigationBar {
198
198
}
199
199
200
200
function hasNamedFunctionDeclarations ( nodes : NodeArray < Statement > ) : boolean {
201
- for ( let s of nodes ) {
201
+ for ( const s of nodes ) {
202
202
if ( s . kind === SyntaxKind . FunctionDeclaration && ! isEmpty ( ( < FunctionDeclaration > s ) . name . text ) ) {
203
203
return true ;
204
204
}
@@ -238,17 +238,17 @@ namespace ts.NavigationBar {
238
238
}
239
239
240
240
function getItemsWorker ( nodes : Node [ ] , createItem : ( n : Node ) => ts . NavigationBarItem ) : ts . NavigationBarItem [ ] {
241
- let items : ts . NavigationBarItem [ ] = [ ] ;
241
+ const items : ts . NavigationBarItem [ ] = [ ] ;
242
242
243
- let keyToItem : Map < NavigationBarItem > = { } ;
243
+ const keyToItem : Map < NavigationBarItem > = { } ;
244
244
245
- for ( let child of nodes ) {
246
- let item = createItem ( child ) ;
245
+ for ( const child of nodes ) {
246
+ const item = createItem ( child ) ;
247
247
if ( item !== undefined ) {
248
248
if ( item . text . length > 0 ) {
249
- let key = item . text + "-" + item . kind + "-" + item . indent ;
249
+ const key = item . text + "-" + item . kind + "-" + item . indent ;
250
250
251
- let itemWithSameName = keyToItem [ key ] ;
251
+ const itemWithSameName = keyToItem [ key ] ;
252
252
if ( itemWithSameName ) {
253
253
// We had an item with the same name. Merge these items together.
254
254
merge ( itemWithSameName , item ) ;
@@ -275,8 +275,8 @@ namespace ts.NavigationBar {
275
275
276
276
// Next, recursively merge or add any children in the source as appropriate.
277
277
outer:
278
- for ( let sourceChild of source . childItems ) {
279
- for ( let targetChild of target . childItems ) {
278
+ for ( const sourceChild of source . childItems ) {
279
+ for ( const targetChild of target . childItems ) {
280
280
if ( targetChild . text === sourceChild . text && targetChild . kind === sourceChild . kind ) {
281
281
// Found a match. merge them.
282
282
merge ( targetChild , sourceChild ) ;
@@ -383,7 +383,7 @@ namespace ts.NavigationBar {
383
383
return ! text || text . trim ( ) === "" ;
384
384
}
385
385
386
- function getNavigationBarItem ( text : string , kind : string , kindModifiers : string , spans : TextSpan [ ] , childItems : NavigationBarItem [ ] = [ ] , indent : number = 0 ) : NavigationBarItem {
386
+ function getNavigationBarItem ( text : string , kind : string , kindModifiers : string , spans : TextSpan [ ] , childItems : NavigationBarItem [ ] = [ ] , indent = 0 ) : NavigationBarItem {
387
387
if ( isEmpty ( text ) ) {
388
388
return undefined ;
389
389
}
@@ -437,7 +437,7 @@ namespace ts.NavigationBar {
437
437
}
438
438
439
439
// Otherwise, we need to aggregate each identifier to build up the qualified name.
440
- let result : string [ ] = [ ] ;
440
+ const result : string [ ] = [ ] ;
441
441
442
442
result . push ( moduleDeclaration . name . text ) ;
443
443
@@ -451,9 +451,9 @@ namespace ts.NavigationBar {
451
451
}
452
452
453
453
function createModuleItem ( node : ModuleDeclaration ) : NavigationBarItem {
454
- let moduleName = getModuleName ( node ) ;
454
+ const moduleName = getModuleName ( node ) ;
455
455
456
- let childItems = getItemsWorker ( getChildNodes ( ( < Block > getInnermostModule ( node ) . body ) . statements ) , createChildItem ) ;
456
+ const childItems = getItemsWorker ( getChildNodes ( ( < Block > getInnermostModule ( node ) . body ) . statements ) , createChildItem ) ;
457
457
458
458
return getNavigationBarItem ( moduleName ,
459
459
ts . ScriptElementKind . moduleElement ,
@@ -465,9 +465,9 @@ namespace ts.NavigationBar {
465
465
466
466
function createFunctionItem ( node : FunctionDeclaration ) : ts . NavigationBarItem {
467
467
if ( node . body && node . body . kind === SyntaxKind . Block ) {
468
- let childItems = getItemsWorker ( sortNodes ( ( < Block > node . body ) . statements ) , createChildItem ) ;
468
+ const childItems = getItemsWorker ( sortNodes ( ( < Block > node . body ) . statements ) , createChildItem ) ;
469
469
470
- return getNavigationBarItem ( ! node . name ? "default" : node . name . text ,
470
+ return getNavigationBarItem ( ! node . name ? "default" : node . name . text ,
471
471
ts . ScriptElementKind . functionElement ,
472
472
getNodeModifiers ( node ) ,
473
473
[ getNodeSpan ( node ) ] ,
@@ -489,7 +489,7 @@ namespace ts.NavigationBar {
489
489
490
490
function createMemberFunctionLikeItem ( node : MethodDeclaration | ConstructorDeclaration ) : ts . NavigationBarItem {
491
491
if ( node . body && node . body . kind === SyntaxKind . Block ) {
492
- let childItems = getItemsWorker ( sortNodes ( ( < Block > node . body ) . statements ) , createChildItem ) ;
492
+ const childItems = getItemsWorker ( sortNodes ( ( < Block > node . body ) . statements ) , createChildItem ) ;
493
493
let scriptElementKind : string ;
494
494
let memberFunctionName : string ;
495
495
if ( node . kind === SyntaxKind . MethodDeclaration ) {
@@ -513,16 +513,16 @@ namespace ts.NavigationBar {
513
513
}
514
514
515
515
function createSourceFileItem ( node : SourceFile ) : ts . NavigationBarItem {
516
- let childItems = getItemsWorker ( getChildNodes ( node . statements ) , createChildItem ) ;
516
+ const childItems = getItemsWorker ( getChildNodes ( node . statements ) , createChildItem ) ;
517
517
518
518
if ( childItems === undefined || childItems . length === 0 ) {
519
519
return undefined ;
520
520
}
521
521
522
522
hasGlobalNode = true ;
523
- let rootName = isExternalModule ( node )
523
+ const rootName = isExternalModule ( node )
524
524
? "\"" + escapeString ( getBaseFileName ( removeFileExtension ( normalizePath ( node . fileName ) ) ) ) + "\""
525
- : "<global>"
525
+ : "<global>" ;
526
526
527
527
return getNavigationBarItem ( rootName ,
528
528
ts . ScriptElementKind . moduleElement ,
@@ -535,22 +535,22 @@ namespace ts.NavigationBar {
535
535
let childItems : NavigationBarItem [ ] ;
536
536
537
537
if ( node . members ) {
538
- let constructor = < ConstructorDeclaration > forEach ( node . members , member => {
538
+ const constructor = < ConstructorDeclaration > forEach ( node . members , member => {
539
539
return member . kind === SyntaxKind . Constructor && member ;
540
540
} ) ;
541
541
542
542
// Add the constructor parameters in as children of the class (for property parameters).
543
543
// Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that
544
544
// are not properties will be filtered out later by createChildItem.
545
- let nodes : Node [ ] = removeDynamicallyNamedProperties ( node ) ;
545
+ const nodes : Node [ ] = removeDynamicallyNamedProperties ( node ) ;
546
546
if ( constructor ) {
547
547
addRange ( nodes , filter ( constructor . parameters , p => ! isBindingPattern ( p . name ) ) ) ;
548
548
}
549
549
550
550
childItems = getItemsWorker ( sortNodes ( nodes ) , createChildItem ) ;
551
551
}
552
552
553
- var nodeName = ! node . name ? "default" : node . name . text ;
553
+ const nodeName = ! node . name ? "default" : node . name . text ;
554
554
555
555
return getNavigationBarItem (
556
556
nodeName ,
@@ -562,7 +562,7 @@ namespace ts.NavigationBar {
562
562
}
563
563
564
564
function createEnumItem ( node : EnumDeclaration ) : ts . NavigationBarItem {
565
- let childItems = getItemsWorker ( sortNodes ( removeComputedProperties ( node ) ) , createChildItem ) ;
565
+ const childItems = getItemsWorker ( sortNodes ( removeComputedProperties ( node ) ) , createChildItem ) ;
566
566
return getNavigationBarItem (
567
567
node . name . text ,
568
568
ts . ScriptElementKind . enumElement ,
@@ -573,7 +573,7 @@ namespace ts.NavigationBar {
573
573
}
574
574
575
575
function createInterfaceItem ( node : InterfaceDeclaration ) : ts . NavigationBarItem {
576
- let childItems = getItemsWorker ( sortNodes ( removeDynamicallyNamedProperties ( node ) ) , createChildItem ) ;
576
+ const childItems = getItemsWorker ( sortNodes ( removeDynamicallyNamedProperties ( node ) ) , createChildItem ) ;
577
577
return getNavigationBarItem (
578
578
node . name . text ,
579
579
ts . ScriptElementKind . interfaceElement ,
@@ -591,7 +591,7 @@ namespace ts.NavigationBar {
591
591
/**
592
592
* Like removeComputedProperties, but retains the properties with well known symbol names
593
593
*/
594
- function removeDynamicallyNamedProperties ( node : ClassDeclaration | InterfaceDeclaration ) : Declaration [ ] {
594
+ function removeDynamicallyNamedProperties ( node : ClassDeclaration | InterfaceDeclaration ) : Declaration [ ] {
595
595
return filter < Declaration > ( node . members , member => ! hasDynamicName ( member ) ) ;
596
596
}
597
597
@@ -619,11 +619,11 @@ namespace ts.NavigationBar {
619
619
const anonClassText = "<class>" ;
620
620
let indent = 0 ;
621
621
622
- let rootName = isExternalModule ( sourceFile ) ?
622
+ const rootName = isExternalModule ( sourceFile ) ?
623
623
"\"" + escapeString ( getBaseFileName ( removeFileExtension ( normalizePath ( sourceFile . fileName ) ) ) ) + "\""
624
624
: "<global>" ;
625
625
626
- let sourceFileItem = getNavBarItem ( rootName , ScriptElementKind . moduleElement , [ getNodeSpan ( sourceFile ) ] ) ;
626
+ const sourceFileItem = getNavBarItem ( rootName , ScriptElementKind . moduleElement , [ getNodeSpan ( sourceFile ) ] ) ;
627
627
let topItem = sourceFileItem ;
628
628
629
629
// Walk the whole file, because we want to also find function expressions - which may be in variable initializer,
@@ -656,12 +656,12 @@ namespace ts.NavigationBar {
656
656
}
657
657
}
658
658
659
- function createNavBarItem ( node : Node ) : NavigationBarItem {
659
+ function createNavBarItem ( node : Node ) : NavigationBarItem {
660
660
switch ( node . kind ) {
661
661
case SyntaxKind . VariableDeclaration :
662
662
// Only add to the navbar if at the top-level of the file
663
663
// Note: "const" and "let" are also SyntaxKind.VariableDeclarations
664
- if ( node . parent /*VariableDeclarationList*/ . parent /*VariableStatement*/
664
+ if ( node . parent /*VariableDeclarationList*/ . parent /*VariableStatement*/
665
665
. parent /*SourceFile*/ . kind !== SyntaxKind . SourceFile ) {
666
666
return undefined ;
667
667
}
@@ -724,7 +724,7 @@ namespace ts.NavigationBar {
724
724
function getNavBarItem ( text : string , kind : string , spans : TextSpan [ ] , kindModifiers = ScriptElementKindModifier . none ) : NavigationBarItem {
725
725
return {
726
726
text, kind, kindModifiers, spans, childItems : [ ] , indent, bolded : false , grayed : false
727
- }
727
+ } ;
728
728
}
729
729
730
730
function getDefineModuleItem ( node : Node ) : NavigationBarItem {
@@ -737,7 +737,7 @@ namespace ts.NavigationBar {
737
737
return undefined ;
738
738
}
739
739
const callExpr = node . parent as CallExpression ;
740
- if ( callExpr . expression . kind !== SyntaxKind . Identifier || callExpr . expression . getText ( ) !== ' define' ) {
740
+ if ( callExpr . expression . kind !== SyntaxKind . Identifier || callExpr . expression . getText ( ) !== " define" ) {
741
741
return undefined ;
742
742
}
743
743
0 commit comments