@@ -152,69 +152,82 @@ module TypeScript.Services {
152
152
}
153
153
}
154
154
155
+ private getNavigationBarItem ( text : string , kind : string , kindModifiers : string , spans : TypeScript . TextSpan [ ] , childItems ?: ts . NavigationBarItem [ ] , indent : number = 0 ) : ts . NavigationBarItem {
156
+ return {
157
+ text : text ,
158
+ kind : kind ,
159
+ kindModifiers : kindModifiers ,
160
+ spans : spans ,
161
+ childItems : childItems ,
162
+ indent : indent ,
163
+ bolded : false ,
164
+ grayed : false
165
+ } ;
166
+ }
167
+
155
168
private createChildItem ( node : ISyntaxNode ) : ts . NavigationBarItem {
156
169
switch ( node . kind ( ) ) {
157
170
case SyntaxKind . Parameter :
158
171
var parameter = < ParameterSyntax > node ;
159
172
if ( parameter . modifiers . length === 0 ) {
160
173
return null ;
161
174
}
162
- return new ts . NavigationBarItem ( parameter . identifier . text ( ) , ts . ScriptElementKind . memberVariableElement , this . getKindModifiers ( parameter . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
175
+ return this . getNavigationBarItem ( parameter . identifier . text ( ) , ts . ScriptElementKind . memberVariableElement , this . getKindModifiers ( parameter . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
163
176
164
177
case SyntaxKind . MemberFunctionDeclaration :
165
178
var memberFunction = < MemberFunctionDeclarationSyntax > node ;
166
- return new ts . NavigationBarItem ( memberFunction . propertyName . text ( ) , ts . ScriptElementKind . memberFunctionElement , this . getKindModifiers ( memberFunction . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
179
+ return this . getNavigationBarItem ( memberFunction . propertyName . text ( ) , ts . ScriptElementKind . memberFunctionElement , this . getKindModifiers ( memberFunction . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
167
180
168
181
case SyntaxKind . GetAccessor :
169
182
var getAccessor = < GetAccessorSyntax > node ;
170
- return new ts . NavigationBarItem ( getAccessor . propertyName . text ( ) , ts . ScriptElementKind . memberGetAccessorElement , this . getKindModifiers ( getAccessor . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
183
+ return this . getNavigationBarItem ( getAccessor . propertyName . text ( ) , ts . ScriptElementKind . memberGetAccessorElement , this . getKindModifiers ( getAccessor . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
171
184
172
185
case SyntaxKind . SetAccessor :
173
186
var setAccessor = < SetAccessorSyntax > node ;
174
- return new ts . NavigationBarItem ( setAccessor . propertyName . text ( ) , ts . ScriptElementKind . memberSetAccessorElement , this . getKindModifiers ( setAccessor . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
187
+ return this . getNavigationBarItem ( setAccessor . propertyName . text ( ) , ts . ScriptElementKind . memberSetAccessorElement , this . getKindModifiers ( setAccessor . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
175
188
176
189
case SyntaxKind . IndexSignature :
177
190
var indexSignature = < IndexSignatureSyntax > node ;
178
- return new ts . NavigationBarItem ( "[]" , ts . ScriptElementKind . indexSignatureElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
191
+ return this . getNavigationBarItem ( "[]" , ts . ScriptElementKind . indexSignatureElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
179
192
180
193
case SyntaxKind . EnumElement :
181
194
var enumElement = < EnumElementSyntax > node ;
182
- return new ts . NavigationBarItem ( enumElement . propertyName . text ( ) , ts . ScriptElementKind . memberVariableElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
195
+ return this . getNavigationBarItem ( enumElement . propertyName . text ( ) , ts . ScriptElementKind . memberVariableElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
183
196
184
197
case SyntaxKind . CallSignature :
185
198
var callSignature = < CallSignatureSyntax > node ;
186
- return new ts . NavigationBarItem ( "()" , ts . ScriptElementKind . callSignatureElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
199
+ return this . getNavigationBarItem ( "()" , ts . ScriptElementKind . callSignatureElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
187
200
188
201
case SyntaxKind . ConstructSignature :
189
202
var constructSignature = < ConstructSignatureSyntax > node ;
190
- return new ts . NavigationBarItem ( "new()" , ts . ScriptElementKind . constructSignatureElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
203
+ return this . getNavigationBarItem ( "new()" , ts . ScriptElementKind . constructSignatureElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
191
204
192
205
case SyntaxKind . MethodSignature :
193
206
var methodSignature = < MethodSignatureSyntax > node ;
194
- return new ts . NavigationBarItem ( methodSignature . propertyName . text ( ) , ts . ScriptElementKind . memberFunctionElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
207
+ return this . getNavigationBarItem ( methodSignature . propertyName . text ( ) , ts . ScriptElementKind . memberFunctionElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
195
208
196
209
case SyntaxKind . PropertySignature :
197
210
var propertySignature = < PropertySignatureSyntax > node ;
198
- return new ts . NavigationBarItem ( propertySignature . propertyName . text ( ) , ts . ScriptElementKind . memberVariableElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
211
+ return this . getNavigationBarItem ( propertySignature . propertyName . text ( ) , ts . ScriptElementKind . memberVariableElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
199
212
200
213
case SyntaxKind . FunctionDeclaration :
201
214
var functionDeclaration = < FunctionDeclarationSyntax > node ;
202
215
if ( ! this . isTopLevelFunctionDeclaration ( functionDeclaration ) ) {
203
- return new ts . NavigationBarItem ( functionDeclaration . identifier . text ( ) , ts . ScriptElementKind . functionElement , this . getKindModifiers ( functionDeclaration . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
216
+ return this . getNavigationBarItem ( functionDeclaration . identifier . text ( ) , ts . ScriptElementKind . functionElement , this . getKindModifiers ( functionDeclaration . modifiers ) , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
204
217
}
205
218
break ;
206
219
207
220
case SyntaxKind . MemberVariableDeclaration :
208
221
var memberVariableDeclaration = < MemberVariableDeclarationSyntax > node ;
209
- return new ts . NavigationBarItem ( memberVariableDeclaration . variableDeclarator . propertyName . text ( ) , ts . ScriptElementKind . memberVariableElement , this . getKindModifiers ( memberVariableDeclaration . modifiers ) , [ TextSpan . fromBounds ( start ( memberVariableDeclaration . variableDeclarator ) , end ( memberVariableDeclaration . variableDeclarator ) ) ] ) ;
222
+ return this . getNavigationBarItem ( memberVariableDeclaration . variableDeclarator . propertyName . text ( ) , ts . ScriptElementKind . memberVariableElement , this . getKindModifiers ( memberVariableDeclaration . modifiers ) , [ TextSpan . fromBounds ( start ( memberVariableDeclaration . variableDeclarator ) , end ( memberVariableDeclaration . variableDeclarator ) ) ] ) ;
210
223
211
224
case SyntaxKind . VariableDeclarator :
212
225
var variableDeclarator = < VariableDeclaratorSyntax > node ;
213
- return new ts . NavigationBarItem ( variableDeclarator . propertyName . text ( ) , ts . ScriptElementKind . variableElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( variableDeclarator ) , end ( variableDeclarator ) ) ] ) ;
226
+ return this . getNavigationBarItem ( variableDeclarator . propertyName . text ( ) , ts . ScriptElementKind . variableElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( variableDeclarator ) , end ( variableDeclarator ) ) ] ) ;
214
227
215
228
case SyntaxKind . ConstructorDeclaration :
216
229
var constructorDeclaration = < ConstructorDeclarationSyntax > node ;
217
- return new ts . NavigationBarItem ( "constructor" , ts . ScriptElementKind . constructorImplementationElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
230
+ return this . getNavigationBarItem ( "constructor" , ts . ScriptElementKind . constructorImplementationElement , ts . ScriptElementKindModifier . none , [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ) ;
218
231
}
219
232
220
233
return null ;
@@ -273,7 +286,7 @@ module TypeScript.Services {
273
286
274
287
var childItems = this . getItemsWorker ( ( ) => this . getChildNodes ( node . moduleElements ) , n => this . createChildItem ( n ) ) ;
275
288
276
- return new ts . NavigationBarItem ( moduleNames . join ( "." ) ,
289
+ return this . getNavigationBarItem ( moduleNames . join ( "." ) ,
277
290
ts . ScriptElementKind . moduleElement ,
278
291
this . getKindModifiers ( node . modifiers ) ,
279
292
[ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ,
@@ -284,7 +297,7 @@ module TypeScript.Services {
284
297
private createFunctionItem ( node : FunctionDeclarationSyntax ) {
285
298
var childItems = this . getItemsWorker ( ( ) => node . block . statements , n => this . createChildItem ( n ) ) ;
286
299
287
- return new ts . NavigationBarItem ( node . identifier . text ( ) ,
300
+ return this . getNavigationBarItem ( node . identifier . text ( ) ,
288
301
ts . ScriptElementKind . functionElement ,
289
302
this . getKindModifiers ( node . modifiers ) ,
290
303
[ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ,
@@ -300,7 +313,7 @@ module TypeScript.Services {
300
313
}
301
314
302
315
this . hasGlobalNode = true ;
303
- return new ts . NavigationBarItem ( "<global>" ,
316
+ return this . getNavigationBarItem ( "<global>" ,
304
317
ts . ScriptElementKind . moduleElement ,
305
318
ts . ScriptElementKindModifier . none ,
306
319
[ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ,
@@ -317,7 +330,7 @@ module TypeScript.Services {
317
330
: node . classElements ;
318
331
319
332
var childItems = this . getItemsWorker ( ( ) => nodes , n => this . createChildItem ( n ) ) ;
320
- return new ts . NavigationBarItem (
333
+ return this . getNavigationBarItem (
321
334
node . identifier . text ( ) ,
322
335
ts . ScriptElementKind . classElement ,
323
336
this . getKindModifiers ( node . modifiers ) ,
@@ -328,7 +341,7 @@ module TypeScript.Services {
328
341
329
342
private createEnumItem ( node : TypeScript . EnumDeclarationSyntax ) : ts . NavigationBarItem {
330
343
var childItems = this . getItemsWorker ( ( ) => node . enumElements , n => this . createChildItem ( n ) ) ;
331
- return new ts . NavigationBarItem (
344
+ return this . getNavigationBarItem (
332
345
node . identifier . text ( ) ,
333
346
ts . ScriptElementKind . enumElement ,
334
347
this . getKindModifiers ( node . modifiers ) ,
@@ -339,7 +352,7 @@ module TypeScript.Services {
339
352
340
353
private createIterfaceItem ( node : TypeScript . InterfaceDeclarationSyntax ) : ts . NavigationBarItem {
341
354
var childItems = this . getItemsWorker ( ( ) => node . body . typeMembers , n => this . createChildItem ( n ) ) ;
342
- return new ts . NavigationBarItem (
355
+ return this . getNavigationBarItem (
343
356
node . identifier . text ( ) ,
344
357
ts . ScriptElementKind . interfaceElement ,
345
358
this . getKindModifiers ( node . modifiers ) ,
0 commit comments