@@ -36,11 +36,11 @@ module ts {
36
36
export function collectElements ( sourceFile : SourceFile ) : OutliningSpan [ ] {
37
37
var elements : OutliningSpan [ ] = [ ] ;
38
38
39
- function addOutlineRange ( node : Node , startElement : Node , endElement : Node ) {
40
- if ( node && startElement && endElement ) {
39
+ function addOutlineRange ( hintSpanNode : Node , startElement : Node , endElement : Node ) {
40
+ if ( hintSpanNode && startElement && endElement ) {
41
41
var span : OutliningSpan = {
42
42
textSpan : TypeScript . TextSpan . fromBounds ( startElement . pos , endElement . end ) ,
43
- hintSpan : TypeScript . TextSpan . fromBounds ( node . getStart ( ) , node . end ) ,
43
+ hintSpan : TypeScript . TextSpan . fromBounds ( hintSpanNode . getStart ( ) , hintSpanNode . end ) ,
44
44
bannerText : "..." ,
45
45
autoCollapse : false
46
46
} ;
@@ -49,33 +49,31 @@ module ts {
49
49
}
50
50
51
51
var depth = 0 ;
52
- var maxDepth = 10 ;
52
+ var maxDepth = 20 ;
53
53
function walk ( n : Node ) : void {
54
- if ( depth >= maxDepth ) {
54
+ if ( depth > maxDepth ) {
55
55
return ;
56
56
}
57
57
switch ( n . kind ) {
58
+ case SyntaxKind . Block :
59
+ case SyntaxKind . FunctionBlock :
60
+ case SyntaxKind . ModuleBlock :
61
+ case SyntaxKind . TryBlock :
62
+ case SyntaxKind . TryBlock :
63
+ case SyntaxKind . CatchBlock :
64
+ case SyntaxKind . FinallyBlock :
65
+ var openBrace = forEach ( n . getChildren ( ) , c => c . kind === SyntaxKind . OpenBraceToken && c ) ;
66
+ var closeBrace = forEach ( n . getChildren ( ) , c => c . kind === SyntaxKind . CloseBraceToken && c ) ;
67
+ addOutlineRange ( n . parent , openBrace , closeBrace ) ;
68
+ break ;
58
69
case SyntaxKind . ClassDeclaration :
59
70
case SyntaxKind . InterfaceDeclaration :
60
- case SyntaxKind . ModuleDeclaration :
61
71
case SyntaxKind . EnumDeclaration :
62
72
case SyntaxKind . ObjectLiteral :
63
73
var openBrace = forEach ( n . getChildren ( ) , c => c . kind === SyntaxKind . OpenBraceToken && c ) ;
64
74
var closeBrace = forEach ( n . getChildren ( ) , c => c . kind === SyntaxKind . CloseBraceToken && c ) ;
65
75
addOutlineRange ( n , openBrace , closeBrace ) ;
66
76
break ;
67
- case SyntaxKind . Constructor :
68
- case SyntaxKind . FunctionDeclaration :
69
- case SyntaxKind . Method :
70
- case SyntaxKind . GetAccessor :
71
- case SyntaxKind . SetAccessor :
72
- var body = ( < FunctionDeclaration > n ) . body ;
73
- if ( body ) {
74
- var openBrace = forEach ( body . getChildren ( ) , c => c . kind === SyntaxKind . OpenBraceToken && c ) ;
75
- var closeBrace = forEach ( body . getChildren ( ) , c => c . kind === SyntaxKind . CloseBraceToken && c ) ;
76
- addOutlineRange ( n , openBrace , closeBrace ) ;
77
- }
78
- break ;
79
77
}
80
78
depth ++ ;
81
79
forEachChild ( n , walk ) ;
0 commit comments