From b612cd9eaac7a9a6d66da13a56c5e503254aa32c Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 27 Jun 2018 17:31:56 +0200 Subject: [PATCH] staticanalysis --- src/app.js | 11 +-------- src/app/panels/righthand-panel.js | 25 +++++++++++++------- src/app/staticanalysis/staticAnalysisView.js | 21 +++++++++++----- src/app/tabs/compile-tab.js | 6 +++-- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/app.js b/src/app.js index ca2ab93055..b319001302 100644 --- a/src/app.js +++ b/src/app.js @@ -573,16 +573,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org registry.put({api: renderer, name: 'renderer'}) // ----------------- StaticAnalysis ----------------- - - var staticAnalysisAPI = { - renderWarning: (label, warningContainer, type) => { - return renderer.error(label, warningContainer, type) - }, - offsetToLineColumn: (location, file) => { - return offsetToLineColumnConverter.offsetToLineColumn(location, file, compiler.lastCompilationResult) - } - } - var staticanalysis = new StaticAnalysis(staticAnalysisAPI, compiler.event) + var staticanalysis = new StaticAnalysis() registry.put({api: staticanalysis, name: 'staticanalysis'}) // ---------------- Righthand-panel -------------------- diff --git a/src/app/panels/righthand-panel.js b/src/app/panels/righthand-panel.js index dbdd6baa71..c93c8902bb 100644 --- a/src/app/panels/righthand-panel.js +++ b/src/app/panels/righthand-panel.js @@ -32,16 +32,18 @@ module.exports = class RighthandPanel { dragbar: null } + self._components.registry.put({api: this, name: 'righthandpanel'}) + self._components = { - pluginManager: new PluginManager(), - tabbedMenu: new TabbedMenu(), - compile: new CompileTab(), - run: new RunTab(), - settings: new SettingsTab(), - analysis: new AnalysisTab(), - debug: new DebuggerTab(), - support: new SupportTab(), - test: new TestTab() + pluginManager: new PluginManager(self._components.registry), + tabbedMenu: new TabbedMenu(self._components.registry), + compile: new CompileTab(self._components.registry), + run: new RunTab(self._components.registry), + settings: new SettingsTab(self._components.registry), + analysis: new AnalysisTab(self._components.registry), + debug: new DebuggerTab(self._components.registry), + support: new SupportTab(self._components.registry), + test: new TestTab(self._components.registry) } self.event.register('plugin-loadRequest', json => { @@ -81,6 +83,11 @@ module.exports = class RighthandPanel { if (self._view.element) return self._view.element return self._view.element } + + focusOn (x) { + if (this._components.tabbedMenu) this._components.tabbedMenu.selectTabByClassName(x) + } + init () { // @TODO: init is for resizable drag bar only and should be refactored in the future const self = this diff --git a/src/app/staticanalysis/staticAnalysisView.js b/src/app/staticanalysis/staticAnalysisView.js index 174c5e37a0..ac2419d5f0 100644 --- a/src/app/staticanalysis/staticAnalysisView.js +++ b/src/app/staticanalysis/staticAnalysisView.js @@ -9,18 +9,27 @@ var styleGuide = require('../ui/styles-guide/theme-chooser') var styles = styleGuide.chooser() var css = require('./styles/staticAnalysisView-styles') +var globlalRegistry = require('../../global/registry') var EventManager = remixLib.EventManager -function staticAnalysisView (appAPI, compilerEvent) { +function staticAnalysisView (localRegistry) { + var self = this this.event = new EventManager() this.view = null - this.appAPI = appAPI this.runner = new StaticAnalysisRunner() this.modulesView = renderModules(this.runner.modules()) this.lastCompilationResult = null - var self = this - compilerEvent.register('compilationFinished', function (success, data, source) { + self._components = {} + self._components.registry = localRegistry || globlalRegistry + // dependencies + self._deps = { + compiler: self._components.registry.get('compiler').api, + renderer: self._components.registry.get('renderer').api, + offsetToLineColumnConverter: self._components.registry.get('offsetToLineColumnConverter').api + } + + self._deps.compiler.event.register('compilationFinished', function (success, data, source) { self.lastCompilationResult = null $('#staticanalysisresult').empty() if (success) { @@ -85,12 +94,12 @@ staticAnalysisView.prototype.run = function () { start: parseInt(split[0]), length: parseInt(split[1]) } - location = self.appAPI.offsetToLineColumn(location, file) + location = self._deps.offsetToLineColumnConverter.offsetToLineColumn(location, file) location = Object.keys(self.lastCompilationResult.contracts)[file] + ':' + (location.start.line + 1) + ':' + (location.start.column + 1) + ':' } warningCount++ var msg = yo`${location} ${item.warning} ${item.more ? yo`
more
` : yo``}
` - self.appAPI.renderWarning(msg, warningContainer, {type: 'staticAnalysisWarning', useSpan: true}) + self._deps.renderer.error(msg, warningContainer, {type: 'staticAnalysisWarning', useSpan: true}) }) }) if (warningContainer.html() === '') { diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index e8d228d781..a888263a51 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -40,7 +40,9 @@ module.exports = class CompileTab { compiler: self._components.registry.get('compiler').api, staticAnalysis: self._components.registry.get('staticanalysis').api, renderer: self._components.registry.get('renderer').api, - transactionContextAPI: self._components.registry.get('transactionContextAPI').api + fileManager: self._components.registry.get('filemanager').api, + transactionContextAPI: self._components.registry.get('transactionContextAPI').api, + rightHandPanel: self._components.registry.get('righthandpanel').api } self.data = { hideWarnings: self._deps.config.get('hideWarnings') || false, @@ -148,7 +150,7 @@ module.exports = class CompileTab { self._deps.staticAnalysis.event.register('staticAnaysisWarning', (count) => { if (count) { const msg = `Static Analysis raised ${count} warning(s) that requires your attention. Click here to show the warning(s).` - const settings = { type: 'staticAnalysisWarning', click: () => self._api.switchTab('staticanalysisView'), useSpan: true } + const settings = { type: 'staticAnalysisWarning', click: () => self._deps.rightHandPanel.focusOn('staticanalysisView'), useSpan: true } self._deps.renderer.error(msg, self._view.errorContainer, settings) } })