93 lines
2.9 KiB
TypeScript
93 lines
2.9 KiB
TypeScript
import { resolveTaskLocations } from "@/commands/resolveTaskLocations";
|
|
import { TASK_FILE_EXTENSION } from "@/model/taskFile";
|
|
import { IConfigProvider } from "@/ports";
|
|
import { FsTaskRepository } from "@/storage/FsTaskRepository";
|
|
import { NodeFileSystem } from "@/storage/NodeFileSystem";
|
|
import { VscodeConfigProvider } from "@/storage/VscodeConfigProvider";
|
|
import { registerTaskCodeActions } from "@/ui/taskCodeActions";
|
|
import { registerTaskCodeLenses } from "@/ui/taskCodeLenses";
|
|
import { registerTaskCommands } from "@/ui/taskCommands";
|
|
import { registerTaskDiagnostics } from "@/ui/taskDiagnostics";
|
|
import { TaskDashboardPanel } from "@/views/taskDashboardPanel";
|
|
import { TaskKanbanPanel } from "@/views/taskKanbanPanel";
|
|
import { TaskTreeProvider } from "@/views/taskTreeProvider";
|
|
import * as path from "path";
|
|
import * as vscode from "vscode";
|
|
|
|
function createTaskWatchers(
|
|
config: IConfigProvider,
|
|
onMutated: () => void,
|
|
): vscode.Disposable {
|
|
return vscode.Disposable.from(
|
|
...resolveTaskLocations(config).map((location) => {
|
|
const pattern = path
|
|
.join(location.folderPath, `*${TASK_FILE_EXTENSION}`)
|
|
.replace(/\\/g, "/");
|
|
const watcher = vscode.workspace.createFileSystemWatcher(pattern);
|
|
watcher.onDidCreate(onMutated);
|
|
watcher.onDidChange(onMutated);
|
|
watcher.onDidDelete(onMutated);
|
|
return watcher;
|
|
}),
|
|
);
|
|
}
|
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
|
const fileSystem = new NodeFileSystem();
|
|
const config = new VscodeConfigProvider();
|
|
const repo = new FsTaskRepository(fileSystem, TASK_FILE_EXTENSION);
|
|
const tree = new TaskTreeProvider(repo, config);
|
|
|
|
const onTasksMutated = (): void => {
|
|
tree.refresh();
|
|
TaskDashboardPanel.refreshIfOpen();
|
|
TaskKanbanPanel.refreshIfOpen();
|
|
};
|
|
|
|
context.subscriptions.push(
|
|
vscode.window.registerTreeDataProvider("xboctukFlow.tasks", tree),
|
|
);
|
|
|
|
let watcherDisposable: vscode.Disposable = createTaskWatchers(
|
|
config,
|
|
onTasksMutated,
|
|
);
|
|
context.subscriptions.push(watcherDisposable);
|
|
|
|
context.subscriptions.push(
|
|
vscode.workspace.onDidChangeConfiguration((e) => {
|
|
if (!e.affectsConfiguration("xboctukFlow")) return;
|
|
watcherDisposable.dispose();
|
|
watcherDisposable = createTaskWatchers(config, onTasksMutated);
|
|
context.subscriptions.push(watcherDisposable);
|
|
tree.refresh();
|
|
}),
|
|
);
|
|
|
|
const statusBarItem = vscode.window.createStatusBarItem(
|
|
vscode.StatusBarAlignment.Left,
|
|
);
|
|
statusBarItem.text = "$(checklist) Tasks";
|
|
statusBarItem.command = "xboctukFlow.openDashboard";
|
|
statusBarItem.tooltip = "XBOCTuK Flow — Open Dashboard";
|
|
statusBarItem.show();
|
|
context.subscriptions.push(statusBarItem);
|
|
|
|
registerTaskDiagnostics(context, { fs: fileSystem, config });
|
|
registerTaskCodeLenses(context);
|
|
registerTaskCodeActions(context);
|
|
|
|
registerTaskCommands(context, {
|
|
repo,
|
|
config,
|
|
tree,
|
|
fs: fileSystem,
|
|
onTasksMutated: () => {
|
|
TaskDashboardPanel.refreshIfOpen();
|
|
TaskKanbanPanel.refreshIfOpen();
|
|
},
|
|
});
|
|
}
|
|
|
|
export function deactivate() {}
|