mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-16 05:58:32 -06:00
brace completion
This commit is contained in:
parent
24ace87f22
commit
863c65b901
8
src/server/protocol.d.ts
vendored
8
src/server/protocol.d.ts
vendored
@ -289,6 +289,14 @@ declare namespace ts.server.protocol {
|
||||
body?: FileSpan[];
|
||||
}
|
||||
|
||||
export interface BraceCompletionRequest extends FileLocationRequest {
|
||||
arguments: BraceCompletionRequestArgs;
|
||||
}
|
||||
|
||||
export interface BraceCompletionRequestArgs extends FileLocationRequestArgs {
|
||||
openingBrace: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get occurrences request; value of command field is
|
||||
* "occurrences". Return response giving spans that are relevant
|
||||
|
||||
@ -102,6 +102,7 @@ namespace ts.server {
|
||||
export namespace CommandNames {
|
||||
export const Brace = "brace";
|
||||
export const BraceFull = "brace-full";
|
||||
export const BraceCompletion = "braceCompletion";
|
||||
export const Change = "change";
|
||||
export const Close = "close";
|
||||
export const Completions = "completions";
|
||||
@ -751,6 +752,12 @@ namespace ts.server {
|
||||
return { position, indentation };
|
||||
}
|
||||
|
||||
private isValidBraceCompletion(args: protocol.BraceCompletionRequestArgs) {
|
||||
const { file, project } = this.getFileAndProject(args.file);
|
||||
const position = this.getPosition(args, project.getScriptInfo(file));
|
||||
return project.languageService.isValidBraceCompletionAtPostion(file, position, args.openingBrace.charCodeAt(0));
|
||||
}
|
||||
|
||||
private getQuickInfoWorker(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.QuickInfoResponseBody | QuickInfo {
|
||||
const file = ts.normalizePath(args.file);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
@ -1302,6 +1309,9 @@ namespace ts.server {
|
||||
[CommandNames.Indentation]: (request: protocol.IndentationRequest) => {
|
||||
return this.requiredResponse(this.getIndentation(request.arguments));
|
||||
},
|
||||
[CommandNames.BraceCompletion]: (request: protocol.BraceCompletionRequest) => {
|
||||
return this.requiredResponse(this.isValidBraceCompletion(request.arguments));
|
||||
},
|
||||
[CommandNames.DocCommentTemplate]: (request: protocol.FileLocationRequest) => {
|
||||
return this.requiredResponse(this.getDocCommentTemplate(request.arguments));
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user