Skip to content

Commit fcdbd06

Browse files
committed
WIP
1 parent 0f8ac80 commit fcdbd06

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

src/server/protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,11 @@ namespace ts.server.protocol {
15741574
* Documentation strings for the symbol.
15751575
*/
15761576
documentation: SymbolDisplayPart[];
1577+
1578+
/**
1579+
* The associated code actions for this entry
1580+
*/
1581+
codeActions?: CodeAction[];
15771582
}
15781583

15791584
export interface CompletionsResponse extends Response {

src/server/session.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ namespace ts.server {
108108
/* @internal */
109109
export const CompletionsFull: protocol.CommandTypes.CompletionsFull = "completions-full";
110110
export const CompletionDetails: protocol.CommandTypes.CompletionDetails = "completionEntryDetails";
111-
export const CommitCompletionWithCodeAction: protocol.CommandTypes.CommitCompletionWithCodeAction = "commitCompletionWithCodeAction";
112111
export const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList";
113112
export const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile = "compileOnSaveEmitFile";
114113
export const Configure: protocol.CommandTypes.Configure = "configure";
@@ -1168,8 +1167,11 @@ namespace ts.server {
11681167

11691168
return args.entryNames.reduce((accum: protocol.CompletionEntryDetails[], entryName: string) => {
11701169
const details = project.getLanguageService().getCompletionEntryDetails(file, position, entryName);
1170+
const mappedCodeActions = map(details.codeActions, action => this.mapCodeAction(action, scriptInfo));
1171+
const mappedDetails = details as (CompletionEntryDetails | protocol.CompletionEntryDetails);
1172+
mappedDetails.codeActions = mappedCodeActions;
11711173
if (details) {
1172-
accum.push(details);
1174+
accum.push(<protocol.CompletionEntryDetails>mappedDetails);
11731175
}
11741176
return accum;
11751177
}, []);
@@ -1197,11 +1199,6 @@ namespace ts.server {
11971199
return result;
11981200
}
11991201

1200-
private getCodeActionAfterCommittingCompletion(args: protocol.CommitCompletionWithCodeActionRequestArgs) {
1201-
const { itemName, sourceFileName } = args;
1202-
const { file, project } = this.getFileAndProject(args);
1203-
}
1204-
12051202
private emitFile(args: protocol.CompileOnSaveEmitFileRequestArgs) {
12061203
const { file, project } = this.getFileAndProject(args);
12071204
if (!project) {
@@ -1686,9 +1683,6 @@ namespace ts.server {
16861683
[CommandNames.CompileOnSaveEmitFile]: (request: protocol.CompileOnSaveEmitFileRequest) => {
16871684
return this.requiredResponse(this.emitFile(request.arguments));
16881685
},
1689-
[CommandNames.CommitCompletionWithCodeAction]: (request: protocol.CommitCompletionWithCodeActionRequest) => {
1690-
return this.requiredResponse(this.getCodeActionAfterCommittingCompletion(request.arguments));
1691-
},
16921686
[CommandNames.SignatureHelp]: (request: protocol.SignatureHelpRequest) => {
16931687
return this.requiredResponse(this.getSignatureHelpItems(request.arguments, /*simplifiedResult*/ true));
16941688
},

src/services/completions.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ namespace ts.Completions {
288288
// Compute all the completion symbols again.
289289
const completionData = getCompletionData(typeChecker, log, sourceFile, position, allSourceFiles);
290290
if (completionData) {
291-
const { symbols, location } = completionData;
291+
const { symbols, location, symbolActionMap } = completionData;
292292

293293
// Find the symbol with the matching entry name.
294294
// We don't need to perform character checks here because we're only comparing the
@@ -297,13 +297,20 @@ namespace ts.Completions {
297297
const symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location) === entryName ? s : undefined);
298298

299299
if (symbol) {
300+
301+
let codeActions: CodeAction[];
302+
if (symbolActionMap.has(getUniqueSymbolIdAsString(symbol, typeChecker))) {
303+
codeActions = [];
304+
}
305+
300306
const { displayParts, documentation, symbolKind } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, SemanticMeaning.All);
301307
return {
302308
name: entryName,
303309
kindModifiers: SymbolDisplay.getSymbolModifiers(symbol),
304310
kind: symbolKind,
305311
displayParts,
306-
documentation
312+
documentation,
313+
codeActions
307314
};
308315
}
309316
}
@@ -489,7 +496,7 @@ namespace ts.Completions {
489496
// It has a left-hand side, so we're not in an opening JSX tag.
490497
break;
491498
}
492-
// fall through
499+
// fall through
493500

494501
case SyntaxKind.JsxSelfClosingElement:
495502
case SyntaxKind.JsxElement:

src/services/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ namespace ts {
603603
kindModifiers: string; // see ScriptElementKindModifier, comma separated
604604
displayParts: SymbolDisplayPart[];
605605
documentation: SymbolDisplayPart[];
606+
codeActions?: CodeAction[];
606607
}
607608

608609
export interface OutliningSpan {

0 commit comments

Comments
 (0)