staticanalysis

pull/3094/head
yann300 7 years ago
parent e6934964ca
commit 5526d98c5e
  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'})
// ----------------- 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 --------------------

@ -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

@ -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`<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() === '') {

@ -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)
}
})

Loading…
Cancel
Save