From b3fdafee17a5cddfe9da601f95fb4e43e7dbbe8f Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 19 Feb 2019 16:08:20 -0500 Subject: [PATCH] refactor compile tab --- src/app.js | 10 ++++++++- src/app/tabs/analysis-tab.js | 3 +++ src/app/tabs/compile-tab.js | 41 ++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/app.js b/src/app.js index 67d019122d..9ca8c69923 100644 --- a/src/app.js +++ b/src/app.js @@ -432,7 +432,15 @@ Please make a backup of your contracts and start using http://remix.ethereum.org let filePanel = new FilePanel() registry.put({api: filePanel, name: 'filepanel'}) - let compileTab = new CompileTab(registry) + let compileTab = new CompileTab( + registry.get('editor').api, + registry.get('config').api, + registry.get('renderer').api, + registry.get('fileproviders/swarm').api, + registry.get('filemanager').api, + registry.get('fileproviders').api, + registry.get('pluginmanager').api + ) let run = new RunTab( registry.get('udapp').api, registry.get('udappUI').api, diff --git a/src/app/tabs/analysis-tab.js b/src/app/tabs/analysis-tab.js index 68e78afd87..390082c84c 100644 --- a/src/app/tabs/analysis-tab.js +++ b/src/app/tabs/analysis-tab.js @@ -12,6 +12,7 @@ class AnalysisTab extends ApiFactory { this.event = new EventManager() this.registry = registry } + get profile () { return { name: 'solidityStaticAnalysis', @@ -23,6 +24,7 @@ class AnalysisTab extends ApiFactory { kind: 'analysis' } } + render () { var staticanalysis = new StaticAnalysis() this.registry.put({api: staticanalysis, name: 'staticanalysis'}) @@ -31,6 +33,7 @@ class AnalysisTab extends ApiFactory { this.el = yo`
${staticanalysis.render()}
` return this.el } + } module.exports = AnalysisTab diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index 88c1e1d5ff..677516c52a 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -21,7 +21,7 @@ import { ApiFactory } from 'remix-plugin' class CompileTab extends ApiFactory { - constructor (registry) { + constructor (editor, config, renderer, swarmfileProvider, fileManager, fileProviders, pluginManager) { super() this.events = new EventEmitter() this._view = { @@ -34,27 +34,26 @@ class CompileTab extends ApiFactory { this.queryParams = new QueryParams() // dependencies - this._deps = { - editor: registry.get('editor').api, - config: registry.get('config').api, - renderer: registry.get('renderer').api, - swarmfileProvider: registry.get('fileproviders/swarm').api, - fileManager: registry.get('filemanager').api, - fileProviders: registry.get('fileproviders').api, - pluginManager: registry.get('pluginmanager').api - } + this.editor = editor + this.config = config + this.renderer = renderer + this.swarmfileProvider = swarmfileProvider + this.fileManager = fileManager + this.fileProviders = fileProviders + this.pluginManager = pluginManager + this.data = { contractsDetails: {} } - this.compileTabLogic = new CompileTabLogic(this.queryParams, this._deps.fileManager, this._deps.editor, this._deps.config, this._deps.fileProviders) + this.compileTabLogic = new CompileTabLogic(this.queryParams, this.fileManager, this.editor, this.config, this.fileProviders) this.compiler = this.compileTabLogic.compiler this.compileTabLogic.init() this.compilerContainer = new CompilerContainer( this.compileTabLogic, - this._deps.editor, - this._deps.config, + this.editor, + this.config, this.queryParams ) } @@ -82,7 +81,7 @@ class CompileTab extends ApiFactory { } }) - this._deps.fileManager.events.on('currentFileChanged', (name) => { + this.fileManager.events.on('currentFileChanged', (name) => { this.compilerContainer.currentFile = name }) this.compiler.event.register('compilationFinished', (success, data, source) => { @@ -106,7 +105,7 @@ class CompileTab extends ApiFactory { yo.update(this._view.contractSelection, contractSelection) if (data['error']) { - this._deps.renderer.error(data['error'].formattedMessage, this._view.errorContainer, {type: data['error'].severity || 'error'}) + this.renderer.error(data['error'].formattedMessage, this._view.errorContainer, {type: data['error'].severity || 'error'}) if (data['error'].mode === 'panic') { return modalDialogCustom.alert(yo`
The compiler returned with the following internal error:
${data['error'].formattedMessage}.
@@ -117,12 +116,12 @@ class CompileTab extends ApiFactory { } if (data.errors && data.errors.length) { data.errors.forEach((err) => { - if (this._deps.config.get('hideWarnings')) { + if (this.config.get('hideWarnings')) { if (err.severity !== 'warning') { - this._deps.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity}) + this.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity}) } } else { - this._deps.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity}) + this.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity}) } }) } @@ -215,7 +214,7 @@ class CompileTab extends ApiFactory { if (contract.metadata === undefined || contract.metadata.length === 0) { modalDialogCustom.alert('This contract may be abstract, may not implement an abstract parent\'s methods completely or not invoke an inherited contract\'s constructor correctly.') } else { - publishOnSwarm(contract, this._deps.fileManager, function (err, uploaded) { + publishOnSwarm(contract, this.fileManager, function (err, uploaded) { if (err) { try { err = JSON.stringify(err) @@ -229,7 +228,7 @@ class CompileTab extends ApiFactory { modalDialogCustom.alert(yo`Metadata published successfully.
${result}
`) } }, (item) => { // triggered each time there's a new verified publish (means hash correspond) - this._deps.swarmfileProvider.addReadOnly(item.hash, item.content) + this.swarmfileProvider.addReadOnly(item.hash, item.content) }) } } @@ -339,7 +338,7 @@ class CompileTab extends ApiFactory { this._view.errorContainer = yo`
` this._view.contractSelection = this.contractSelection() this._view.compilerContainer = this.compilerContainer.render() - const currentFile = this._deps.fileManager.currentFile() + const currentFile = this.fileManager.currentFile() if (currentFile) this.compilerContainer.currentFile = currentFile this._view.el = yo`