@@ -33,8 +33,16 @@ namespace ts.OutliningElementsCollector {
33
33
// Add outlining spans for comments if they exist
34
34
addOutliningForLeadingCommentsForNode ( node , sourceFile , cancellationToken , out ) ;
35
35
// Add outlining spans for the import statement itself if applicable
36
- const span = getOutliningSpanForNode ( node , sourceFile ) ;
37
- if ( span ) out . push ( span ) ;
36
+ if ( isImportDeclaration ( node ) && node . importClause && node . importClause . namedBindings &&
37
+ node . importClause . namedBindings . kind !== SyntaxKind . NamespaceImport && node . importClause . namedBindings . elements . length ) {
38
+ const openToken = findChildOfKind ( node . importClause . namedBindings , SyntaxKind . OpenBraceToken , sourceFile ) ;
39
+ const closeToken = findChildOfKind ( node . importClause . namedBindings , SyntaxKind . CloseBraceToken , sourceFile ) ;
40
+ if ( openToken && closeToken ) {
41
+ out . push ( createOutliningSpan (
42
+ createTextSpanFromBounds ( openToken . getStart ( sourceFile ) , closeToken . getEnd ( ) ) ,
43
+ OutliningSpanKind . Import , createTextSpanFromNode ( node , sourceFile ) ) ) ;
44
+ }
45
+ }
38
46
}
39
47
40
48
function visitNonImportNode ( n : Node ) {
@@ -177,10 +185,7 @@ namespace ts.OutliningElementsCollector {
177
185
return spanForObjectOrArrayLiteral ( n ) ;
178
186
case SyntaxKind . ArrayLiteralExpression :
179
187
return spanForObjectOrArrayLiteral ( n , SyntaxKind . OpenBracketToken ) ;
180
- case SyntaxKind . ImportDeclaration :
181
- const importClause = ( n as ImportDeclaration ) . importClause ;
182
- return importClause && importClause . namedBindings && importClause . namedBindings . kind !== SyntaxKind . NamespaceImport ? spanForNode ( importClause . namedBindings ) : undefined ;
183
- }
188
+ }
184
189
185
190
function spanForObjectOrArrayLiteral ( node : Node , open : SyntaxKind . OpenBraceToken | SyntaxKind . OpenBracketToken = SyntaxKind . OpenBraceToken ) : OutliningSpan | undefined {
186
191
// If the block has no leading keywords and is inside an array literal,
0 commit comments