From 5dd8396ce6602bec234d0c70e182e696be9d4c38 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 3 Dec 2018 15:28:59 +0100 Subject: [PATCH] move runCompiler to compile tab --- src/app.js | 39 +--------------------------------- src/app/tabs/compile-tab.js | 42 +++++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/src/app.js b/src/app.js index 62eab60020..19c6afc57c 100644 --- a/src/app.js +++ b/src/app.js @@ -226,35 +226,7 @@ class App { self._adjustLayout('left', self.data._layout.left.offset) self._adjustLayout('right', self.data._layout.right.offset) return self._view.el - } - runCompiler () { - const self = this - if (self._components.righthandpanel.debugger().isDebuggerActive()) return - - self._components.fileManager.saveCurrentFile() - self._components.editorpanel.getEditor().clearAnnotations() - var currentFile = self._components.config.get('currentFile') - if (currentFile) { - if (/.(.sol)$/.exec(currentFile)) { - // only compile *.sol file. - var target = currentFile - var sources = {} - var provider = self._components.fileManager.fileProviderOf(currentFile) - if (provider) { - provider.get(target, (error, content) => { - if (error) { - console.log(error) - } else { - sources[target] = { content } - self._components.compiler.compile(sources, target) - } - }) - } else { - console.log('cannot compile ' + currentFile + '. Does not belong to any explorer') - } - } - } - } + } startdebugging (txHash) { const self = this self.event.trigger('debuggingRequested', []) @@ -376,15 +348,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org return 'Are you sure you want to leave?' } - // Run the compiler instead of trying to save the website - $(window).keydown(function (e) { - // ctrl+s or command+s - if ((e.metaKey || e.ctrlKey) && e.keyCode === 83) { - e.preventDefault() - self.runCompiler() - } - }) - registry.put({api: msg => self._components.editorpanel.logHtmlMessage(msg), name: 'logCallback'}) // ----------------- Compiler ----------------- diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index 7e4b7e5a6e..9c155693b8 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -42,7 +42,6 @@ module.exports = class CompileTab { self._components.queryParams = new QueryParams() // dependencies self._deps = { - app: self._components.registry.get('app').api, editor: self._components.registry.get('editor').api, config: self._components.registry.get('config').api, compiler: self._components.registry.get('compiler').api, @@ -71,7 +70,7 @@ module.exports = class CompileTab { function scheduleCompilation () { if (!self._deps.config.get('autoCompile')) return if (self.data.compileTimeout) window.clearTimeout(self.data.compileTimeout) - self.data.compileTimeout = window.setTimeout(() => self._deps.app.runCompiler(), self.data.timeout) + self.data.compileTimeout = window.setTimeout(() => self.runCompiler(), self.data.timeout) } self._deps.compiler.event.register('compilationDuration', function tabHighlighting (speed) { if (!self._view.warnCompilationSlow) return @@ -165,6 +164,15 @@ module.exports = class CompileTab { }) } }) + + // Run the compiler instead of trying to save the website + $(window).keydown(function (e) { + // ctrl+s or command+s + if ((e.metaKey || e.ctrlKey) && e.keyCode === 83) { + e.preventDefault() + self.runCompiler() + } + }) } addWarning (msg, settings) { const self = this @@ -183,7 +191,7 @@ module.exports = class CompileTab { self.data.optimize = !!self._view.optimize.checked self._components.queryParams.update({ optimize: self.data.optimize }) self._deps.compiler.setOptimize(self.data.optimize) - self._deps.app.runCompiler() + self.runCompiler() } self._deps.compiler.event.register('compilerLoaded', (version) => self.setVersionText(version)) @@ -279,7 +287,7 @@ module.exports = class CompileTab { 'web3Deploy': 'Copy/paste this code to any JavaScript/Web3 console to deploy this contract' } function updateAutoCompile (event) { self._deps.config.set('autoCompile', self._view.autoCompile.checked) } - function compile (event) { self._deps.app.runCompiler() } + function compile (event) { self.runCompiler() } function hideWarnings (event) { self._deps.config.set('hideWarnings', self._view.hideWarningsBox.checked) compile() @@ -452,6 +460,32 @@ module.exports = class CompileTab { callback(allversions, selectedVersion) }) } + runCompiler () { + const self = this + self._deps.fileManager.saveCurrentFile() + self._deps.editor.clearAnnotations() + var currentFile = self._deps.config.get('currentFile') + if (currentFile) { + if (/.(.sol)$/.exec(currentFile)) { + // only compile *.sol file. + var target = currentFile + var sources = {} + var provider = self._deps.fileManager.fileProviderOf(currentFile) + if (provider) { + provider.get(target, (error, content) => { + if (error) { + console.log(error) + } else { + sources[target] = { content } + self.compiler.compile(sources, target) + } + }) + } else { + console.log('cannot compile ' + currentFile + '. Does not belong to any explorer') + } + } + } + } } const css = csjs`