mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 (#15681)
* Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 * Fixes and cleanup * Distro * Fix hygiene yarn * delete no yarn lock changes file * Fix hygiene * Fix layer check * Fix CI * Skip lib checks * Remove tests deleted in vs code * Fix tests * Distro * Fix tests and add removed extension point * Skip failing notebook tests for now * Disable broken tests and cleanup build folder * Update yarn.lock and fix smoke tests * Bump sqlite * fix contributed actions and file spacing * Fix user data path * Update yarn.locks Co-authored-by: ADS Merger <karlb@microsoft.com>
This commit is contained in:
@@ -30,7 +30,6 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag
|
||||
import { IProgressService, IProgressOptions, ProgressLocation } from 'vs/platform/progress/common/progress';
|
||||
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
|
||||
@@ -45,14 +44,15 @@ import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder, IWorkspace,
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IOutputService, IOutputChannel } from 'vs/workbench/contrib/output/common/output';
|
||||
|
||||
import { ITerminalService, ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { ITerminalProfileResolverService } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
|
||||
import { ITaskSystem, ITaskResolver, ITaskSummary, TaskExecuteKind, TaskError, TaskErrors, TaskTerminateResponse, TaskSystemInfo, ITaskExecuteResult } from 'vs/workbench/contrib/tasks/common/taskSystem';
|
||||
import {
|
||||
Task, CustomTask, ConfiguringTask, ContributedTask, InMemoryTask, TaskEvent,
|
||||
TaskSet, TaskGroup, GroupType, ExecutionEngine, JsonSchemaVersion, TaskSourceKind,
|
||||
TaskSorter, TaskIdentifier, KeyedTaskIdentifier, TASK_RUNNING_STATE, TaskRunSource,
|
||||
KeyedTaskIdentifier as NKeyedTaskIdentifier, TaskDefinition
|
||||
KeyedTaskIdentifier as NKeyedTaskIdentifier, TaskDefinition, RuntimeType
|
||||
} from 'vs/workbench/contrib/tasks/common/tasks';
|
||||
import { ITaskService, ITaskProvider, ProblemMatcherRunOptions, CustomizationProperties, TaskFilter, WorkspaceFolderTaskResult, USER_TASKS_GROUP_KEY, CustomExecutionSupportedContext, ShellExecutionSupportedContext, ProcessExecutionSupportedContext } from 'vs/workbench/contrib/tasks/common/taskService';
|
||||
import { getTemplates as getTaskTemplates } from 'vs/workbench/contrib/tasks/common/taskTemplates';
|
||||
@@ -80,6 +80,8 @@ import { isWorkspaceFolder, TaskQuickPickEntry, QUICKOPEN_DETAIL_CONFIG, TaskQui
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { once } from 'vs/base/common/functional';
|
||||
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
|
||||
import { IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from 'vs/platform/workspace/common/workspaceTrust';
|
||||
import { VirtualWorkspaceContext } from 'vs/workbench/browser/contextkeys';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// integration with tasks view panel
|
||||
@@ -141,6 +143,11 @@ interface TaskCustomizationTelemetryEvent {
|
||||
properties: string[];
|
||||
}
|
||||
|
||||
interface CommandUpgrade {
|
||||
command?: string;
|
||||
args?: string[];
|
||||
}
|
||||
|
||||
class TaskMap {
|
||||
private _store: Map<string, Task[]> = new Map();
|
||||
|
||||
@@ -231,8 +238,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
private _waitForSupportedExecutions: Promise<void>;
|
||||
private _onDidRegisterSupportedExecutions: Emitter<void> = new Emitter();
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
private lastRunTasksViewTask: TaskInfo;
|
||||
private lastRunTasksViewTask: TaskInfo; // {{SQL CARBON EDIT}}
|
||||
|
||||
constructor(
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@@ -254,18 +260,19 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@IProgressService private readonly progressService: IProgressService,
|
||||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
@IHostService private readonly _hostService: IHostService,
|
||||
@IDialogService protected readonly dialogService: IDialogService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IContextKeyService protected readonly contextKeyService: IContextKeyService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@ITerminalInstanceService private readonly terminalInstanceService: ITerminalInstanceService,
|
||||
@ITerminalProfileResolverService private readonly terminalProfileResolverService: ITerminalProfileResolverService,
|
||||
@IPathService private readonly pathService: IPathService,
|
||||
@ITextModelService private readonly textModelResolverService: ITextModelService,
|
||||
@IPreferencesService private readonly preferencesService: IPreferencesService,
|
||||
@IViewDescriptorService private readonly viewDescriptorService: IViewDescriptorService,
|
||||
@IWorkspaceTrustRequestService private readonly workspaceTrustRequestService: IWorkspaceTrustRequestService,
|
||||
@IWorkspaceTrustManagementService private readonly workspaceTrustManagementService: IWorkspaceTrustManagementService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@ISqlTaskService private readonly sqlTaskService: ISqlTaskService
|
||||
@ISqlTaskService private readonly sqlTaskService: ISqlTaskService // {{SQL CARBON EDIT}}
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -282,24 +289,8 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
}
|
||||
let folderSetup = this.computeWorkspaceFolderSetup();
|
||||
if (this.executionEngine !== folderSetup[2]) {
|
||||
if (this._taskSystem && this._taskSystem.getActiveTasks().length > 0) {
|
||||
this.notificationService.prompt(
|
||||
Severity.Info,
|
||||
nls.localize(
|
||||
'TaskSystem.noHotSwap',
|
||||
'Changing the task execution engine with an active task running requires to reload the Window'
|
||||
),
|
||||
[{
|
||||
label: nls.localize('reloadWindow', "Reload Window"),
|
||||
run: () => this._hostService.reload()
|
||||
}],
|
||||
{ sticky: true }
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
this.disposeTaskSystemListeners();
|
||||
this._taskSystem = undefined;
|
||||
}
|
||||
this.disposeTaskSystemListeners();
|
||||
this._taskSystem = undefined;
|
||||
}
|
||||
this.updateSetup(folderSetup);
|
||||
this.updateWorkspaceTasks();
|
||||
@@ -344,6 +335,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
this._waitForSupportedExecutions = new Promise(resolve => {
|
||||
once(this._onDidRegisterSupportedExecutions.event)(() => resolve());
|
||||
});
|
||||
this.upgrade();
|
||||
}
|
||||
|
||||
public registerSupportedExecutions(custom?: boolean, shell?: boolean, process?: boolean) {
|
||||
@@ -351,13 +343,14 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
const customContext = CustomExecutionSupportedContext.bindTo(this.contextKeyService);
|
||||
customContext.set(custom);
|
||||
}
|
||||
const isVirtual = !!VirtualWorkspaceContext.getValue(this.contextKeyService);
|
||||
if (shell !== undefined) {
|
||||
const shellContext = ShellExecutionSupportedContext.bindTo(this.contextKeyService);
|
||||
shellContext.set(shell);
|
||||
shellContext.set(shell && !isVirtual);
|
||||
}
|
||||
if (process !== undefined) {
|
||||
const processContext = ProcessExecutionSupportedContext.bindTo(this.contextKeyService);
|
||||
processContext.set(process);
|
||||
processContext.set(process && !isVirtual);
|
||||
}
|
||||
this._onDidRegisterSupportedExecutions.fire();
|
||||
}
|
||||
@@ -373,8 +366,10 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
private registerCommands(): void {
|
||||
CommandsRegistry.registerCommand({
|
||||
id: 'workbench.action.tasks.runTask',
|
||||
handler: (accessor, arg) => {
|
||||
this.runTaskCommand(arg);
|
||||
handler: async (accessor, arg) => {
|
||||
if (await this.trust()) {
|
||||
this.runTaskCommand(arg);
|
||||
}
|
||||
},
|
||||
description: {
|
||||
description: 'Run Task',
|
||||
@@ -387,16 +382,22 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.reRunTask', (accessor, arg) => {
|
||||
this.reRunTaskCommand();
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.reRunTask', async (accessor, arg) => {
|
||||
if (await this.trust()) {
|
||||
this.reRunTaskCommand();
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.restartTask', (accessor, arg) => {
|
||||
this.runRestartTaskCommand(arg);
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.restartTask', async (accessor, arg) => {
|
||||
if (await this.trust()) {
|
||||
this.runRestartTaskCommand(arg);
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.terminate', (accessor, arg) => {
|
||||
this.runTerminateCommand(arg);
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.terminate', async (accessor, arg) => {
|
||||
if (await this.trust()) {
|
||||
this.runTerminateCommand(arg);
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.showLog', () => {
|
||||
@@ -406,34 +407,46 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
this.showOutput();
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.build', () => {
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.build', async () => {
|
||||
if (!this.canRunCommand()) {
|
||||
return;
|
||||
}
|
||||
this.runBuildCommand();
|
||||
if (await this.trust()) {
|
||||
this.runBuildCommand();
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.test', () => {
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.test', async () => {
|
||||
if (!this.canRunCommand()) {
|
||||
return;
|
||||
}
|
||||
this.runTestCommand();
|
||||
if (await this.trust()) {
|
||||
this.runTestCommand();
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.configureTaskRunner', () => {
|
||||
this.runConfigureTasks();
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.configureTaskRunner', async () => {
|
||||
if (await this.trust()) {
|
||||
this.runConfigureTasks();
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.configureDefaultBuildTask', () => {
|
||||
this.runConfigureDefaultBuildTask();
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.configureDefaultBuildTask', async () => {
|
||||
if (await this.trust()) {
|
||||
this.runConfigureDefaultBuildTask();
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.configureDefaultTestTask', () => {
|
||||
this.runConfigureDefaultTestTask();
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.configureDefaultTestTask', async () => {
|
||||
if (await this.trust()) {
|
||||
this.runConfigureDefaultTestTask();
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.showTasks', async () => {
|
||||
return this.runShowTasks();
|
||||
if (await this.trust()) {
|
||||
return this.runShowTasks();
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.tasks.toggleProblems', () => this.commandService.executeCommand(Constants.TOGGLE_MARKERS_VIEW_ACTION_ID));
|
||||
@@ -555,10 +568,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
}
|
||||
|
||||
private getTaskSystemInfo(key: string): TaskSystemInfo | undefined {
|
||||
if (this.environmentService.remoteAuthority) {
|
||||
return this._taskSystemInfos.get(key);
|
||||
}
|
||||
return undefined;
|
||||
return this._taskSystemInfos.get(key);
|
||||
}
|
||||
|
||||
public extensionCallbackTaskComplete(task: Task, result: number): Promise<void> {
|
||||
@@ -568,7 +578,10 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return this._taskSystem.customExecutionComplete(task, result);
|
||||
}
|
||||
|
||||
public getTask(folder: IWorkspace | IWorkspaceFolder | string, identifier: string | TaskIdentifier, compareId: boolean = false): Promise<Task | undefined> {
|
||||
public async getTask(folder: IWorkspace | IWorkspaceFolder | string, identifier: string | TaskIdentifier, compareId: boolean = false): Promise<Task | undefined> {
|
||||
if (!(await this.trust())) {
|
||||
return undefined; // {{SQL CARBON EDIT}} Strict null
|
||||
}
|
||||
const name = Types.isString(folder) ? folder : isWorkspaceFolder(folder) ? folder.name : folder.configuration ? resources.basename(folder.configuration) : undefined;
|
||||
if (this.ignoredWorkspaceFolders.some(ignored => ignored.name === name)) {
|
||||
return Promise.reject(new Error(nls.localize('TaskServer.folderIgnored', 'The folder {0} is ignored since it uses task version 0.1.0', name)));
|
||||
@@ -593,6 +606,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
}
|
||||
|
||||
public async tryResolveTask(configuringTask: ConfiguringTask): Promise<Task | undefined> {
|
||||
if (!(await this.trust())) {
|
||||
return undefined; // {{SQL CARBON EDIT}} Strict null
|
||||
}
|
||||
await Promise.all([this.extensionService.activateByEvent('onCommand:workbench.action.tasks.runTask'), this.extensionService.whenInstalledExtensionsRegistered()]);
|
||||
let matchingProvider: ITaskProvider | undefined;
|
||||
let matchingProviderUnavailable: boolean = false;
|
||||
@@ -642,7 +658,10 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
|
||||
protected abstract versionAndEngineCompatible(filter?: TaskFilter): boolean;
|
||||
|
||||
public tasks(filter?: TaskFilter): Promise<Task[]> {
|
||||
public async tasks(filter?: TaskFilter): Promise<Task[]> {
|
||||
if (!(await this.trust())) {
|
||||
return [];
|
||||
}
|
||||
if (!this.versionAndEngineCompatible(filter)) {
|
||||
return Promise.resolve<Task[]>([]);
|
||||
}
|
||||
@@ -688,25 +707,25 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return new TaskSorter(this.contextService.getWorkspace() ? this.contextService.getWorkspace().folders : []);
|
||||
}
|
||||
|
||||
public isActive(): Promise<boolean> {
|
||||
private isActive(): Promise<boolean> {
|
||||
if (!this._taskSystem) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
return this._taskSystem.isActive();
|
||||
}
|
||||
|
||||
public getActiveTasks(): Promise<Task[]> {
|
||||
public async getActiveTasks(): Promise<Task[]> {
|
||||
if (!this._taskSystem) {
|
||||
return Promise.resolve([]);
|
||||
return [];
|
||||
}
|
||||
return Promise.resolve(this._taskSystem.getActiveTasks());
|
||||
return this._taskSystem.getActiveTasks();
|
||||
}
|
||||
|
||||
public getBusyTasks(): Promise<Task[]> {
|
||||
public async getBusyTasks(): Promise<Task[]> {
|
||||
if (!this._taskSystem) {
|
||||
return Promise.resolve([]);
|
||||
return [];
|
||||
}
|
||||
return Promise.resolve(this._taskSystem.getBusyTasks());
|
||||
return this._taskSystem.getBusyTasks();
|
||||
}
|
||||
|
||||
public getRecentlyUsedTasksV1(): LRUCache<string, string> {
|
||||
@@ -732,7 +751,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return this._recentlyUsedTasksV1;
|
||||
}
|
||||
|
||||
public getRecentlyUsedTasks(): LRUCache<string, string> {
|
||||
private getRecentlyUsedTasks(): LRUCache<string, string> {
|
||||
if (this._recentlyUsedTasks) {
|
||||
return this._recentlyUsedTasks;
|
||||
}
|
||||
@@ -783,7 +802,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
for (const key of folderToTasksMap.keys()) {
|
||||
let custom: CustomTask[] = [];
|
||||
let customized: IStringDictionary<ConfiguringTask> = Object.create(null);
|
||||
await this.computeTasksForSingleConfig(folderMap[key] ?? this.workspaceFolders[0], {
|
||||
await this.computeTasksForSingleConfig(folderMap[key] ?? await this.getAFolder(), {
|
||||
version: '2.0.0',
|
||||
tasks: folderToTasksMap.get(key)
|
||||
}, TaskRunSource.System, custom, customized, folderMap[key] ? TaskConfig.TaskConfigSource.TasksJson : TaskConfig.TaskConfigSource.User, true);
|
||||
@@ -867,7 +886,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
this.openerService.open(URI.parse('https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher'));
|
||||
}
|
||||
|
||||
public async build(): Promise<ITaskSummary> {
|
||||
private build(): Promise<ITaskSummary> {
|
||||
return this.getGroupedTasks().then((tasks) => {
|
||||
let runnable = this.createRunnableTask(tasks, TaskGroup.Build);
|
||||
if (!runnable || !runnable.task) {
|
||||
@@ -884,7 +903,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
});
|
||||
}
|
||||
|
||||
public runTest(): Promise<ITaskSummary> {
|
||||
private runTest(): Promise<ITaskSummary> {
|
||||
return this.getGroupedTasks().then((tasks) => {
|
||||
let runnable = this.createRunnableTask(tasks, TaskGroup.Test);
|
||||
if (!runnable || !runnable.task) {
|
||||
@@ -901,10 +920,15 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
});
|
||||
}
|
||||
|
||||
public run(task: Task | undefined, options?: ProblemMatcherRunOptions, runSource: TaskRunSource = TaskRunSource.System): Promise<ITaskSummary | undefined> {
|
||||
public async run(task: Task | undefined, options?: ProblemMatcherRunOptions, runSource: TaskRunSource = TaskRunSource.System): Promise<ITaskSummary | undefined> {
|
||||
if (!(await this.trust())) {
|
||||
return undefined; // {{SQL CARBON EDIT}} Strict null
|
||||
}
|
||||
|
||||
if (!task) {
|
||||
throw new TaskError(Severity.Info, nls.localize('TaskServer.noTask', 'Task to execute is undefined'), TaskErrors.TaskNotFound);
|
||||
}
|
||||
|
||||
return new Promise<ITaskSummary | undefined>(async (resolve) => {
|
||||
let resolver = this.createResolver();
|
||||
if (options && options.attachProblemMatcher && this.shouldAttachProblemMatcher(task) && !InMemoryTask.is(task)) {
|
||||
@@ -920,7 +944,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
}).then((value) => {
|
||||
if (runSource === TaskRunSource.User) {
|
||||
this.getWorkspaceTasks().then(workspaceTasks => {
|
||||
RunAutomaticTasks.promptForPermission(this, this.storageService, this.notificationService, workspaceTasks);
|
||||
RunAutomaticTasks.promptForPermission(this, this.storageService, this.notificationService, this.workspaceTrustManagementService, this.openerService, workspaceTasks);
|
||||
});
|
||||
}
|
||||
return value;
|
||||
@@ -1079,7 +1103,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return Promise.resolve(task);
|
||||
}
|
||||
|
||||
public getTasksForGroup(group: string): Promise<Task[]> {
|
||||
private getTasksForGroup(group: string): Promise<Task[]> {
|
||||
return this.getGroupedTasks().then((groups) => {
|
||||
let result: Task[] = [];
|
||||
groups.forEach((tasks) => {
|
||||
@@ -1097,7 +1121,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
|
||||
}
|
||||
|
||||
public canCustomize(task: Task): boolean {
|
||||
private canCustomize(task: Task): boolean {
|
||||
if (this.schemaVersion !== JsonSchemaVersion.V2_0_0) {
|
||||
return false;
|
||||
}
|
||||
@@ -1219,7 +1243,11 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return toCustomize;
|
||||
}
|
||||
|
||||
public customize(task: ContributedTask | CustomTask | ConfiguringTask, properties?: CustomizationProperties, openConfig?: boolean): Promise<void> {
|
||||
public async customize(task: ContributedTask | CustomTask | ConfiguringTask, properties?: CustomizationProperties, openConfig?: boolean): Promise<void> {
|
||||
if (!(await this.trust())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const workspaceFolder = task.getWorkspaceFolder();
|
||||
if (!workspaceFolder) {
|
||||
return Promise.resolve(undefined);
|
||||
@@ -1602,7 +1630,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return executeResult.promise;
|
||||
}
|
||||
|
||||
public restart(task: Task): void {
|
||||
private restart(task: Task): void {
|
||||
if (!this._taskSystem) {
|
||||
return;
|
||||
}
|
||||
@@ -1618,14 +1646,18 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
});
|
||||
}
|
||||
|
||||
public terminate(task: Task): Promise<TaskTerminateResponse> {
|
||||
public async terminate(task: Task): Promise<TaskTerminateResponse> {
|
||||
if (!(await this.trust())) {
|
||||
return { success: true, task: undefined };
|
||||
}
|
||||
|
||||
if (!this._taskSystem) {
|
||||
return Promise.resolve({ success: true, task: undefined });
|
||||
return { success: true, task: undefined };
|
||||
}
|
||||
return this._taskSystem.terminate(task);
|
||||
}
|
||||
|
||||
public terminateAll(): Promise<TaskTerminateResponse[]> {
|
||||
private terminateAll(): Promise<TaskTerminateResponse[]> {
|
||||
if (!this._taskSystem) {
|
||||
return Promise.resolve<TaskTerminateResponse[]>([]);
|
||||
}
|
||||
@@ -1637,7 +1669,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
this.terminalService, this.outputService, this.panelService, this.viewsService, this.markerService,
|
||||
this.modelService, this.configurationResolverService, this.telemetryService,
|
||||
this.contextService, this.environmentService,
|
||||
AbstractTaskService.OutputChannelId, this.fileService, this.terminalInstanceService,
|
||||
AbstractTaskService.OutputChannelId, this.fileService, this.terminalProfileResolverService,
|
||||
this.pathService, this.viewDescriptorService, this.logService, this.configurationService,
|
||||
(workspaceFolder: IWorkspaceFolder | undefined) => {
|
||||
if (workspaceFolder) {
|
||||
@@ -1898,6 +1930,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
}
|
||||
|
||||
public async getWorkspaceTasks(runSource: TaskRunSource = TaskRunSource.User): Promise<Map<string, WorkspaceFolderTaskResult>> {
|
||||
if (!(await this.trust())) {
|
||||
return new Map();
|
||||
}
|
||||
await this._waitForSupportedExecutions;
|
||||
if (this._workspaceTasksPromise) {
|
||||
return this._workspaceTasksPromise;
|
||||
@@ -1906,7 +1941,18 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return this._workspaceTasksPromise!;
|
||||
}
|
||||
|
||||
protected abstract updateWorkspaceTasks(runSource: TaskRunSource | void): void;
|
||||
private updateWorkspaceTasks(runSource: TaskRunSource = TaskRunSource.User): void {
|
||||
this._workspaceTasksPromise = this.computeWorkspaceTasks(runSource);
|
||||
}
|
||||
|
||||
private async getAFolder(): Promise<IWorkspaceFolder> {
|
||||
let folder = this.workspaceFolders.length > 0 ? this.workspaceFolders[0] : undefined;
|
||||
if (!folder) {
|
||||
const userhome = await this.pathService.userHome();
|
||||
folder = new WorkspaceFolder({ uri: userhome, name: resources.basename(userhome), index: 0 });
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
protected computeWorkspaceTasks(runSource: TaskRunSource = TaskRunSource.User): Promise<Map<string, WorkspaceFolderTaskResult>> {
|
||||
let promises: Promise<WorkspaceFolderTaskResult | undefined>[] = [];
|
||||
@@ -1920,11 +1966,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
result.set(value.workspaceFolder.uri.toString(), value);
|
||||
}
|
||||
}
|
||||
let folder = this.workspaceFolders.length > 0 ? this.workspaceFolders[0] : undefined;
|
||||
if (!folder) {
|
||||
const userhome = await this.pathService.userHome();
|
||||
folder = new WorkspaceFolder({ uri: userhome, name: resources.basename(userhome), index: 0 });
|
||||
}
|
||||
const folder = await this.getAFolder();
|
||||
const userTasks = await this.computeUserTasks(folder, runSource).then((value) => value, () => undefined);
|
||||
if (userTasks) {
|
||||
result.set(USER_TASKS_GROUP_KEY, userTasks);
|
||||
@@ -2094,6 +2136,15 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
let workspaceFolder: IWorkspaceFolder = this.contextService.getWorkspace().folders[0];
|
||||
workspaceFolders.push(workspaceFolder);
|
||||
executionEngine = this.computeExecutionEngine(workspaceFolder);
|
||||
const telemetryData: { [key: string]: any; } = {
|
||||
executionEngineVersion: executionEngine
|
||||
};
|
||||
/* __GDPR__
|
||||
"taskService.engineVersion" : {
|
||||
"executionEngineVersion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('taskService.engineVersion', telemetryData);
|
||||
schemaVersion = this.computeJsonSchemaVersion(workspaceFolder);
|
||||
} else if (this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE) {
|
||||
workspace = this.contextService.getWorkspace();
|
||||
@@ -2392,7 +2443,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return (this.getRecentlyUsedTasksV1().size > 0) && (this.getRecentlyUsedTasks().size === 0);
|
||||
}
|
||||
|
||||
public async migrateRecentTasks(tasks: Task[]) {
|
||||
private async migrateRecentTasks(tasks: Task[]) {
|
||||
if (!this.needsRecentTasksMigration()) {
|
||||
return;
|
||||
}
|
||||
@@ -2435,6 +2486,14 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
private async trust(): Promise<boolean> {
|
||||
return (await this.workspaceTrustRequestService.requestWorkspaceTrust(
|
||||
{
|
||||
modal: true,
|
||||
message: nls.localize('TaskService.requestTrust', "Listing and running tasks requires that some of the files in this workspace be executed as code.")
|
||||
})) === true;
|
||||
}
|
||||
|
||||
private runTaskCommand(arg?: any): void {
|
||||
if (!this.canRunCommand()) {
|
||||
return;
|
||||
@@ -2939,6 +2998,10 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
}
|
||||
|
||||
private async runConfigureTasks(): Promise<void> {
|
||||
if (!(await this.trust())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.canRunCommand()) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -3144,4 +3207,132 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async createTasksDotOld(folder: IWorkspaceFolder): Promise<[URI, URI] | undefined> {
|
||||
const tasksFile = folder.toResource('.vscode/tasks.json');
|
||||
if (await this.fileService.exists(tasksFile)) {
|
||||
const oldFile = tasksFile.with({ path: `${tasksFile.path}.old` });
|
||||
await this.fileService.copy(tasksFile, oldFile, true);
|
||||
return [oldFile, tasksFile];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private upgradeTask(task: Task, suppressTaskName: boolean, globalConfig: { windows?: CommandUpgrade, osx?: CommandUpgrade, linux?: CommandUpgrade }): TaskConfig.CustomTask | TaskConfig.ConfiguringTask | undefined {
|
||||
if (!CustomTask.is(task)) {
|
||||
return undefined; // {{SQL CARBON EDIT}} Strict nulls
|
||||
}
|
||||
const configElement: any = {
|
||||
label: task._label
|
||||
};
|
||||
const oldTaskTypes = new Set(['gulp', 'jake', 'grunt']);
|
||||
if (Types.isString(task.command.name) && oldTaskTypes.has(task.command.name)) {
|
||||
configElement.type = task.command.name;
|
||||
configElement.task = task.command.args![0];
|
||||
} else {
|
||||
if (task.command.runtime === RuntimeType.Shell) {
|
||||
configElement.type = RuntimeType.toString(RuntimeType.Shell);
|
||||
}
|
||||
if (task.command.name && !suppressTaskName && !globalConfig.windows?.command && !globalConfig.osx?.command && !globalConfig.linux?.command) {
|
||||
configElement.command = task.command.name;
|
||||
} else if (suppressTaskName) {
|
||||
configElement.command = task._source.config.element.command;
|
||||
}
|
||||
if (task.command.args && (!Types.isArray(task.command.args) || (task.command.args.length > 0))) {
|
||||
if (!globalConfig.windows?.args && !globalConfig.osx?.args && !globalConfig.linux?.args) {
|
||||
configElement.args = task.command.args;
|
||||
} else {
|
||||
configElement.args = task._source.config.element.args;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (task.configurationProperties.presentation) {
|
||||
configElement.presentation = task.configurationProperties.presentation;
|
||||
}
|
||||
if (task.configurationProperties.isBackground) {
|
||||
configElement.isBackground = task.configurationProperties.isBackground;
|
||||
}
|
||||
if (task.configurationProperties.problemMatchers) {
|
||||
configElement.problemMatcher = task._source.config.element.problemMatcher;
|
||||
}
|
||||
if (task.configurationProperties.group) {
|
||||
configElement.group = task.configurationProperties.group;
|
||||
}
|
||||
|
||||
task._source.config.element = configElement;
|
||||
const tempTask = new CustomTask(task._id, task._source, task._label, task.type, task.command, task.hasDefinedMatchers, task.runOptions, task.configurationProperties);
|
||||
const configTask = this.createCustomizableTask(tempTask);
|
||||
if (configTask) {
|
||||
return configTask;
|
||||
}
|
||||
return undefined; // {{SQL CARBON EDIT}} Strict nulls
|
||||
}
|
||||
|
||||
private async upgrade(): Promise<void> {
|
||||
if (this.schemaVersion === JsonSchemaVersion.V2_0_0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(await this.trust())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tasks = await this.getGroupedTasks();
|
||||
const fileDiffs: [URI, URI][] = [];
|
||||
for (const folder of this.workspaceFolders) {
|
||||
const diff = await this.createTasksDotOld(folder);
|
||||
if (diff) {
|
||||
fileDiffs.push(diff);
|
||||
}
|
||||
if (!diff) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const configTasks: (TaskConfig.CustomTask | TaskConfig.ConfiguringTask)[] = [];
|
||||
const suppressTaskName = !!this.configurationService.getValue('tasks.suppressTaskName', { resource: folder.uri });
|
||||
const globalConfig = {
|
||||
windows: <CommandUpgrade>this.configurationService.getValue('tasks.windows', { resource: folder.uri }),
|
||||
osx: <CommandUpgrade>this.configurationService.getValue('tasks.osx', { resource: folder.uri }),
|
||||
linux: <CommandUpgrade>this.configurationService.getValue('tasks.linux', { resource: folder.uri })
|
||||
};
|
||||
tasks.get(folder).forEach(task => {
|
||||
const configTask = this.upgradeTask(task, suppressTaskName, globalConfig);
|
||||
if (configTask) {
|
||||
configTasks.push(configTask);
|
||||
}
|
||||
});
|
||||
this._taskSystem = undefined;
|
||||
this._workspaceTasksPromise = undefined;
|
||||
await this.writeConfiguration(folder, 'tasks.tasks', configTasks);
|
||||
await this.writeConfiguration(folder, 'tasks.version', '2.0.0');
|
||||
if (this.configurationService.getValue('tasks.showOutput', { resource: folder.uri })) {
|
||||
await this.configurationService.updateValue('tasks.showOutput', undefined, { resource: folder.uri });
|
||||
}
|
||||
if (this.configurationService.getValue('tasks.isShellCommand', { resource: folder.uri })) {
|
||||
await this.configurationService.updateValue('tasks.isShellCommand', undefined, { resource: folder.uri });
|
||||
}
|
||||
if (this.configurationService.getValue('tasks.suppressTaskName', { resource: folder.uri })) {
|
||||
await this.configurationService.updateValue('tasks.suppressTaskName', undefined, { resource: folder.uri });
|
||||
}
|
||||
}
|
||||
this.updateSetup();
|
||||
|
||||
this.notificationService.prompt(Severity.Warning,
|
||||
fileDiffs.length === 1 ?
|
||||
nls.localize('taskService.upgradeVersion', "The deprecated tasks version 0.1.0 has been removed. Your tasks have been upgraded to version 2.0.0. Open the diff to review the upgrade.")
|
||||
: nls.localize('taskService.upgradeVersionPlural', "The deprecated tasks version 0.1.0 has been removed. Your tasks have been upgraded to version 2.0.0. Open the diffs to review the upgrade."),
|
||||
[{
|
||||
label: fileDiffs.length === 1 ? nls.localize('taskService.openDiff', "Open diff") : nls.localize('taskService.openDiffs', "Open diffs"),
|
||||
run: async () => {
|
||||
for (const upgrade of fileDiffs) {
|
||||
await this.editorService.openEditor({
|
||||
leftResource: upgrade[0],
|
||||
rightResource: upgrade[1],
|
||||
});
|
||||
}
|
||||
}
|
||||
}]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user