@@ -15,7 +15,7 @@ import nls = require('vs/nls');
1515import arrays = require( 'vs/base/common/arrays' ) ;
1616import { IMarker } from 'vs/platform/markers/common/markers' ;
1717
18- export function evaluate ( languageService : ts . LanguageService , resource : URI , range : EditorCommon . IRange , id : any ) : Modes . IQuickFixResult {
18+ export function evaluate ( languageService : ts . LanguageService , resource : URI , range : EditorCommon . IRange , quickFix : Modes . IQuickFix ) : Modes . IQuickFixResult {
1919
2020 var filename = resource . toString ( ) ,
2121 sourceFile = languageService . getSourceFile ( filename ) ,
@@ -26,7 +26,7 @@ export function evaluate(languageService: ts.LanguageService, resource: URI, ran
2626 return null ;
2727 }
2828
29- var command = JSON . parse ( id ) ;
29+ var [ command ] = quickFix . command . arguments ;
3030 switch ( command . type ) {
3131 case 'rename' : {
3232 var start = sourceFile . getLineAndCharacterOfPosition ( token . getStart ( ) ) ;
@@ -129,9 +129,12 @@ function computeRenameProposals(languageService:ts.LanguageService, resource:URI
129129 }
130130
131131 fixes . push ( {
132- label : nls . localize ( 'typescript.quickfix.rename' , "Rename to '{0}'" , entry . name ) ,
133- id : JSON . stringify ( { type : 'rename' , name : entry . name } ) ,
134- score : score
132+ command : {
133+ id : 'ts.renameTo' ,
134+ title : nls . localize ( 'typescript.quickfix.rename' , "Rename to '{0}'" , entry . name ) ,
135+ arguments : [ { type : 'rename' , name : entry . name } ]
136+ } ,
137+ score
135138 } ) ;
136139 }
137140 } ) ;
@@ -204,19 +207,25 @@ function computeAddTypeDefinitionProposals(languageService: ts.LanguageService,
204207 if ( typingsMap . hasOwnProperty ( currentWord ) ) {
205208 var mapping = typingsMap [ currentWord ] ;
206209 var dtsRefs : string [ ] = Array . isArray ( mapping ) ? < string [ ] > mapping : [ < string > mapping ] ;
207- dtsRefs . forEach ( ( dtsRef ) => {
210+ dtsRefs . forEach ( ( dtsRef , idx ) => {
208211 result . push ( {
209- label : nls . localize ( 'typescript.quickfix.typeDefinitions' , "Download type definition {0}" , dtsRef . split ( '/' ) [ 1 ] ) ,
210- id : JSON . stringify ( { type : 'typedefinitions' , name : dtsRef } ) ,
211- score : 1
212+ command : {
213+ id : 'ts.downloadDts' ,
214+ title : nls . localize ( 'typescript.quickfix.typeDefinitions' , "Download type definition {0}" , dtsRef . split ( '/' ) [ 1 ] ) ,
215+ arguments : [ { type : 'typedefinitions' , name : dtsRef } ]
216+ } ,
217+ score : idx
212218 } ) ;
213219 } ) ;
214220 }
215221
216222 if ( strings . endsWith ( resource . path , '.js' ) ) {
217223 result . push ( {
218- label : nls . localize ( 'typescript.quickfix.addAsGlobal' , "Mark '{0}' as global" , currentWord ) ,
219- id : JSON . stringify ( { type : 'addglobal' , name : currentWord } ) ,
224+ command : {
225+ id : 'ts.addAsGlobal' ,
226+ title : nls . localize ( 'typescript.quickfix.addAsGlobal' , "Mark '{0}' as global" , currentWord ) ,
227+ arguments : [ { type : 'addglobal' , name : currentWord } ]
228+ } ,
220229 score : 1
221230 } ) ;
222231 }
0 commit comments