From 4f932c9748b043ad7630484c3698b43065de21cb Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 18 May 2021 16:31:47 +0200 Subject: [PATCH] make compileTabLogic a plugin --- apps/remix-ide/src/app.js | 1 + apps/remix-ide/src/app/tabs/compile-tab.js | 9 +++------ .../src/app/tabs/compileTab/compileTab.js | 19 ++++++++++++++----- apps/remix-ide/src/remixAppManager.js | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index a22f388004..93dd6753b5 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -431,6 +431,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org engine.register([ compileTab, + compileTab.compileTabLogic, run, debug, analysis, diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index fe49f60037..400ef25d76 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -65,15 +65,10 @@ class CompileTab extends ViewPlugin { eventHandlers: {}, loading: false } + this.compileTabLogic = new CompileTabLogic(this.queryParams, this.fileManager, this.editor, this.config, this.fileProvider, this.contentImport) } onActivationInternal () { - const miscApi = { - clearAnnotations: () => { - this.call('editor', 'clearAnnotations') - } - } - this.compileTabLogic = new CompileTabLogic(this.queryParams, this.fileManager, this.editor, this.config, this.fileProvider, this.contentImport, miscApi) this.compiler = this.compileTabLogic.compiler this.compileTabLogic.init() @@ -486,6 +481,7 @@ class CompileTab extends ViewPlugin { } onActivation () { + this.call('manager', 'activatePlugin', 'solidity-logic') this.listenToEvents() } @@ -499,6 +495,7 @@ class CompileTab extends ViewPlugin { this.fileManager.events.removeListener('noFileSelected', this.data.eventHandlers.onNoFileSelected) this.compiler.event.unregister('compilationFinished', this.data.eventHandlers.onCompilationFinished) globalRegistry.get('themeModule').api.events.removeListener('themeChanged', this.data.eventHandlers.onThemeChanged) + this.call('manager', 'deactivatePlugin', 'solidity-logic') } } diff --git a/apps/remix-ide/src/app/tabs/compileTab/compileTab.js b/apps/remix-ide/src/app/tabs/compileTab/compileTab.js index a3010dbc2d..d5b1168b93 100644 --- a/apps/remix-ide/src/app/tabs/compileTab/compileTab.js +++ b/apps/remix-ide/src/app/tabs/compileTab/compileTab.js @@ -1,10 +1,19 @@ const EventEmitter = require('events') var Compiler = require('@remix-project/remix-solidity').Compiler +import * as packageJson from '../../../../../../package.json' +import { Plugin } from '@remixproject/engine' -class CompileTab { - constructor (queryParams, fileManager, editor, config, fileProvider, contentImport, miscApi) { +const profile = { + name: 'solidity-logic', + displayName: 'Solidity compiler logic', + description: 'Compile solidity contracts - Logic', + version: packageJson.version +} + +class CompileTab extends Plugin { + constructor (queryParams, fileManager, editor, config, fileProvider, contentImport) { + super(profile) this.event = new EventEmitter() - this.miscApi = miscApi this.queryParams = queryParams this.compilerImport = contentImport this.compiler = new Compiler((url, cb) => this.compilerImport.resolveAndSave(url).then((result) => cb(null, result)).catch((error) => cb(error.message))) @@ -100,10 +109,10 @@ class CompileTab { ` const configFilePath = 'remix-compiler.config.js' this.fileManager.setFileContent(configFilePath, fileContent) - this.fileManager.call('hardhat', 'compile', configFilePath) + this.call('hardhat', 'compile', configFilePath) } this.fileManager.saveCurrentFile() - this.miscApi.clearAnnotations() + this.call('editor', 'clearAnnotations') var currentFile = this.config.get('currentFile') return this.compileFile(currentFile) } catch (err) { diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 650a87b14d..7e7f9cd10f 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -14,7 +14,7 @@ const requiredModules = [ // services + layout views + system views const dependentModules = ['git', 'hardhat'] // module which shouldn't be manually activated (e.g git is activated by remixd) export function isNative (name) { - const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons'] + const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity'] return nativePlugins.includes(name) || requiredModules.includes(name) }