staticanalysis

pull/3094/head
yann300 7 years ago
parent 473a31f59f
commit b612cd9eaa
  1. 11
      src/app.js
  2. 25
      src/app/panels/righthand-panel.js
  3. 21
      src/app/staticanalysis/staticAnalysisView.js
  4. 6
      src/app/tabs/compile-tab.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'}) registry.put({api: renderer, name: 'renderer'})
// ----------------- StaticAnalysis ----------------- // ----------------- StaticAnalysis -----------------
var staticanalysis = new 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)
registry.put({api: staticanalysis, name: 'staticanalysis'}) registry.put({api: staticanalysis, name: 'staticanalysis'})
// ---------------- Righthand-panel -------------------- // ---------------- Righthand-panel --------------------

@ -32,16 +32,18 @@ module.exports = class RighthandPanel {
dragbar: null dragbar: null
} }
self._components.registry.put({api: this, name: 'righthandpanel'})
self._components = { self._components = {
pluginManager: new PluginManager(), pluginManager: new PluginManager(self._components.registry),
tabbedMenu: new TabbedMenu(), tabbedMenu: new TabbedMenu(self._components.registry),
compile: new CompileTab(), compile: new CompileTab(self._components.registry),
run: new RunTab(), run: new RunTab(self._components.registry),
settings: new SettingsTab(), settings: new SettingsTab(self._components.registry),
analysis: new AnalysisTab(), analysis: new AnalysisTab(self._components.registry),
debug: new DebuggerTab(), debug: new DebuggerTab(self._components.registry),
support: new SupportTab(), support: new SupportTab(self._components.registry),
test: new TestTab() test: new TestTab(self._components.registry)
} }
self.event.register('plugin-loadRequest', json => { self.event.register('plugin-loadRequest', json => {
@ -81,6 +83,11 @@ module.exports = class RighthandPanel {
if (self._view.element) return self._view.element if (self._view.element) return self._view.element
return self._view.element return self._view.element
} }
focusOn (x) {
if (this._components.tabbedMenu) this._components.tabbedMenu.selectTabByClassName(x)
}
init () { init () {
// @TODO: init is for resizable drag bar only and should be refactored in the future // @TODO: init is for resizable drag bar only and should be refactored in the future
const self = this const self = this

@ -9,18 +9,27 @@ var styleGuide = require('../ui/styles-guide/theme-chooser')
var styles = styleGuide.chooser() var styles = styleGuide.chooser()
var css = require('./styles/staticAnalysisView-styles') var css = require('./styles/staticAnalysisView-styles')
var globlalRegistry = require('../../global/registry')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
function staticAnalysisView (appAPI, compilerEvent) { function staticAnalysisView (localRegistry) {
var self = this
this.event = new EventManager() this.event = new EventManager()
this.view = null this.view = null
this.appAPI = appAPI
this.runner = new StaticAnalysisRunner() this.runner = new StaticAnalysisRunner()
this.modulesView = renderModules(this.runner.modules()) this.modulesView = renderModules(this.runner.modules())
this.lastCompilationResult = null this.lastCompilationResult = null
var self = this self._components = {}
compilerEvent.register('compilationFinished', function (success, data, source) { 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 self.lastCompilationResult = null
$('#staticanalysisresult').empty() $('#staticanalysisresult').empty()
if (success) { if (success) {
@ -85,12 +94,12 @@ staticAnalysisView.prototype.run = function () {
start: parseInt(split[0]), start: parseInt(split[0]),
length: parseInt(split[1]) 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) + ':' location = Object.keys(self.lastCompilationResult.contracts)[file] + ':' + (location.start.line + 1) + ':' + (location.start.column + 1) + ':'
} }
warningCount++ warningCount++
var msg = yo`<span>${location} ${item.warning} ${item.more ? yo`<span><br><a href="${item.more}" target="blank">more</a></span>` : yo`<span></span>`}</span>` var msg = yo`<span>${location} ${item.warning} ${item.more ? yo`<span><br><a href="${item.more}" target="blank">more</a></span>` : yo`<span></span>`}</span>`
self.appAPI.renderWarning(msg, warningContainer, {type: 'staticAnalysisWarning', useSpan: true}) self._deps.renderer.error(msg, warningContainer, {type: 'staticAnalysisWarning', useSpan: true})
}) })
}) })
if (warningContainer.html() === '') { if (warningContainer.html() === '') {

@ -40,7 +40,9 @@ module.exports = class CompileTab {
compiler: self._components.registry.get('compiler').api, compiler: self._components.registry.get('compiler').api,
staticAnalysis: self._components.registry.get('staticanalysis').api, staticAnalysis: self._components.registry.get('staticanalysis').api,
renderer: self._components.registry.get('renderer').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 = { self.data = {
hideWarnings: self._deps.config.get('hideWarnings') || false, hideWarnings: self._deps.config.get('hideWarnings') || false,
@ -148,7 +150,7 @@ module.exports = class CompileTab {
self._deps.staticAnalysis.event.register('staticAnaysisWarning', (count) => { self._deps.staticAnalysis.event.register('staticAnaysisWarning', (count) => {
if (count) { if (count) {
const msg = `Static Analysis raised ${count} warning(s) that requires your attention. Click here to show the warning(s).` 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) self._deps.renderer.error(msg, self._view.errorContainer, settings)
} }
}) })

Loading…
Cancel
Save