88
99import 'vs/css!./quickOutline' ;
1010import * as nls from 'vs/nls' ;
11- import * as arrays from 'vs/base/common/arrays' ;
1211import { onUnexpectedError } from 'vs/base/common/errors' ;
1312import { matchesFuzzy } from 'vs/base/common/filters' ;
1413import * as strings from 'vs/base/common/strings' ;
@@ -17,9 +16,9 @@ import {IContext, IHighlight, QuickOpenEntryGroup, QuickOpenModel} from 'vs/base
1716import { IAutoFocus , Mode } from 'vs/base/parts/quickopen/common/quickOpen' ;
1817import { Behaviour } from 'vs/editor/common/editorActionEnablement' ;
1918import { ICommonCodeEditor , IEditorActionDescriptorData , IRange } from 'vs/editor/common/editorCommon' ;
20- import { IOutlineEntry , OutlineRegistry } from 'vs/editor/common/modes' ;
19+ import { SymbolInformation , SymbolKind , DocumentSymbolProviderRegistry } from 'vs/editor/common/modes' ;
2120import { BaseEditorQuickOpenAction , IDecorator } from './editorQuickOpen' ;
22- import { getOutlineEntries , IOutline } from 'vs/editor/contrib/quickOpen/common/quickOpen' ;
21+ import { getDocumentSymbols , IOutline } from 'vs/editor/contrib/quickOpen/common/quickOpen' ;
2322
2423let SCOPE_PREFIX = ':' ;
2524
@@ -108,19 +107,11 @@ class SymbolEntry extends QuickOpenEntryGroup {
108107 }
109108}
110109
111- interface OutlineNode {
112- label : string ;
113- type : string ;
114- range : IRange ;
115- children ?: OutlineNode [ ] ;
116- parentScope ?: string [ ] ;
117- }
118-
119110export class QuickOutlineAction extends BaseEditorQuickOpenAction {
120111
121112 public static ID = 'editor.action.quickOutline' ;
122113
123- private cachedResult : IOutlineEntry [ ] ;
114+ private cachedResult : SymbolInformation [ ] ;
124115
125116 constructor ( descriptor : IEditorActionDescriptorData , editor : ICommonCodeEditor ) {
126117 super ( descriptor , editor , nls . localize ( 'QuickOutlineAction.label' , "Go to Symbol..." ) , Behaviour . WidgetFocus | Behaviour . ShowInContextMenu ) ;
@@ -131,18 +122,18 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
131122 }
132123
133124 public isSupported ( ) : boolean {
134- return ( OutlineRegistry . has ( this . editor . getModel ( ) ) && super . isSupported ( ) ) ;
125+ return ( DocumentSymbolProviderRegistry . has ( this . editor . getModel ( ) ) && super . isSupported ( ) ) ;
135126 }
136127
137128 public run ( ) : TPromise < boolean > {
138129 let model = this . editor . getModel ( ) ;
139130
140- if ( ! OutlineRegistry . has ( model ) ) {
131+ if ( ! DocumentSymbolProviderRegistry . has ( model ) ) {
141132 return null ;
142133 }
143134
144135 // Resolve outline
145- let promise = getOutlineEntries ( model ) ;
136+ let promise = getDocumentSymbols ( model ) ;
146137 return promise . then ( ( result : IOutline ) => {
147138 if ( result . entries . length > 0 ) {
148139
@@ -180,15 +171,9 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
180171 return nls . localize ( 'quickOutlineActionInput' , "Type the name of an identifier you wish to navigate to" ) ;
181172 }
182173
183- private toQuickOpenEntries ( outline : OutlineNode [ ] , searchValue : string ) : SymbolEntry [ ] {
174+ private toQuickOpenEntries ( flattened : SymbolInformation [ ] , searchValue : string ) : SymbolEntry [ ] {
184175 let results : SymbolEntry [ ] = [ ] ;
185176
186- // Flatten
187- let flattened : OutlineNode [ ] = [ ] ;
188- if ( outline ) {
189- this . flatten ( outline , flattened ) ;
190- }
191-
192177 // Convert to Entries
193178 let normalizedSearchValue = searchValue ;
194179 if ( searchValue . indexOf ( SCOPE_PREFIX ) === 0 ) {
@@ -197,20 +182,20 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
197182
198183 for ( let i = 0 ; i < flattened . length ; i ++ ) {
199184 let element = flattened [ i ] ;
200- let label = strings . trim ( element . label ) ;
185+ let label = strings . trim ( element . name ) ;
201186
202187 // Check for meatch
203188 let highlights = matchesFuzzy ( normalizedSearchValue , label ) ;
204189 if ( highlights ) {
205190
206191 // Show parent scope as description
207192 let description : string = null ;
208- if ( element . parentScope ) {
209- description = arrays . tail ( element . parentScope ) ;
193+ if ( element . containerName ) {
194+ description = element . containerName ;
210195 }
211196
212197 // Add
213- results . push ( new SymbolEntry ( label , element . type , description , element . range , highlights , this . editor , this ) ) ;
198+ results . push ( new SymbolEntry ( label , SymbolKind . from ( element . kind ) , description , element . location . range , highlights , this . editor , this ) ) ;
214199 }
215200 }
216201
@@ -284,27 +269,6 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
284269 return type ;
285270 }
286271
287- private flatten ( outline : OutlineNode [ ] , flattened : OutlineNode [ ] , parentScope ?: string [ ] ) : void {
288- for ( let i = 0 ; i < outline . length ; i ++ ) {
289- let element = outline [ i ] ;
290- flattened . push ( element ) ;
291-
292- if ( parentScope ) {
293- element . parentScope = parentScope ;
294- }
295-
296- if ( element . children ) {
297- let elementScope : string [ ] = [ ] ;
298- if ( parentScope ) {
299- elementScope = parentScope . slice ( 0 ) ;
300- }
301- elementScope . push ( element . label ) ;
302-
303- this . flatten ( element . children , flattened , elementScope ) ;
304- }
305- }
306- }
307-
308272 private sortNormal ( searchValue : string , elementA : SymbolEntry , elementB : SymbolEntry ) : number {
309273 let elementAName = elementA . getLabel ( ) . toLowerCase ( ) ;
310274 let elementBName = elementB . getLabel ( ) . toLowerCase ( ) ;
0 commit comments