[fix] updates

This commit is contained in:
2025-07-19 18:50:14 +01:00
parent b2014942b6
commit 6f5357ea5c
4 changed files with 2967 additions and 4727 deletions

View File

@@ -2,15 +2,44 @@ import path = require('node:path');
import * as vscode from 'vscode';
export class CustomExecutionTaskProvider implements vscode.TaskProvider{
provideTasks(token?: vscode.CancellationToken): vscode.ProviderResult<vscode.Task[]> {
throw new Error('Method not implemented.');
interface BFRunTaskDefinition {
type: 'current';
file?: string;
}
export class CustomExecutionTaskProvider implements vscode.TaskProvider {
static type: string = 'BFExec';
tasks: vscode.Task[] | undefined;
constructor(private workspaceRoot: string|undefined,private currentDocument:string |undefined){
}
resolveTask(task: vscode.Task, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.Task> {
const taskDefinition = {};
throw new Error('5');
// return new vscode.Task()
provideTasks(token?: vscode.CancellationToken): vscode.ProviderResult<vscode.Task[]> {
if (this.tasks !== undefined) { return this.tasks; }
const types: BFRunTaskDefinition['type'][] = ['current'];
this.tasks = [];
types.forEach(e=>
this.tasks.push(this.getTaskFromDefinition(e))
);
}
getTaskFromDefinition(e: string): vscode.Task {
const definition:BFRunTaskDefinition = {
type: 'current',
file: undefined
};
return new vscode.Task(definition, vscode.TaskScope.Workspace,`bf: run: current file`,CustomExecutionTaskProvider.type,
new vscode.CustomExecution(async ()=>{
return new CustomBuildTaskTerminal(this.workspaceRoot);
})
);
}
resolveTask(_task: vscode.Task, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.Task> {
return undefined;
}
}
@@ -18,24 +47,20 @@ export class CustomExecutionTaskProvider implements vscode.TaskProvider{
class CustomBuildTaskTerminal implements vscode.Pseudoterminal {
private writeEmitter = new vscode.EventEmitter<string>();
onDidWrite: vscode.Event<string> = this.writeEmitter.event;
private closeEmitter = new vscode.EventEmitter<number>();
onDidWrite: vscode.Event<string> = this.writeEmitter.event;
onDidClose?: vscode.Event<number> = this.closeEmitter.event;
private fileWatcher: vscode.FileSystemWatcher | undefined;
constructor(private workspaceRoot: string, private flavor: string, private flags: string[], private getSharedState: () => string | undefined, private setSharedState: (state: string) => void) {
constructor(private workspaceRoot: string) {
}
open(initialDimensions: vscode.TerminalDimensions | undefined): void {
// At this point we can start using the terminal.
if (this.flags.indexOf('watch') > -1) {
const pattern = path.join(this.workspaceRoot, 'customBuildFile');
this.fileWatcher = vscode.workspace.createFileSystemWatcher(pattern);
this.fileWatcher.onDidChange(() => this.doBuild());
this.fileWatcher.onDidCreate(() => this.doBuild());
this.fileWatcher.onDidDelete(() => this.doBuild());
}
this.doBuild();
}
@@ -49,26 +74,10 @@ class CustomBuildTaskTerminal implements vscode.Pseudoterminal {
private async doBuild(): Promise<void> {
return new Promise<void>((resolve) => {
this.writeEmitter.fire('Starting build...\r\n');
let isIncremental = this.flags.indexOf('incremental') > -1;
if (isIncremental) {
if (this.getSharedState()) {
this.writeEmitter.fire('Using last build results: ' + this.getSharedState() + '\r\n');
} else {
isIncremental = false;
this.writeEmitter.fire('No result from last build. Doing full build.\r\n');
}
}
// Since we don't actually build anything in this example set a timeout instead.
setTimeout(() => {
const date = new Date();
this.setSharedState(date.toTimeString() + ' ' + date.toDateString());
this.writeEmitter.fire('Build complete.\r\n\r\n');
if (this.flags.indexOf('watch') === -1) {
this.closeEmitter.fire(0);
resolve();
}
}, isIncremental ? 1000 : 4000);
this.writeEmitter.fire('Build complete.\r\n\r\n');
this.closeEmitter.fire(0);
resolve();
});
}
}