@@ -4,15 +4,13 @@ import { URI, Utils } from 'vscode-uri';
44import Script from './Script' ;
55import native from './native.au3?raw' ;
66import { isAbsolutePath } from './Path' ;
7+ import EventEmitter from '@utils/EventEmitter' ;
78
89/** The key is the script URI */
910export type ScriptList = Map < string , Script > ;
1011
1112type uri = string | URI | { toString : ( ) => string } ;
1213
13- export type diagnosticsListner = (
14- uri : string , diagnostics : Diagnostic [ ] ) => void ;
15-
1614export type IncludeResolve = { uri : URI , text : string | null } ;
1715
1816export type IncludePromise = Promise < IncludeResolve | null > ;
@@ -35,8 +33,8 @@ export class Workspace {
3533 protected scripts : ScriptList = new Map ( ) ;
3634 protected resolvingIncludes = new Map < string , IncludePromise > ( ) ;
3735 protected connection : Connection | null ;
38- protected diagnosticsListners : diagnosticsListner [ ] = [ ] ;
3936 protected configuration : AutoIt3Configuration | null = null ;
37+ public readonly eventEmitter : EventEmitter < { diagnostics : { uri : string , diagnostics : Diagnostic [ ] } } > = new EventEmitter ( ) ;
4038
4139 constructor ( connection : Connection | null = null ) {
4240 this . connection = connection ;
@@ -60,25 +58,6 @@ export class Workspace {
6058 return this . connection ;
6159 }
6260
63- public onDiagnostics ( fn : diagnosticsListner ) : void {
64- this . diagnosticsListners . push ( fn ) ;
65- }
66-
67- /**
68- * function for removing a diagnostics listner
69- */
70- public offDiagnostics ( fn : diagnosticsListner ) : void {
71- this . diagnosticsListners = this . diagnosticsListners . filter (
72- ( x ) => x !== fn ,
73- ) ;
74- }
75-
76- public triggerDiagnostics ( uri : string , diagnostics : Diagnostic [ ] ) : void {
77- for ( const fn of this . diagnosticsListners ) {
78- fn . call ( this , uri , diagnostics ) ;
79- }
80- }
81-
8261 public add ( script : Script ) : void {
8362 const uri = script . getUri ( ) ;
8463
0 commit comments