1- ///<reference path='references.ts' />
21
32module TypeScript . Services {
43 export class NavigationBarItemGetter {
@@ -152,69 +151,82 @@ module TypeScript.Services {
152151 }
153152 }
154153
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+
155167 private createChildItem ( node : ISyntaxNode ) : ts . NavigationBarItem {
156168 switch ( node . kind ( ) ) {
157169 case SyntaxKind . Parameter :
158170 var parameter = < ParameterSyntax > node ;
159171 if ( parameter . modifiers . length === 0 ) {
160172 return null ;
161173 }
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 ) ) ] ) ;
163175
164176 case SyntaxKind . MemberFunctionDeclaration :
165177 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 ) ) ] ) ;
167179
168180 case SyntaxKind . GetAccessor :
169181 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 ) ) ] ) ;
171183
172184 case SyntaxKind . SetAccessor :
173185 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 ) ) ] ) ;
175187
176188 case SyntaxKind . IndexSignature :
177189 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 ) ) ] ) ;
179191
180192 case SyntaxKind . EnumElement :
181193 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 ) ) ] ) ;
183195
184196 case SyntaxKind . CallSignature :
185197 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 ) ) ] ) ;
187199
188200 case SyntaxKind . ConstructSignature :
189201 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 ) ) ] ) ;
191203
192204 case SyntaxKind . MethodSignature :
193205 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 ) ) ] ) ;
195207
196208 case SyntaxKind . PropertySignature :
197209 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 ) ) ] ) ;
199211
200212 case SyntaxKind . FunctionDeclaration :
201213 var functionDeclaration = < FunctionDeclarationSyntax > node ;
202214 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 ) ) ] ) ;
204216 }
205217 break ;
206218
207219 case SyntaxKind . MemberVariableDeclaration :
208220 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 ) ) ] ) ;
210222
211223 case SyntaxKind . VariableDeclarator :
212224 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 ) ) ] ) ;
214226
215227 case SyntaxKind . ConstructorDeclaration :
216228 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 ) ) ] ) ;
218230 }
219231
220232 return null ;
@@ -273,7 +285,7 @@ module TypeScript.Services {
273285
274286 var childItems = this . getItemsWorker ( ( ) => this . getChildNodes ( node . moduleElements ) , n => this . createChildItem ( n ) ) ;
275287
276- return new ts . NavigationBarItem ( moduleNames . join ( "." ) ,
288+ return this . getNavigationBarItem ( moduleNames . join ( "." ) ,
277289 ts . ScriptElementKind . moduleElement ,
278290 this . getKindModifiers ( node . modifiers ) ,
279291 [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ,
@@ -284,7 +296,7 @@ module TypeScript.Services {
284296 private createFunctionItem ( node : FunctionDeclarationSyntax ) {
285297 var childItems = this . getItemsWorker ( ( ) => node . block . statements , n => this . createChildItem ( n ) ) ;
286298
287- return new ts . NavigationBarItem ( node . identifier . text ( ) ,
299+ return this . getNavigationBarItem ( node . identifier . text ( ) ,
288300 ts . ScriptElementKind . functionElement ,
289301 this . getKindModifiers ( node . modifiers ) ,
290302 [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ,
@@ -300,7 +312,7 @@ module TypeScript.Services {
300312 }
301313
302314 this . hasGlobalNode = true ;
303- return new ts . NavigationBarItem ( "<global>" ,
315+ return this . getNavigationBarItem ( "<global>" ,
304316 ts . ScriptElementKind . moduleElement ,
305317 ts . ScriptElementKindModifier . none ,
306318 [ TextSpan . fromBounds ( start ( node ) , end ( node ) ) ] ,
@@ -317,7 +329,7 @@ module TypeScript.Services {
317329 : node . classElements ;
318330
319331 var childItems = this . getItemsWorker ( ( ) => nodes , n => this . createChildItem ( n ) ) ;
320- return new ts . NavigationBarItem (
332+ return this . getNavigationBarItem (
321333 node . identifier . text ( ) ,
322334 ts . ScriptElementKind . classElement ,
323335 this . getKindModifiers ( node . modifiers ) ,
@@ -328,7 +340,7 @@ module TypeScript.Services {
328340
329341 private createEnumItem ( node : TypeScript . EnumDeclarationSyntax ) : ts . NavigationBarItem {
330342 var childItems = this . getItemsWorker ( ( ) => node . enumElements , n => this . createChildItem ( n ) ) ;
331- return new ts . NavigationBarItem (
343+ return this . getNavigationBarItem (
332344 node . identifier . text ( ) ,
333345 ts . ScriptElementKind . enumElement ,
334346 this . getKindModifiers ( node . modifiers ) ,
@@ -339,7 +351,7 @@ module TypeScript.Services {
339351
340352 private createIterfaceItem ( node : TypeScript . InterfaceDeclarationSyntax ) : ts . NavigationBarItem {
341353 var childItems = this . getItemsWorker ( ( ) => node . body . typeMembers , n => this . createChildItem ( n ) ) ;
342- return new ts . NavigationBarItem (
354+ return this . getNavigationBarItem (
343355 node . identifier . text ( ) ,
344356 ts . ScriptElementKind . interfaceElement ,
345357 this . getKindModifiers ( node . modifiers ) ,
0 commit comments