@@ -2201,68 +2201,36 @@ namespace ts.server {
2201
2201
} ) ;
2202
2202
}
2203
2203
2204
- private toggleLineComment ( args : protocol . FileRangeRequestArgs , simplifiedResult : boolean ) : TextChange [ ] | protocol . CodeEdit [ ] {
2204
+ private toggleLineComment ( args : protocol . FileRangeRequestArgs ) : TextChange [ ] {
2205
2205
const { file, project } = this . getFileAndProject ( args ) ;
2206
2206
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
2207
2207
const textRange = this . getRange ( args , scriptInfo ) ;
2208
2208
2209
- const textChanges = project . getLanguageService ( ) . toggleLineComment ( file , textRange ) ;
2210
-
2211
- if ( simplifiedResult ) {
2212
- const scriptInfo = this . projectService . getScriptInfoForNormalizedPath ( file ) ! ;
2213
-
2214
- return textChanges . map ( textChange => this . convertTextChangeToCodeEdit ( textChange , scriptInfo ) ) ;
2215
- }
2216
-
2217
- return textChanges ;
2209
+ return project . getLanguageService ( ) . toggleLineComment ( file , textRange ) ;
2218
2210
}
2219
2211
2220
- private toggleMultilineComment ( args : protocol . FileRangeRequestArgs , simplifiedResult : boolean ) : TextChange [ ] | protocol . CodeEdit [ ] {
2212
+ private toggleMultilineComment ( args : protocol . FileRangeRequestArgs ) : TextChange [ ] {
2221
2213
const { file, project } = this . getFileAndProject ( args ) ;
2222
2214
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
2223
2215
const textRange = this . getRange ( args , scriptInfo ) ;
2224
2216
2225
- const textChanges = project . getLanguageService ( ) . toggleMultilineComment ( file , textRange ) ;
2226
-
2227
- if ( simplifiedResult ) {
2228
- const scriptInfo = this . projectService . getScriptInfoForNormalizedPath ( file ) ! ;
2229
-
2230
- return textChanges . map ( textChange => this . convertTextChangeToCodeEdit ( textChange , scriptInfo ) ) ;
2231
- }
2232
-
2233
- return textChanges ;
2217
+ return project . getLanguageService ( ) . toggleMultilineComment ( file , textRange ) ;
2234
2218
}
2235
2219
2236
- private commentSelection ( args : protocol . FileRangeRequestArgs , simplifiedResult : boolean ) : TextChange [ ] | protocol . CodeEdit [ ] {
2220
+ private commentSelection ( args : protocol . FileRangeRequestArgs ) : TextChange [ ] {
2237
2221
const { file, project } = this . getFileAndProject ( args ) ;
2238
2222
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
2239
2223
const textRange = this . getRange ( args , scriptInfo ) ;
2240
2224
2241
- const textChanges = project . getLanguageService ( ) . commentSelection ( file , textRange ) ;
2242
-
2243
- if ( simplifiedResult ) {
2244
- const scriptInfo = this . projectService . getScriptInfoForNormalizedPath ( file ) ! ;
2245
-
2246
- return textChanges . map ( textChange => this . convertTextChangeToCodeEdit ( textChange , scriptInfo ) ) ;
2247
- }
2248
-
2249
- return textChanges ;
2225
+ return project . getLanguageService ( ) . commentSelection ( file , textRange ) ;
2250
2226
}
2251
2227
2252
- private uncommentSelection ( args : protocol . FileRangeRequestArgs , simplifiedResult : boolean ) : TextChange [ ] | protocol . CodeEdit [ ] {
2228
+ private uncommentSelection ( args : protocol . FileRangeRequestArgs ) : TextChange [ ] {
2253
2229
const { file, project } = this . getFileAndProject ( args ) ;
2254
2230
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
2255
2231
const textRange = this . getRange ( args , scriptInfo ) ;
2256
2232
2257
- const textChanges = project . getLanguageService ( ) . uncommentSelection ( file , textRange ) ;
2258
-
2259
- if ( simplifiedResult ) {
2260
- const scriptInfo = this . projectService . getScriptInfoForNormalizedPath ( file ) ! ;
2261
-
2262
- return textChanges . map ( textChange => this . convertTextChangeToCodeEdit ( textChange , scriptInfo ) ) ;
2263
- }
2264
-
2265
- return textChanges ;
2233
+ return project . getLanguageService ( ) . uncommentSelection ( file , textRange ) ;
2266
2234
}
2267
2235
2268
2236
private mapSelectionRange ( selectionRange : SelectionRange , scriptInfo : ScriptInfo ) : protocol . SelectionRange {
@@ -2710,29 +2678,17 @@ namespace ts.server {
2710
2678
[ CommandNames . ProvideCallHierarchyOutgoingCalls ] : ( request : protocol . ProvideCallHierarchyOutgoingCallsRequest ) => {
2711
2679
return this . requiredResponse ( this . provideCallHierarchyOutgoingCalls ( request . arguments ) ) ;
2712
2680
} ,
2713
- [ CommandNames . ToggleLineComment ] : ( request : protocol . ToggleLineCommentRequest ) => {
2714
- return this . requiredResponse ( this . toggleLineComment ( request . arguments , /*simplifiedResult*/ true ) ) ;
2715
- } ,
2716
- [ CommandNames . ToggleLineCommentFull ] : ( request : protocol . ToggleLineCommentRequest ) => {
2717
- return this . requiredResponse ( this . toggleLineComment ( request . arguments , /*simplifiedResult*/ false ) ) ;
2681
+ [ CommandNames . ToggleLineCommentFull ] : ( request : protocol . CommentSelectionRequest ) => {
2682
+ return this . requiredResponse ( this . toggleLineComment ( request . arguments ) ) ;
2718
2683
} ,
2719
- [ CommandNames . ToggleMultilineComment ] : ( request : protocol . ToggleMultilineCommentRequest ) => {
2720
- return this . requiredResponse ( this . toggleMultilineComment ( request . arguments , /*simplifiedResult*/ true ) ) ;
2721
- } ,
2722
- [ CommandNames . ToggleMultilineCommentFull ] : ( request : protocol . ToggleMultilineCommentRequest ) => {
2723
- return this . requiredResponse ( this . toggleMultilineComment ( request . arguments , /*simplifiedResult*/ false ) ) ;
2724
- } ,
2725
- [ CommandNames . CommentSelection ] : ( request : protocol . CommentSelectionRequest ) => {
2726
- return this . requiredResponse ( this . commentSelection ( request . arguments , /*simplifiedResult*/ true ) ) ;
2684
+ [ CommandNames . ToggleMultilineCommentFull ] : ( request : protocol . CommentSelectionRequest ) => {
2685
+ return this . requiredResponse ( this . toggleMultilineComment ( request . arguments ) ) ;
2727
2686
} ,
2728
2687
[ CommandNames . CommentSelectionFull ] : ( request : protocol . CommentSelectionRequest ) => {
2729
- return this . requiredResponse ( this . commentSelection ( request . arguments , /*simplifiedResult*/ false ) ) ;
2730
- } ,
2731
- [ CommandNames . UncommentSelection ] : ( request : protocol . UncommentSelectionRequest ) => {
2732
- return this . requiredResponse ( this . uncommentSelection ( request . arguments , /*simplifiedResult*/ true ) ) ;
2688
+ return this . requiredResponse ( this . commentSelection ( request . arguments ) ) ;
2733
2689
} ,
2734
- [ CommandNames . UncommentSelectionFull ] : ( request : protocol . UncommentSelectionRequest ) => {
2735
- return this . requiredResponse ( this . uncommentSelection ( request . arguments , /*simplifiedResult*/ false ) ) ;
2690
+ [ CommandNames . UncommentSelectionFull ] : ( request : protocol . CommentSelectionRequest ) => {
2691
+ return this . requiredResponse ( this . uncommentSelection ( request . arguments ) ) ;
2736
2692
} ,
2737
2693
} ) ;
2738
2694
0 commit comments