From e66a8258db88c2300223eb22822d3938c287865a Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Thu, 14 Mar 2019 18:20:33 +0100 Subject: [PATCH] switch async exposed method to sync is possible --- src/app/editor/SourceHighlighters.js | 32 +++++++++++----------------- src/app/tabs/compile-tab.js | 14 +++--------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/app/editor/SourceHighlighters.js b/src/app/editor/SourceHighlighters.js index 5d69060a8c..85c69e2537 100644 --- a/src/app/editor/SourceHighlighters.js +++ b/src/app/editor/SourceHighlighters.js @@ -19,27 +19,21 @@ class SourceHighlighters extends ApiFactory { } } - // TODO what to do with mod? - async highlight (mod, lineColumnPos, filePath, hexColor) { - return new Promise((resolve, reject) => { - let position - try { - position = JSON.parse(lineColumnPos) - } catch (e) { - throw e - } - if (!this.highlighters[mod]) this.highlighters[mod] = new SourceHighlighter() - this.highlighters[mod].currentSourceLocation(null) - this.highlighters[mod].currentSourceLocationFromfileName(position, filePath, hexColor) - resolve() - }) + highlight (lineColumnPos, filePath, hexColor) { + const { from } = this.currentRequest + try { + const position = JSON.parse(lineColumnPos) + if (!this.highlighters[from]) this.highlighters[from] = new SourceHighlighter() + this.highlighters[from].currentSourceLocation(null) + this.highlighters[from].currentSourceLocationFromfileName(position, filePath, hexColor) + } catch (e) { + throw e + } } - async discardHighlight (mod) { - return new Promise((resolve, reject) => { - if (this.highlighters[mod]) this.highlighters[mod].currentSourceLocation(null) - resolve() - }) + discardHighlight () { + const { from } = this.currentRequest + if (this.highlighters[from]) this.highlighters[from].currentSourceLocation(null) } } diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index 7fececee29..88c1e1d5ff 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -71,14 +71,6 @@ class CompileTab extends ApiFactory { } } - activate () { - this.listenToEvents() - this.compilerContainer.activate() - } - - deactivate () { - } - /************ * EVENTS */ @@ -147,9 +139,7 @@ class CompileTab extends ApiFactory { } getCompilationResult () { - return new Promise((resolve, reject) => { - resolve(this.compileTabLogic.compiler.lastCompilationResult) - }) + return this.compileTabLogic.compiler.lastCompilationResult } /********* @@ -343,6 +333,8 @@ class CompileTab extends ApiFactory { render () { if (this._view.el) return this._view.el + this.listenToEvents() + this.compilerContainer.activate() this._view.errorContainer = yo`
` this._view.contractSelection = this.contractSelection()