mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 02:15:10 -05:00
Merge branch 'master' into vfs
This commit is contained in:
@@ -632,6 +632,10 @@ namespace ts.server {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getEditsForFileRename() {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
private convertCodeEditsToTextChanges(edits: protocol.FileCodeEdits[]): FileTextChanges[] {
|
||||
return edits.map(edit => {
|
||||
const fileName = edit.fileName;
|
||||
|
||||
@@ -121,6 +121,9 @@ namespace ts.server.protocol {
|
||||
OrganizeImports = "organizeImports",
|
||||
/* @internal */
|
||||
OrganizeImportsFull = "organizeImports-full",
|
||||
GetEditsForFileRename = "getEditsForFileRename",
|
||||
/* @internal */
|
||||
GetEditsForFileRenameFull = "getEditsForFileRename-full",
|
||||
|
||||
// NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`.
|
||||
}
|
||||
@@ -610,6 +613,22 @@ namespace ts.server.protocol {
|
||||
edits: ReadonlyArray<FileCodeEdits>;
|
||||
}
|
||||
|
||||
export interface GetEditsForFileRenameRequest extends Request {
|
||||
command: CommandTypes.GetEditsForFileRename;
|
||||
arguments: GetEditsForFileRenameRequestArgs;
|
||||
}
|
||||
|
||||
// Note: The file from FileRequestArgs is just any file in the project.
|
||||
// We will generate code changes for every file in that project, so the choice is arbitrary.
|
||||
export interface GetEditsForFileRenameRequestArgs extends FileRequestArgs {
|
||||
readonly oldFilePath: string;
|
||||
readonly newFilePath: string;
|
||||
}
|
||||
|
||||
export interface GetEditsForFileRenameResponse extends Response {
|
||||
edits: ReadonlyArray<FileCodeEdits>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request for the available codefixes at a specific position.
|
||||
*/
|
||||
@@ -1749,6 +1768,7 @@ namespace ts.server.protocol {
|
||||
* Optional prefix to apply to possible completions.
|
||||
*/
|
||||
prefix?: string;
|
||||
triggerCharacter?: string;
|
||||
/**
|
||||
* @deprecated Use UserPreferences.includeCompletionsForModuleExports
|
||||
*/
|
||||
|
||||
@@ -1287,6 +1287,7 @@ namespace ts.server {
|
||||
|
||||
const completions = project.getLanguageService().getCompletionsAtPosition(file, position, {
|
||||
...this.getPreferences(file),
|
||||
triggerCharacter: args.triggerCharacter,
|
||||
includeExternalModuleExports: args.includeExternalModuleExports,
|
||||
includeInsertTextCompletions: args.includeInsertTextCompletions
|
||||
});
|
||||
@@ -1664,6 +1665,12 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
private getEditsForFileRename(args: protocol.GetEditsForFileRenameRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.FileCodeEdits> | ReadonlyArray<FileTextChanges> {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const changes = project.getLanguageService().getEditsForFileRename(args.oldFilePath, args.newFilePath, this.getFormatOptions(file));
|
||||
return simplifiedResult ? this.mapTextChangesToCodeEdits(project, changes) : changes;
|
||||
}
|
||||
|
||||
private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.CodeFixAction> | ReadonlyArray<CodeFixAction> {
|
||||
if (args.errorCodes.length === 0) {
|
||||
return undefined;
|
||||
@@ -2117,7 +2124,13 @@ namespace ts.server {
|
||||
},
|
||||
[CommandNames.OrganizeImportsFull]: (request: protocol.OrganizeImportsRequest) => {
|
||||
return this.requiredResponse(this.organizeImports(request.arguments, /*simplifiedResult*/ false));
|
||||
}
|
||||
},
|
||||
[CommandNames.GetEditsForFileRename]: (request: protocol.GetEditsForFileRenameRequest) => {
|
||||
return this.requiredResponse(this.getEditsForFileRename(request.arguments, /*simplifiedResult*/ true));
|
||||
},
|
||||
[CommandNames.GetEditsForFileRenameFull]: (request: protocol.GetEditsForFileRenameRequest) => {
|
||||
return this.requiredResponse(this.getEditsForFileRename(request.arguments, /*simplifiedResult*/ false));
|
||||
},
|
||||
});
|
||||
|
||||
public addProtocolHandler(command: string, handler: (request: protocol.Request) => HandlerResponse) {
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
"../services/navigateTo.ts",
|
||||
"../services/navigationBar.ts",
|
||||
"../services/organizeImports.ts",
|
||||
"../services/getEditsForFileRename.ts",
|
||||
"../services/outliningElementsCollector.ts",
|
||||
"../services/patternMatcher.ts",
|
||||
"../services/preProcess.ts",
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
"../services/navigateTo.ts",
|
||||
"../services/navigationBar.ts",
|
||||
"../services/organizeImports.ts",
|
||||
"../services/getEditsForFileRename.ts",
|
||||
"../services/outliningElementsCollector.ts",
|
||||
"../services/patternMatcher.ts",
|
||||
"../services/preProcess.ts",
|
||||
|
||||
Reference in New Issue
Block a user