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