|
|
|
@ -1,10 +1,10 @@ |
|
|
|
|
import React from 'react' // eslint-disable-line
|
|
|
|
|
import { ViewPlugin } from '@remixproject/engine-web' |
|
|
|
|
import ReactDOM from 'react-dom' |
|
|
|
|
import { EventEmitter } from 'events' |
|
|
|
|
import {RemixUiStaticAnalyser} from '@remix-ui/static-analyser' // eslint-disable-line
|
|
|
|
|
import * as packageJson from '../../../../../package.json' |
|
|
|
|
import Registry from '../state/registry' |
|
|
|
|
import { ViewPluginUI } from '../components/ViewPluginUI' |
|
|
|
|
|
|
|
|
|
var EventManager = require('../../lib/events') |
|
|
|
|
|
|
|
|
@ -35,6 +35,7 @@ class AnalysisTab extends ViewPlugin { |
|
|
|
|
offsetToLineColumnConverter: this.registry.get( |
|
|
|
|
'offsettolinecolumnconverter').api |
|
|
|
|
} |
|
|
|
|
this.dispatch = null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async onActivation () { |
|
|
|
@ -43,33 +44,40 @@ class AnalysisTab extends ViewPlugin { |
|
|
|
|
await this.call('manager', 'activatePlugin', 'solidity') |
|
|
|
|
} |
|
|
|
|
this.renderComponent() |
|
|
|
|
this.event.register('staticAnaysisWarning', (count) => { |
|
|
|
|
if (count > 0) { |
|
|
|
|
this.emit('statusChanged', { key: count, title: `${count} warning${count === 1 ? '' : 's'}`, type: 'warning' }) |
|
|
|
|
} else if (count === 0) { |
|
|
|
|
this.emit('statusChanged', { key: 'succeed', title: 'no warning', type: 'success' }) |
|
|
|
|
} else { |
|
|
|
|
// count ==-1 no compilation result
|
|
|
|
|
this.emit('statusChanged', { key: 'none' }) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setDispatch (dispatch) { |
|
|
|
|
this.dispatch = dispatch |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
|
return this.element |
|
|
|
|
return <div id='staticAnalyserView'><ViewPluginUI plugin={this} /></div> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
updateComponent(state) { |
|
|
|
|
return <RemixUiStaticAnalyser |
|
|
|
|
registry={state.registry} |
|
|
|
|
analysisModule={state} |
|
|
|
|
event={state.event} |
|
|
|
|
/> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
renderComponent () { |
|
|
|
|
ReactDOM.render( |
|
|
|
|
<RemixUiStaticAnalyser |
|
|
|
|
registry={this.registry} |
|
|
|
|
analysisModule={this} |
|
|
|
|
event={this.event} |
|
|
|
|
/>, |
|
|
|
|
this.element, |
|
|
|
|
() => { |
|
|
|
|
this.event.register('staticAnaysisWarning', (count) => { |
|
|
|
|
if (count > 0) { |
|
|
|
|
this.emit('statusChanged', { key: count, title: `${count} warning${count === 1 ? '' : 's'}`, type: 'warning' }) |
|
|
|
|
} else if (count === 0) { |
|
|
|
|
this.emit('statusChanged', { key: 'succeed', title: 'no warning', type: 'success' }) |
|
|
|
|
} else { |
|
|
|
|
// count ==-1 no compilation result
|
|
|
|
|
this.emit('statusChanged', { key: 'none' }) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
this.dispatch({ |
|
|
|
|
registry: this.registry, |
|
|
|
|
analysisModule: this, |
|
|
|
|
event: this.event |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|