public override void Initialize(IApp app) { base.Initialize(app); Compilers.ForEach(b => { if (b.Type.GetInterface(typeof(IBackgroundCompiler).Name) == null) { throw new ElideException("Compiler '{0}' doesn't implement IBackgroundCompiler interface.", b.Type); } var bc = TypeCreator.New <IBackgroundCompiler>(b.Type); var inf = (EditorInfo)app.GetService <IEditorService>().GetInfo("editors", b.EditorKey); var ins = inf.Instance as ICodeEditor; if (ins == null) { throw new ElideException("Compiler '{0}' can be only registered for the code editor.", b.Type); } var sci = ins.Control as ScintillaControl; var wrap = new BackgroundCompiler(app, sci, bc, this); CompilerInstances.Add(b.EditorKey, wrap); }); app.GetService <IDaemonService>().RegisterDaemon(this); app.GetService <IDocumentService>().DocumentAdded += (_, e) => DocumentOpened(e.Document); }
public void Execute() { var doc = App.Document() as CodeDocument; var wrap = default(BackgroundCompiler); if (doc != null && doc.UnitVersion != doc.Version && CompilerInstances.TryGetValue(doc.CodeEditor.Key, out wrap) && EnableBackgroundCompilation) { wrap.Compile(doc); } }
private void DocumentOpened(Document doc) { var inf = App.EditorInfo(doc); var wrap = default(BackgroundCompiler); if (inf.Instance is ICodeEditor && CompilerInstances.TryGetValue(inf.Key, out wrap) && EnableBackgroundCompilation) { wrap.CompileAlways((CodeDocument)doc); } }