mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 11:46:08 -05:00
Add CopilotRelated command (#59963)
This commit is contained in:
committed by
GitHub
parent
da1fb07db0
commit
52c59dbcbe
@@ -202,6 +202,7 @@ export const enum CommandTypes {
|
||||
ProvideInlayHints = "provideInlayHints",
|
||||
WatchChange = "watchChange",
|
||||
MapCode = "mapCode",
|
||||
CopilotRelated = "copilotRelated",
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2406,6 +2407,18 @@ export interface MapCodeResponse extends Response {
|
||||
body: readonly FileCodeEdits[];
|
||||
}
|
||||
|
||||
export interface CopilotRelatedRequest extends FileRequest {
|
||||
command: CommandTypes.CopilotRelated;
|
||||
arguments: FileRequestArgs;
|
||||
}
|
||||
|
||||
export interface CopilotRelatedItems {
|
||||
relatedFiles: readonly string[];
|
||||
}
|
||||
|
||||
export interface CopilotRelatedResponse extends Response {
|
||||
body: CopilotRelatedItems;
|
||||
}
|
||||
/**
|
||||
* Synchronous request for semantic diagnostics of one file.
|
||||
*/
|
||||
|
||||
@@ -937,6 +937,7 @@ const invalidPartialSemanticModeCommands: readonly protocol.CommandTypes[] = [
|
||||
protocol.CommandTypes.ProvideCallHierarchyIncomingCalls,
|
||||
protocol.CommandTypes.ProvideCallHierarchyOutgoingCalls,
|
||||
protocol.CommandTypes.GetPasteEdits,
|
||||
protocol.CommandTypes.CopilotRelated,
|
||||
];
|
||||
|
||||
const invalidSyntacticModeCommands: readonly protocol.CommandTypes[] = [
|
||||
@@ -2030,7 +2031,6 @@ export class Session<TMessage = string> implements EventSender {
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private mapCode(args: protocol.MapCodeRequestArgs): protocol.FileCodeEdits[] {
|
||||
const formatOptions = this.getHostFormatOptions();
|
||||
const preferences = this.getHostPreferences();
|
||||
@@ -2051,6 +2051,14 @@ export class Session<TMessage = string> implements EventSender {
|
||||
return this.mapTextChangesToCodeEdits(changes);
|
||||
}
|
||||
|
||||
private getCopilotRelatedInfo(args: protocol.FileRequestArgs): protocol.CopilotRelatedItems {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
|
||||
return {
|
||||
relatedFiles: project.getLanguageService().getImports(file),
|
||||
};
|
||||
}
|
||||
|
||||
private setCompilerOptionsForInferredProjects(args: protocol.SetCompilerOptionsForInferredProjectsArgs): void {
|
||||
this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
|
||||
}
|
||||
@@ -3791,6 +3799,9 @@ export class Session<TMessage = string> implements EventSender {
|
||||
[protocol.CommandTypes.MapCode]: (request: protocol.MapCodeRequest) => {
|
||||
return this.requiredResponse(this.mapCode(request.arguments));
|
||||
},
|
||||
[protocol.CommandTypes.CopilotRelated]: (request: protocol.CopilotRelatedRequest) => {
|
||||
return this.requiredResponse(this.getCopilotRelatedInfo(request.arguments));
|
||||
},
|
||||
}));
|
||||
|
||||
public addProtocolHandler(command: string, handler: (request: protocol.Request) => HandlerResponse): void {
|
||||
|
||||
Reference in New Issue
Block a user