[fix] updates
This commit is contained in:
@@ -4,8 +4,8 @@
|
|||||||
* ------------------------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { commands } from 'vscode';
|
import { commands, tasks, workspace } from 'vscode';
|
||||||
import type { ExtensionContext } from 'vscode';
|
import type { Disposable, ExtensionContext } from 'vscode';
|
||||||
import {
|
import {
|
||||||
LanguageClient,
|
LanguageClient,
|
||||||
LanguageClientOptions,
|
LanguageClientOptions,
|
||||||
@@ -13,9 +13,12 @@ import {
|
|||||||
TransportKind,
|
TransportKind,
|
||||||
} from 'vscode-languageclient';
|
} from 'vscode-languageclient';
|
||||||
import { CompileBranFlakesCommand } from './command/CompileBranFlakesCommand';
|
import { CompileBranFlakesCommand } from './command/CompileBranFlakesCommand';
|
||||||
|
import { CustomExecutionTaskProvider } from './task/CustomExecutionTerminal';
|
||||||
|
|
||||||
let client: LanguageClient;
|
let client: LanguageClient;
|
||||||
|
|
||||||
|
let bfRunTaskProvider: Disposable;
|
||||||
|
|
||||||
export function activate(context: ExtensionContext) {
|
export function activate(context: ExtensionContext) {
|
||||||
// The server is implemented in node
|
// The server is implemented in node
|
||||||
let serverModule = context.asAbsolutePath(
|
let serverModule = context.asAbsolutePath(
|
||||||
@@ -48,10 +51,13 @@ export function activate(context: ExtensionContext) {
|
|||||||
commands.registerCommand(
|
commands.registerCommand(
|
||||||
branFlakesCommand.getCommandName(),
|
branFlakesCommand.getCommandName(),
|
||||||
branFlakesCommand.getCommandHandler()
|
branFlakesCommand.getCommandHandler()
|
||||||
)
|
),
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create the language client and start the client.
|
// Create the language client and start the client.
|
||||||
client = new LanguageClient(
|
client = new LanguageClient(
|
||||||
'brainfucklanguageserver',
|
'brainfucklanguageserver',
|
||||||
@@ -62,11 +68,16 @@ export function activate(context: ExtensionContext) {
|
|||||||
|
|
||||||
// Start the client. This will also launch the server
|
// Start the client. This will also launch the server
|
||||||
client.start();
|
client.start();
|
||||||
|
|
||||||
|
const workspaceRoot = (workspace.workspaceFolders && (workspace.workspaceFolders.length > 0))
|
||||||
|
? workspace.workspaceFolders[0].uri.fsPath : undefined;
|
||||||
|
bfRunTaskProvider = tasks.registerTaskProvider(CustomExecutionTaskProvider.type, new CustomExecutionTaskProvider(workspaceRoot, undefined));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deactivate(): Thenable<void> | undefined {
|
export function deactivate(): Thenable<void> | undefined {
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return client.stop();
|
bfRunTaskProvider?.dispose();
|
||||||
|
client?.stop();
|
||||||
}
|
}
|
||||||
|
@@ -2,15 +2,44 @@ import path = require('node:path');
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
|
||||||
export class CustomExecutionTaskProvider implements vscode.TaskProvider{
|
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){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
provideTasks(token?: vscode.CancellationToken): vscode.ProviderResult<vscode.Task[]> {
|
provideTasks(token?: vscode.CancellationToken): vscode.ProviderResult<vscode.Task[]> {
|
||||||
throw new Error('Method not implemented.');
|
if (this.tasks !== undefined) { return this.tasks; }
|
||||||
|
|
||||||
|
const types: BFRunTaskDefinition['type'][] = ['current'];
|
||||||
|
this.tasks = [];
|
||||||
|
types.forEach(e=>
|
||||||
|
this.tasks.push(this.getTaskFromDefinition(e))
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
resolveTask(task: vscode.Task, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.Task> {
|
getTaskFromDefinition(e: string): vscode.Task {
|
||||||
const taskDefinition = {};
|
const definition:BFRunTaskDefinition = {
|
||||||
throw new Error('5');
|
type: 'current',
|
||||||
// return new vscode.Task()
|
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 {
|
class CustomBuildTaskTerminal implements vscode.Pseudoterminal {
|
||||||
private writeEmitter = new vscode.EventEmitter<string>();
|
private writeEmitter = new vscode.EventEmitter<string>();
|
||||||
onDidWrite: vscode.Event<string> = this.writeEmitter.event;
|
|
||||||
private closeEmitter = new vscode.EventEmitter<number>();
|
private closeEmitter = new vscode.EventEmitter<number>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
onDidWrite: vscode.Event<string> = this.writeEmitter.event;
|
||||||
onDidClose?: vscode.Event<number> = this.closeEmitter.event;
|
onDidClose?: vscode.Event<number> = this.closeEmitter.event;
|
||||||
|
|
||||||
private fileWatcher: vscode.FileSystemWatcher | undefined;
|
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 {
|
open(initialDimensions: vscode.TerminalDimensions | undefined): void {
|
||||||
// At this point we can start using the terminal.
|
// 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();
|
this.doBuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,26 +74,10 @@ class CustomBuildTaskTerminal implements vscode.Pseudoterminal {
|
|||||||
private async doBuild(): Promise<void> {
|
private async doBuild(): Promise<void> {
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
this.writeEmitter.fire('Starting build...\r\n');
|
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.
|
// Since we don't actually build anything in this example set a timeout instead.
|
||||||
setTimeout(() => {
|
this.writeEmitter.fire('Build complete.\r\n\r\n');
|
||||||
const date = new Date();
|
this.closeEmitter.fire(0);
|
||||||
this.setSharedState(date.toTimeString() + ' ' + date.toDateString());
|
resolve();
|
||||||
this.writeEmitter.fire('Build complete.\r\n\r\n');
|
|
||||||
if (this.flags.indexOf('watch') === -1) {
|
|
||||||
this.closeEmitter.fire(0);
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
}, isIncremental ? 1000 : 4000);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
7592
package-lock.json
generated
7592
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/chrisvrose/bf-server"
|
"url": "https://github.com/chrisvrose/bf-server"
|
||||||
},
|
},
|
||||||
"main": "./client/dist/extension",
|
"main": "./client/dist/extension.js",
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"languages": [
|
"languages": [
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user