Skip to content

Commit

Permalink
Merge b55840f into 5483188
Browse files Browse the repository at this point in the history
  • Loading branch information
g-arjones committed Sep 28, 2018
2 parents 5483188 + b55840f commit c8ae679
Show file tree
Hide file tree
Showing 13 changed files with 1,008 additions and 311 deletions.
58 changes: 57 additions & 1 deletion package.json
Expand Up @@ -235,6 +235,7 @@
"mode": {
"type": "string",
"enum": [
"build",
"osdeps",
"watch",
"update-config",
Expand All @@ -246,7 +247,62 @@
}
}
}
]
],
"configuration": {
"title": "Autoproj extension configuration",
"properties": {
"autoproj.optionalTasks.package.rebuild": {
"type": "boolean",
"description": "Provide \"Rebuild\" tasks",
"default": false
},
"autoproj.optionalTasks.package.forceBuild": {
"type": "boolean",
"description": "Provide \"Force Build\" tasks",
"default": false
},
"autoproj.optionalTasks.package.buildNoDeps": {
"type": "boolean",
"description": "Provide \"Build (nodeps)\" tasks",
"default": false
},
"autoproj.optionalTasks.package.checkout": {
"type": "boolean",
"description": "Provide \"Checkout\" tasks",
"default": false
},
"autoproj.optionalTasks.package.update": {
"type": "boolean",
"description": "Provide \"Update\" tasks",
"default": false
},
"autoproj.optionalTasks.workspace.build": {
"type": "boolean",
"description": "Provide \"Build all packages\" tasks",
"default": false
},
"autoproj.optionalTasks.workspace.updateConfig": {
"type": "boolean",
"description": "Provide \"Update Configuration\" tasks",
"default": false
},
"autoproj.optionalTasks.workspace.installOsdeps": {
"type": "boolean",
"description": "Provide \"Install OS Dependencies\" tasks",
"default": false
},
"autoproj.optionalTasks.workspace.update": {
"type": "boolean",
"description": "Provide \"Update all packages\" tasks",
"default": false
},
"autoproj.optionalTasks.workspace.checkout": {
"type": "boolean",
"description": "Provide \"Checkout all packages\" tasks",
"default": false
}
}
}
},
"scripts": {
"vscode:prepublish": "npm run compile",
Expand Down
10 changes: 6 additions & 4 deletions src/commands.ts
@@ -1,6 +1,7 @@
import { basename, dirname, join as pathjoin } from "path";
import { CancellationTokenSource, QuickPickOptions, Uri } from "vscode";
import * as autoproj from "./autoproj";
import * as tasks from "./tasks";
import * as wrappers from "./wrappers";

export class Commands {
Expand Down Expand Up @@ -40,11 +41,12 @@ export class Commands {
try {
const ws = await this.showWorkspacePicker();
if (ws) {
const allTasks = await this.vscode.fetchTasks({ type: "autoproj-workspace" });
const watchTask = allTasks.find((task) => task.definition.mode === "update-environment" &&
task.definition.workspace === ws.root);
const allTasks = await this.vscode.fetchTasks(tasks.WorkspaceTaskFilter);
const updateEnvironmentTask = allTasks.find((task) =>
task.definition.mode === tasks.WorkspaceTaskMode.UpdateEnvironment &&
task.definition.workspace === ws.root);

this.vscode.executeTask(watchTask!);
this.vscode.executeTask(updateEnvironmentTask!);
}
} catch (err) {
this.vscode.showErrorMessage(err.message);
Expand Down
16 changes: 12 additions & 4 deletions src/extension.ts
Expand Up @@ -35,7 +35,8 @@ export class EventHandler implements vscode.Disposable {

public onDidStartTaskProcess(event: vscode.TaskProcessStartEvent) {
const task = event.execution.task;
if (task.definition.type === "autoproj-workspace" && task.definition.mode === "watch") {
if (task.definition.type === tasks.TaskType.Workspace &&
task.definition.mode === tasks.WorkspaceTaskMode.Watch) {
this.workspaceRootToPid.set(task.definition.workspace, event.processId);
}
}
Expand All @@ -57,8 +58,8 @@ export class EventHandler implements vscode.Disposable {
this.wrapper.showErrorMessage(`Could not load installation manifest: ${err.message}`);
}
try {
const allTasks = await this.wrapper.fetchTasks({ type: "autoproj-workspace" });
const watchTask = allTasks.find((task) => task.definition.mode === "watch" &&
const allTasks = await this.wrapper.fetchTasks(tasks.WorkspaceTaskFilter);
const watchTask = allTasks.find((task) => task.definition.mode === tasks.WorkspaceTaskMode.Watch &&
task.definition.workspace === workspace.root);

this.wrapper.executeTask(watchTask!);
Expand Down Expand Up @@ -110,6 +111,7 @@ export function setupExtension(subscriptions: any[], vscodeWrapper: wrappers.VSC
const autoprojTaskProvider = new tasks.AutoprojProvider(workspaces, vscodeWrapper);
const autoprojCommands = new commands.Commands(workspaces, vscodeWrapper);
const eventHandler = new EventHandler(vscodeWrapper, fileWatcher, workspaces);
const tasksHandler = new tasks.Handler(vscodeWrapper, workspaces);

subscriptions.push(vscode.workspace.registerTaskProvider("autoproj", autoprojTaskProvider));
if (vscode.workspace.workspaceFolders) {
Expand All @@ -122,7 +124,13 @@ export function setupExtension(subscriptions: any[], vscodeWrapper: wrappers.VSC
subscriptions.push(eventHandler);
subscriptions.push(workspaces);
subscriptions.push(fileWatcher);
subscriptions.push(vscode.tasks.onDidStartTaskProcess((event) => eventHandler.onDidStartTaskProcess(event)));
subscriptions.push(tasksHandler);
subscriptions.push(vscode.tasks.onDidStartTaskProcess((event) => {
eventHandler.onDidStartTaskProcess(event);
tasksHandler.onDidStartTaskProcess(event);
}));
subscriptions.push(vscode.tasks.onDidEndTaskProcess((event) => tasksHandler.onDidEndTaskProcess(event)));
subscriptions.push(vscode.workspace.onDidChangeConfiguration((event) => autoprojTaskProvider.reloadTasks()));
subscriptions.push(vscode.workspace.onDidChangeWorkspaceFolders((event) => {
event.added.forEach((folder) => eventHandler.onWorkspaceFolderAdded(folder));
event.removed.forEach((folder) => eventHandler.onWorkspaceFolderRemoved(folder));
Expand Down
47 changes: 47 additions & 0 deletions src/progress.ts
@@ -0,0 +1,47 @@
import { Progress, ProgressLocation } from "vscode";
import * as wrappers from "./wrappers";

export class ProgressView {
private resolver: (value?: any) => void;
private view: Progress<{ message?: string, increment?: number }>;
private currentProgress: number;
private currentText: string;
private promise: Promise<void>;

constructor(private readonly vscode: wrappers.VSCode, public readonly title?: string) {
this.currentProgress = 0;
}

public show(): void {
this.vscode.withProgress({
cancellable: false,
location: ProgressLocation.Notification,
title: this.title,
}, (progress) => {
this.view = progress;
this.promise = new Promise((resolve) => this.resolver = resolve);
return this.promise;
});
}

public get text() { return this.currentText; }

public get progress() { return this.currentProgress; }

public update(message: string, increment: number) {
this.currentProgress += increment;
this.currentText = message;

if (this.currentProgress < 0) { this.currentProgress = 0; }

this.view.report({ message, increment });
}

public close() {
this.resolver();
}

public async wait() {
return this.promise;
}
}

0 comments on commit c8ae679

Please sign in to comment.