Skip to content

Commit 40751ba

Browse files
author
Armando Aguirre
committed
Removed public commands
1 parent 89429ac commit 40751ba

File tree

4 files changed

+19
-99
lines changed

4 files changed

+19
-99
lines changed

src/server/protocol.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,12 @@ namespace ts.server.protocol {
136136
SelectionRange = "selectionRange",
137137
/* @internal */
138138
SelectionRangeFull = "selectionRange-full",
139-
ToggleLineComment = "toggleLineComment",
140139
/* @internal */
141140
ToggleLineCommentFull = "toggleLineComment-full",
142-
ToggleMultilineComment = "toggleMultilineComment",
143141
/* @internal */
144142
ToggleMultilineCommentFull = "toggleMultilineComment-full",
145-
CommentSelection = "commentSelection",
146143
/* @internal */
147144
CommentSelectionFull = "commentSelection-full",
148-
UncommentSelection = "uncommentSelection",
149145
/* @internal */
150146
UncommentSelectionFull = "uncommentSelection-full",
151147
PrepareCallHierarchy = "prepareCallHierarchy",
@@ -1544,23 +1540,8 @@ namespace ts.server.protocol {
15441540
parent?: SelectionRange;
15451541
}
15461542

1547-
export interface ToggleLineCommentRequest extends FileRequest {
1548-
command: CommandTypes.ToggleLineComment;
1549-
arguments: FileRangeRequestArgs;
1550-
}
1551-
1552-
export interface ToggleMultilineCommentRequest extends FileRequest {
1553-
command: CommandTypes.ToggleMultilineComment;
1554-
arguments: FileRangeRequestArgs;
1555-
}
1556-
15571543
export interface CommentSelectionRequest extends FileRequest {
1558-
command: CommandTypes.CommentSelection;
1559-
arguments: FileRangeRequestArgs;
1560-
}
15611544

1562-
export interface UncommentSelectionRequest extends FileRequest {
1563-
command: CommandTypes.UncommentSelection;
15641545
arguments: FileRangeRequestArgs;
15651546
}
15661547

src/server/session.ts

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,68 +2201,36 @@ namespace ts.server {
22012201
});
22022202
}
22032203

2204-
private toggleLineComment(args: protocol.FileRangeRequestArgs, simplifiedResult: boolean): TextChange[] | protocol.CodeEdit[] {
2204+
private toggleLineComment(args: protocol.FileRangeRequestArgs): TextChange[] {
22052205
const { file, project } = this.getFileAndProject(args);
22062206
const scriptInfo = project.getScriptInfoForNormalizedPath(file)!;
22072207
const textRange = this.getRange(args, scriptInfo);
22082208

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);
22182210
}
22192211

2220-
private toggleMultilineComment(args: protocol.FileRangeRequestArgs, simplifiedResult: boolean): TextChange[] | protocol.CodeEdit[] {
2212+
private toggleMultilineComment(args: protocol.FileRangeRequestArgs): TextChange[] {
22212213
const { file, project } = this.getFileAndProject(args);
22222214
const scriptInfo = project.getScriptInfoForNormalizedPath(file)!;
22232215
const textRange = this.getRange(args, scriptInfo);
22242216

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);
22342218
}
22352219

2236-
private commentSelection(args: protocol.FileRangeRequestArgs, simplifiedResult: boolean): TextChange[] | protocol.CodeEdit[] {
2220+
private commentSelection(args: protocol.FileRangeRequestArgs): TextChange[] {
22372221
const { file, project } = this.getFileAndProject(args);
22382222
const scriptInfo = project.getScriptInfoForNormalizedPath(file)!;
22392223
const textRange = this.getRange(args, scriptInfo);
22402224

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);
22502226
}
22512227

2252-
private uncommentSelection(args: protocol.FileRangeRequestArgs, simplifiedResult: boolean): TextChange[] | protocol.CodeEdit[] {
2228+
private uncommentSelection(args: protocol.FileRangeRequestArgs): TextChange[] {
22532229
const { file, project } = this.getFileAndProject(args);
22542230
const scriptInfo = project.getScriptInfoForNormalizedPath(file)!;
22552231
const textRange = this.getRange(args, scriptInfo);
22562232

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);
22662234
}
22672235

22682236
private mapSelectionRange(selectionRange: SelectionRange, scriptInfo: ScriptInfo): protocol.SelectionRange {
@@ -2710,29 +2678,17 @@ namespace ts.server {
27102678
[CommandNames.ProvideCallHierarchyOutgoingCalls]: (request: protocol.ProvideCallHierarchyOutgoingCallsRequest) => {
27112679
return this.requiredResponse(this.provideCallHierarchyOutgoingCalls(request.arguments));
27122680
},
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));
27182683
},
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));
27272686
},
27282687
[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));
27332689
},
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));
27362692
},
27372693
});
27382694

src/testRunner/unittests/tsserver/session.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ namespace ts.server {
272272
CommandNames.PrepareCallHierarchy,
273273
CommandNames.ProvideCallHierarchyIncomingCalls,
274274
CommandNames.ProvideCallHierarchyOutgoingCalls,
275-
CommandNames.ToggleLineComment,
276-
CommandNames.ToggleMultilineComment,
277-
CommandNames.CommentSelection,
278-
CommandNames.UncommentSelection,
275+
CommandNames.ToggleLineCommentFull,
276+
CommandNames.ToggleMultilineCommentFull,
277+
CommandNames.CommentSelectionFull,
278+
CommandNames.UncommentSelectionFull,
279279
];
280280

281281
it("should not throw when commands are executed with invalid arguments", () => {

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6304,10 +6304,6 @@ declare namespace ts.server.protocol {
63046304
GetEditsForFileRename = "getEditsForFileRename",
63056305
ConfigurePlugin = "configurePlugin",
63066306
SelectionRange = "selectionRange",
6307-
ToggleLineComment = "toggleLineComment",
6308-
ToggleMultilineComment = "toggleMultilineComment",
6309-
CommentSelection = "commentSelection",
6310-
UncommentSelection = "uncommentSelection",
63116307
PrepareCallHierarchy = "prepareCallHierarchy",
63126308
ProvideCallHierarchyIncomingCalls = "provideCallHierarchyIncomingCalls",
63136309
ProvideCallHierarchyOutgoingCalls = "provideCallHierarchyOutgoingCalls"
@@ -7332,20 +7328,7 @@ declare namespace ts.server.protocol {
73327328
textSpan: TextSpan;
73337329
parent?: SelectionRange;
73347330
}
7335-
interface ToggleLineCommentRequest extends FileRequest {
7336-
command: CommandTypes.ToggleLineComment;
7337-
arguments: FileRangeRequestArgs;
7338-
}
7339-
interface ToggleMultilineCommentRequest extends FileRequest {
7340-
command: CommandTypes.ToggleMultilineComment;
7341-
arguments: FileRangeRequestArgs;
7342-
}
73437331
interface CommentSelectionRequest extends FileRequest {
7344-
command: CommandTypes.CommentSelection;
7345-
arguments: FileRangeRequestArgs;
7346-
}
7347-
interface UncommentSelectionRequest extends FileRequest {
7348-
command: CommandTypes.UncommentSelection;
73497332
arguments: FileRangeRequestArgs;
73507333
}
73517334
/**

0 commit comments

Comments
 (0)