Move findExecutable to extension host

Part of #101073
This commit is contained in:
Alex Ross
2020-07-13 14:25:59 +02:00
parent a9936ddd35
commit aed6bd7e2a
6 changed files with 27 additions and 9 deletions
@@ -668,6 +668,9 @@ export class MainThreadTask implements MainThreadTaskShape {
},
getDefaultShellAndArgs: (): Promise<{ shell: string, args: string[] | string | undefined }> => {
return Promise.resolve(this._proxy.$getDefaultShellAndArgs());
},
findExecutable: (command: string, cwd?: string, paths?: string[]): Promise<string | undefined> => {
return this._proxy.$findExecutable(command, cwd, paths);
}
});
}
@@ -1451,6 +1451,7 @@ export interface ExtHostTaskShape {
$resolveVariables(workspaceFolder: UriComponents, toResolve: { process?: { name: string; cwd?: string; }, variables: string[]; }): Promise<{ process?: string; variables: { [key: string]: string; }; }>;
$getDefaultShellAndArgs(): Thenable<{ shell: string, args: string[] | string | undefined; }>;
$jsonTasksSupported(): Thenable<boolean>;
$findExecutable(command: string, cwd?: string, paths?: string[]): Promise<string | undefined>;
}
export interface IBreakpointDto {
+7 -1
View File
@@ -679,7 +679,9 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask
}
}
public abstract async $jsonTasksSupported(): Promise<boolean>;
public abstract $jsonTasksSupported(): Promise<boolean>;
public abstract $findExecutable(command: string, cwd?: string | undefined, paths?: string[] | undefined): Promise<string | undefined>;
}
export class WorkerExtHostTask extends ExtHostTaskBase {
@@ -775,6 +777,10 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
public async $jsonTasksSupported(): Promise<boolean> {
return false;
}
public async $findExecutable(command: string, cwd?: string | undefined, paths?: string[] | undefined): Promise<string | undefined> {
return undefined;
}
}
export const IExtHostTask = createDecorator<IExtHostTask>('IExtHostTask');
+4
View File
@@ -195,4 +195,8 @@ export class ExtHostTask extends ExtHostTaskBase {
public async $jsonTasksSupported(): Promise<boolean> {
return true;
}
public async $findExecutable(command: string, cwd?: string, paths?: string[]): Promise<string> {
return win32.findExecutable(command, cwd, paths);
}
}
@@ -496,12 +496,15 @@ export class TerminalTaskSystem implements ITaskSystem {
}
}
private resolveAndFindExecutable(workspaceFolder: IWorkspaceFolder | undefined, task: CustomTask | ContributedTask, cwd: string | undefined, envPath: string | undefined): Promise<string> {
return this.findExecutable(
this.configurationResolverService.resolve(workspaceFolder, CommandString.value(task.command.name!)),
cwd ? this.configurationResolverService.resolve(workspaceFolder, cwd) : undefined,
envPath ? envPath.split(path.delimiter).map(p => this.configurationResolverService.resolve(workspaceFolder, p)) : undefined
);
private async resolveAndFindExecutable(systemInfo: TaskSystemInfo | undefined, workspaceFolder: IWorkspaceFolder | undefined, task: CustomTask | ContributedTask, cwd: string | undefined, envPath: string | undefined): Promise<string> {
const command = this.configurationResolverService.resolve(workspaceFolder, CommandString.value(task.command.name!));
cwd = cwd ? this.configurationResolverService.resolve(workspaceFolder, cwd) : undefined;
const paths = envPath ? envPath.split(path.delimiter).map(p => this.configurationResolverService.resolve(workspaceFolder, p)) : undefined;
let foundExecutable = await systemInfo?.findExecutable(command, cwd, paths);
if (!foundExecutable) {
foundExecutable = await this.findExecutable(command, cwd, paths);
}
return foundExecutable;
}
private findUnresolvedVariables(variables: Set<string>, alreadyResolved: Map<string, string>): Set<string> {
@@ -562,7 +565,7 @@ export class TerminalTaskSystem implements ITaskSystem {
if (isProcess) {
let process = CommandString.value(task.command.name!);
if (taskSystemInfo.platform === Platform.Platform.Windows) {
process = await this.resolveAndFindExecutable(workspaceFolder, task, cwd, envPath);
process = await this.resolveAndFindExecutable(taskSystemInfo, workspaceFolder, task, cwd, envPath);
}
resolved.variables.set(TerminalTaskSystem.ProcessVarName, process);
}
@@ -581,7 +584,7 @@ export class TerminalTaskSystem implements ITaskSystem {
if (isProcess) {
let processVarValue: string;
if (Platform.isWindows) {
processVarValue = await this.resolveAndFindExecutable(workspaceFolder, task, cwd, envPath);
processVarValue = await this.resolveAndFindExecutable(taskSystemInfo, workspaceFolder, task, cwd, envPath);
} else {
processVarValue = this.configurationResolverService.resolve(workspaceFolder, CommandString.value(task.command.name!));
}
@@ -121,6 +121,7 @@ export interface TaskSystemInfo {
uriProvider: (this: void, path: string) => URI;
resolveVariables(workspaceFolder: IWorkspaceFolder, toResolve: ResolveSet, target: ConfigurationTarget): Promise<ResolvedVariables>;
getDefaultShellAndArgs(): Promise<{ shell: string, args: string[] | string | undefined }>;
findExecutable(command: string, cwd?: string, paths?: string[]): Promise<string | undefined>;
}
export interface TaskSystemInfoResolver {