1
1
import { Observable } from '@reactivex/rxjs' ;
2
- import jsonpatch from 'fast-json-patch' ;
2
+ import { Operation } from 'fast-json-patch' ;
3
3
import iterate from 'iterare' ;
4
4
import { toPairs } from 'lodash' ;
5
5
import { Span } from 'opentracing' ;
@@ -118,7 +118,7 @@ export class TypeScriptService {
118
118
/**
119
119
* Cached response for empty workspace/symbol query
120
120
*/
121
- private emptyQueryWorkspaceSymbols : Observable < jsonpatch . Operation > ;
121
+ private emptyQueryWorkspaceSymbols : Observable < Operation > ;
122
122
123
123
private traceModuleResolution : boolean ;
124
124
@@ -196,7 +196,7 @@ export class TypeScriptService {
196
196
*
197
197
* @return Observable of JSON Patches that build an `InitializeResult`
198
198
*/
199
- initialize ( params : InitializeParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
199
+ initialize ( params : InitializeParams , span = new Span ( ) ) : Observable < Operation > {
200
200
if ( params . rootUri || params . rootPath ) {
201
201
this . root = params . rootPath || uri2path ( params . rootUri ! ) ;
202
202
this . rootUri = params . rootUri || path2uri ( params . rootPath ! ) ;
@@ -268,7 +268,7 @@ export class TypeScriptService {
268
268
op : 'add' ,
269
269
path : '' ,
270
270
value : result
271
- } as jsonpatch . Operation ) ;
271
+ } as Operation ) ;
272
272
}
273
273
274
274
/**
@@ -289,10 +289,10 @@ export class TypeScriptService {
289
289
*
290
290
* @return Observable of JSON Patches that build a `null` result
291
291
*/
292
- shutdown ( params = { } , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
292
+ shutdown ( params = { } , span = new Span ( ) ) : Observable < Operation > {
293
293
this . projectManager . dispose ( ) ;
294
294
this . packageManager . dispose ( ) ;
295
- return Observable . of ( { op : 'add' , path : '' , value : null } as jsonpatch . Operation ) ;
295
+ return Observable . of ( { op : 'add' , path : '' , value : null } as Operation ) ;
296
296
}
297
297
298
298
/**
@@ -310,9 +310,9 @@ export class TypeScriptService {
310
310
* @return Observable of JSON Patches that build a `Location[]` result
311
311
*/
312
312
313
- textDocumentDefinition ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
313
+ textDocumentDefinition ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < Operation > {
314
314
return this . _getDefinitionLocations ( params , span )
315
- . map ( ( location : Location ) : jsonpatch . Operation => ( { op : 'add' , path : '/-' , value : location } ) )
315
+ . map ( ( location : Location ) : Operation => ( { op : 'add' , path : '/-' , value : location } ) )
316
316
. startWith ( { op : 'add' , path : '' , value : [ ] } ) ;
317
317
}
318
318
@@ -370,9 +370,9 @@ export class TypeScriptService {
370
370
* @return Observable of JSON Patches that build a `SymbolLocationInformation[]` result
371
371
*/
372
372
373
- textDocumentXdefinition ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
373
+ textDocumentXdefinition ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < Operation > {
374
374
return this . _getSymbolLocationInformations ( params , span )
375
- . map ( symbol => ( { op : 'add' , path : '/-' , value : symbol } as jsonpatch . Operation ) )
375
+ . map ( symbol => ( { op : 'add' , path : '/-' , value : symbol } as Operation ) )
376
376
. startWith ( { op : 'add' , path : '' , value : [ ] } ) ;
377
377
}
378
378
@@ -494,9 +494,9 @@ export class TypeScriptService {
494
494
*
495
495
* @return Observable of JSON Patches that build a `Hover` result
496
496
*/
497
- textDocumentHover ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
497
+ textDocumentHover ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < Operation > {
498
498
return this . _getHover ( params , span )
499
- . map ( hover => ( { op : 'add' , path : '' , value : hover } ) as jsonpatch . Operation ) ;
499
+ . map ( hover => ( { op : 'add' , path : '' , value : hover } ) as Operation ) ;
500
500
}
501
501
502
502
/**
@@ -572,7 +572,7 @@ export class TypeScriptService {
572
572
*
573
573
* @return Observable of JSON Patches that build a `Location[]` result
574
574
*/
575
- textDocumentReferences ( params : ReferenceParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
575
+ textDocumentReferences ( params : ReferenceParams , span = new Span ( ) ) : Observable < Operation > {
576
576
const uri = normalizeUri ( params . textDocument . uri ) ;
577
577
578
578
// Ensure all files were fetched to collect all references
@@ -621,7 +621,7 @@ export class TypeScriptService {
621
621
} ;
622
622
} ) ;
623
623
} ) )
624
- . map ( ( location : Location ) : jsonpatch . Operation => ( { op : 'add' , path : '/-' , value : location } ) )
624
+ . map ( ( location : Location ) : Operation => ( { op : 'add' , path : '/-' , value : location } ) )
625
625
// Initialize with array
626
626
. startWith ( { op : 'add' , path : '' , value : [ ] } ) ;
627
627
}
@@ -633,7 +633,7 @@ export class TypeScriptService {
633
633
*
634
634
* @return Observable of JSON Patches that build a `SymbolInformation[]` result
635
635
*/
636
- workspaceSymbol ( params : WorkspaceSymbolParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
636
+ workspaceSymbol ( params : WorkspaceSymbolParams , span = new Span ( ) ) : Observable < Operation > {
637
637
638
638
// Return cached result for empty query, if available
639
639
if ( ! params . query && ! params . symbol && this . emptyQueryWorkspaceSymbols ) {
@@ -705,10 +705,10 @@ export class TypeScriptService {
705
705
const index = scores . findIndex ( s => s < score ) ;
706
706
if ( index === - 1 ) {
707
707
scores . push ( score ) ;
708
- return { op : 'add' , path : '/-' , value : symbol } as jsonpatch . Operation ;
708
+ return { op : 'add' , path : '/-' , value : symbol } as Operation ;
709
709
}
710
710
scores . splice ( index , 0 , score ) ;
711
- return { op : 'add' , path : '/' + index , value : symbol } as jsonpatch . Operation ;
711
+ return { op : 'add' , path : '/' + index , value : symbol } as Operation ;
712
712
} )
713
713
. startWith ( { op : 'add' , path : '' , value : [ ] } ) ;
714
714
@@ -725,7 +725,7 @@ export class TypeScriptService {
725
725
*
726
726
* @return Observable of JSON Patches that build a `SymbolInformation[]` result
727
727
*/
728
- textDocumentDocumentSymbol ( params : DocumentSymbolParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
728
+ textDocumentDocumentSymbol ( params : DocumentSymbolParams , span = new Span ( ) ) : Observable < Operation > {
729
729
const uri = normalizeUri ( params . textDocument . uri ) ;
730
730
731
731
// Ensure files needed to resolve symbols are fetched
@@ -745,8 +745,8 @@ export class TypeScriptService {
745
745
. filter ( ( { tree, parent } ) => navigationTreeIsSymbol ( tree ) )
746
746
. map ( ( { tree, parent } ) => navigationTreeToSymbolInformation ( tree , parent , sourceFile , this . root ) ) ;
747
747
} )
748
- . map ( symbol => ( { op : 'add' , path : '/-' , value : symbol } ) as jsonpatch . Operation )
749
- . startWith ( { op : 'add' , path : '' , value : [ ] } as jsonpatch . Operation ) ;
748
+ . map ( symbol => ( { op : 'add' , path : '/-' , value : symbol } ) as Operation )
749
+ . startWith ( { op : 'add' , path : '' , value : [ ] } as Operation ) ;
750
750
}
751
751
752
752
/**
@@ -755,7 +755,7 @@ export class TypeScriptService {
755
755
*
756
756
* @return Observable of JSON Patches that build a `ReferenceInformation[]` result
757
757
*/
758
- workspaceXreferences ( params : WorkspaceReferenceParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
758
+ workspaceXreferences ( params : WorkspaceReferenceParams , span = new Span ( ) ) : Observable < Operation > {
759
759
const queryWithoutPackage = omit ( params . query , 'package' ) ;
760
760
const minScore = Math . min ( 4.75 , getPropertyCount ( queryWithoutPackage ) ) ;
761
761
return this . isDefinitelyTyped
@@ -844,7 +844,7 @@ export class TypeScriptService {
844
844
} )
845
845
) ;
846
846
} )
847
- . map ( ( reference ) : jsonpatch . Operation => ( { op : 'add' , path : '/-' , value : reference } ) )
847
+ . map ( ( reference ) : Operation => ( { op : 'add' , path : '/-' , value : reference } ) )
848
848
. startWith ( { op : 'add' , path : '' , value : [ ] } ) ;
849
849
}
850
850
@@ -861,7 +861,7 @@ export class TypeScriptService {
861
861
*
862
862
* @return Observable of JSON Patches that build a `PackageInformation[]` result
863
863
*/
864
- workspaceXpackages ( params = { } , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
864
+ workspaceXpackages ( params = { } , span = new Span ( ) ) : Observable < Operation > {
865
865
return this . isDefinitelyTyped
866
866
. mergeMap ( ( isDefinitelyTyped : boolean ) : Observable < PackageInformation > => {
867
867
// In DefinitelyTyped, report all @types/ packages
@@ -920,7 +920,7 @@ export class TypeScriptService {
920
920
} ) ) ;
921
921
} ) ;
922
922
} )
923
- . map ( ( packageInfo ) : jsonpatch . Operation => ( { op : 'add' , path : '/-' , value : packageInfo } ) )
923
+ . map ( ( packageInfo ) : Operation => ( { op : 'add' , path : '/-' , value : packageInfo } ) )
924
924
. startWith ( { op : 'add' , path : '' , value : [ ] } ) ;
925
925
}
926
926
@@ -930,7 +930,7 @@ export class TypeScriptService {
930
930
*
931
931
* @return Observable of JSON Patches that build a `DependencyReference[]` result
932
932
*/
933
- workspaceXdependencies ( params = { } , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
933
+ workspaceXdependencies ( params = { } , span = new Span ( ) ) : Observable < Operation > {
934
934
// Ensure package.json files
935
935
return this . projectManager . ensureModuleStructure ( )
936
936
// Iterate all files
@@ -955,7 +955,7 @@ export class TypeScriptService {
955
955
}
956
956
} ) )
957
957
)
958
- . map ( ( dependency ) : jsonpatch . Operation => ( { op : 'add' , path : '/-' , value : dependency } ) )
958
+ . map ( ( dependency ) : Operation => ( { op : 'add' , path : '/-' , value : dependency } ) )
959
959
. startWith ( { op : 'add' , path : '' , value : [ ] } ) ;
960
960
}
961
961
@@ -974,7 +974,7 @@ export class TypeScriptService {
974
974
*
975
975
* @return Observable of JSON Patches that build a `CompletionList` result
976
976
*/
977
- textDocumentCompletion ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
977
+ textDocumentCompletion ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < Operation > {
978
978
const uri = normalizeUri ( params . textDocument . uri ) ;
979
979
980
980
// Ensure files needed to suggest completions are fetched
@@ -1014,11 +1014,11 @@ export class TypeScriptService {
1014
1014
item . documentation = ts . displayPartsToString ( details . documentation ) ;
1015
1015
item . detail = ts . displayPartsToString ( details . displayParts ) ;
1016
1016
}
1017
- return { op : 'add' , path : '/items/-' , value : item } as jsonpatch . Operation ;
1017
+ return { op : 'add' , path : '/items/-' , value : item } as Operation ;
1018
1018
} )
1019
- . startWith ( { op : 'add' , path : '/isIncomplete' , value : false } as jsonpatch . Operation ) ;
1019
+ . startWith ( { op : 'add' , path : '/isIncomplete' , value : false } as Operation ) ;
1020
1020
} )
1021
- . startWith ( { op : 'add' , path : '' , value : { isIncomplete : true , items : [ ] } as CompletionList } as jsonpatch . Operation ) ;
1021
+ . startWith ( { op : 'add' , path : '' , value : { isIncomplete : true , items : [ ] } as CompletionList } as Operation ) ;
1022
1022
}
1023
1023
1024
1024
/**
@@ -1027,7 +1027,7 @@ export class TypeScriptService {
1027
1027
*
1028
1028
* @return Observable of JSON Patches that build a `SignatureHelp` result
1029
1029
*/
1030
- textDocumentSignatureHelp ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
1030
+ textDocumentSignatureHelp ( params : TextDocumentPositionParams , span = new Span ( ) ) : Observable < Operation > {
1031
1031
const uri = normalizeUri ( params . textDocument . uri ) ;
1032
1032
1033
1033
// Ensure files needed to resolve signature are fetched
@@ -1071,7 +1071,7 @@ export class TypeScriptService {
1071
1071
activeParameter : signatures . argumentIndex
1072
1072
} ;
1073
1073
} )
1074
- . map ( signatureHelp => ( { op : 'add' , path : '' , value : signatureHelp } ) as jsonpatch . Operation ) ;
1074
+ . map ( signatureHelp => ( { op : 'add' , path : '' , value : signatureHelp } ) as Operation ) ;
1075
1075
}
1076
1076
1077
1077
/**
@@ -1081,7 +1081,7 @@ export class TypeScriptService {
1081
1081
*
1082
1082
* @return Observable of JSON Patches that build a `Command[]` result
1083
1083
*/
1084
- textDocumentCodeAction ( params : CodeActionParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
1084
+ textDocumentCodeAction ( params : CodeActionParams , span = new Span ( ) ) : Observable < Operation > {
1085
1085
const uri = normalizeUri ( params . textDocument . uri ) ;
1086
1086
return this . projectManager . ensureReferencedFiles ( uri , undefined , undefined , span )
1087
1087
. toArray ( )
@@ -1108,7 +1108,7 @@ export class TypeScriptService {
1108
1108
1109
1109
return configuration . getService ( ) . getCodeFixesAtPosition ( filePath , start , end , errorCodes , this . settings . format || { } ) || [ ] ;
1110
1110
} )
1111
- . map ( ( action : ts . CodeAction ) : jsonpatch . Operation => ( {
1111
+ . map ( ( action : ts . CodeAction ) : Operation => ( {
1112
1112
op : 'add' ,
1113
1113
path : '/-' ,
1114
1114
value : {
@@ -1117,7 +1117,7 @@ export class TypeScriptService {
1117
1117
arguments : action . changes
1118
1118
} as Command
1119
1119
} ) )
1120
- . startWith ( { op : 'add' , path : '' , value : [ ] } as jsonpatch . Operation ) ;
1120
+ . startWith ( { op : 'add' , path : '' , value : [ ] } as Operation ) ;
1121
1121
}
1122
1122
1123
1123
/**
@@ -1126,7 +1126,7 @@ export class TypeScriptService {
1126
1126
* applies the changes to the workspace using the request workspace/applyEdit which is sent from
1127
1127
* the server to the client.
1128
1128
*/
1129
- workspaceExecuteCommand ( params : ExecuteCommandParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
1129
+ workspaceExecuteCommand ( params : ExecuteCommandParams , span = new Span ( ) ) : Observable < Operation > {
1130
1130
switch ( params . command ) {
1131
1131
case 'codeFix' :
1132
1132
if ( ! params . arguments || params . arguments . length < 1 ) {
@@ -1143,7 +1143,7 @@ export class TypeScriptService {
1143
1143
*
1144
1144
* @return Observable of JSON Patches for `null` result
1145
1145
*/
1146
- executeCodeFixCommand ( fileTextChanges : ts . FileTextChanges [ ] , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
1146
+ executeCodeFixCommand ( fileTextChanges : ts . FileTextChanges [ ] , span = new Span ( ) ) : Observable < Operation > {
1147
1147
if ( fileTextChanges . length === 0 ) {
1148
1148
return Observable . throw ( new Error ( 'No changes supplied for code fix command' ) ) ;
1149
1149
}
@@ -1171,15 +1171,15 @@ export class TypeScriptService {
1171
1171
1172
1172
return this . client . workspaceApplyEdit ( { edit : { changes } } , span ) ;
1173
1173
} ) )
1174
- . map ( ( ) => ( { op : 'add' , path : '' , value : null } ) as jsonpatch . Operation ) ;
1174
+ . map ( ( ) => ( { op : 'add' , path : '' , value : null } ) as Operation ) ;
1175
1175
}
1176
1176
1177
1177
/**
1178
1178
* The rename request is sent from the client to the server to perform a workspace-wide rename of a symbol.
1179
1179
*
1180
1180
* @return Observable of JSON Patches that build a `WorkspaceEdit` result
1181
1181
*/
1182
- textDocumentRename ( params : RenameParams , span = new Span ( ) ) : Observable < jsonpatch . Operation > {
1182
+ textDocumentRename ( params : RenameParams , span = new Span ( ) ) : Observable < Operation > {
1183
1183
const uri = normalizeUri ( params . textDocument . uri ) ;
1184
1184
const editUris = new Set < string > ( ) ;
1185
1185
return this . projectManager . ensureOwnFiles ( span )
@@ -1217,7 +1217,7 @@ export class TypeScriptService {
1217
1217
return [ editUri , edit ] ;
1218
1218
} ) ;
1219
1219
} ) )
1220
- . map ( ( [ uri , edit ] ) : jsonpatch . Operation => {
1220
+ . map ( ( [ uri , edit ] ) : Operation => {
1221
1221
// if file has no edit yet, initialize array
1222
1222
if ( ! editUris . has ( uri ) ) {
1223
1223
editUris . add ( uri ) ;
@@ -1226,7 +1226,7 @@ export class TypeScriptService {
1226
1226
// else append to array
1227
1227
return { op : 'add' , path : JSONPTR `/changes/${ uri } /-` , value : edit } ;
1228
1228
} )
1229
- . startWith ( { op : 'add' , path : '' , value : { changes : { } } as WorkspaceEdit } as jsonpatch . Operation ) ;
1229
+ . startWith ( { op : 'add' , path : '' , value : { changes : { } } as WorkspaceEdit } as Operation ) ;
1230
1230
}
1231
1231
1232
1232
/**
0 commit comments