Skip to content

Instantly share code, notes, and snippets.

@amazzalel-habib
Last active May 12, 2020 03:26
Show Gist options
  • Save amazzalel-habib/cbc17b662a5241d3f1378803aa96de0a to your computer and use it in GitHub Desktop.
Save amazzalel-habib/cbc17b662a5241d3f1378803aa96de0a to your computer and use it in GitHub Desktop.
import * as monaco from "monaco-editor-core";
import IWorkerContext = monaco.worker.IWorkerContext;
import TodoLangLanguageService from "../language-service/LanguageService";
import { ITodoLangError } from "../language-service/TodoLangErrorListener";
export class TodoLangWorker {
private _ctx: IWorkerContext;
private languageService: TodoLangLanguageService;
constructor(ctx: IWorkerContext) {
this._ctx = ctx;
this.languageService = new TodoLangLanguageService();
}
doValidation(): Promise<ITodoLangError[]> {
const code = this.getTextDocument();
return Promise.resolve(this.languageService.validate(code));
}
private getTextDocument(): string {
const model = this._ctx.getMirrorModels()[0];// When there are multiple files open, this will be an array
return model.getValue();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment