remove editor dependency from solidity compiler

pull/5370/head
yann300 4 years ago
parent 330b131fed
commit 8a66934a94
  1. 2
      apps/remix-ide/src/app/editor/editor.js
  2. 1
      apps/remix-ide/src/app/tabs/compile-tab.js
  3. 7
      libs/remix-ui/renderer/src/lib/renderer.tsx
  4. 6
      libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts
  5. 4
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  6. 2
      libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts
  7. 10
      libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx
  8. 2
      libs/remix-ui/solidity-compiler/src/lib/types/index.ts

@ -49,7 +49,7 @@ const profile = {
name: 'editor',
description: 'service - editor',
version: packageJson.version,
methods: ['highlight', 'discardHighlight', 'discardHighlightAt', 'clearAnnotations', 'addAnnotation']
methods: ['highlight', 'discardHighlight', 'discardHighlightAt', 'clearAnnotations', 'addAnnotation', 'gotoLine']
}
class Editor extends Plugin {

@ -55,7 +55,6 @@ class CompileTab extends ViewPlugin {
this.compileTabLogic = new CompileTabLogic(
this.queryParams,
this.fileManager,
this.editor,
this.config,
this.fileProvider,
this.contentImport,

@ -4,12 +4,11 @@ interface RendererProps {
message: any;
opt?: any,
plugin: any,
editor: any,
config: any,
fileManager: any
}
export const Renderer = ({ message, opt = {}, editor, config, fileManager, plugin }: RendererProps) => {
export const Renderer = ({ message, opt = {}, config, fileManager, plugin }: RendererProps) => {
const [messageText, setMessageText] = useState(null)
const [editorOptions, setEditorOptions] = useState({
useSpan: false,
@ -101,13 +100,13 @@ export const Renderer = ({ message, opt = {}, editor, config, fileManager, plugi
if (provider) {
provider.exists(errFile).then(() => {
fileManager.open(errFile)
editor.gotoLine(errLine, errCol)
plugin.call('editor', 'gotoLine', errLine, errCol)
}).catch(error => {
if (error) return console.log(error)
})
}
} else {
editor.gotoLine(errLine, errCol)
plugin.call('editor', 'gotoLine', errLine, errCol)
}
}

@ -26,8 +26,8 @@ export const resetCompilerMode = () => (dispatch: React.Dispatch<any>) => {
})
}
export const listenToEvents = (editor, compileTabLogic) => (dispatch: React.Dispatch<any>) => {
editor.event.register('sessionSwitched', () => {
export const listenToEvents = (compileTabLogic) => (dispatch: React.Dispatch<any>) => {
compileTabLogic.on('editor', 'sessionSwitched', () => {
dispatch(setEditorMode('sessionSwitched'))
})
@ -39,7 +39,7 @@ export const listenToEvents = (editor, compileTabLogic) => (dispatch: React.Disp
dispatch(setCompilerMode('compilationDuration', speed))
})
editor.event.register('contentChanged', () => {
compileTabLogic.on('editor', 'contentChanged', () => {
dispatch(setEditorMode('contentChanged'))
})

@ -18,7 +18,7 @@ declare global {
const _paq = window._paq = window._paq || [] //eslint-disable-line
export const CompilerContainer = (props: CompilerContainerProps) => {
const { editor, config, queryParams, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line
const { config, queryParams, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line
const [state, setState] = useState({
hideWarnings: false,
autoCompile: false,
@ -59,7 +59,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const currentFileName = config.get('currentFile')
currentFile(currentFileName)
listenToEvents(editor, compileTabLogic)(dispatch)
listenToEvents(compileTabLogic)(dispatch)
}, [])
useEffect(() => {

@ -18,7 +18,7 @@ export class CompileTab extends Plugin {
public compilerImport
public event
constructor (public queryParams, public fileManager, public editor, public config, public fileProvider, public contentImport) {
constructor (public queryParams, public fileManager, public config, public fileProvider, public contentImport) {
super(profile)
this.event = new EventEmitter()
this.compiler = new Compiler((url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message)))

@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line
import './css/style.css'
export const SolidityCompiler = (props: SolidityCompilerProps) => {
const { plugin, plugin: { editor, config, queryParams, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props
const { plugin, plugin: { config, queryParams, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props
const [state, setState] = useState({
contractsDetails: {},
eventHandlers: {},
@ -78,19 +78,19 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
return (
<>
<div id="compileTabView">
<CompilerContainer editor={editor} config={config} queryParams={queryParams} compileTabLogic={compileTabLogic} tooltip={toast} modal={modal} compiledFileName={currentFile} setHardHatCompilation={setHardHatCompilation.bind(plugin)} updateCurrentVersion={updateCurrentVersion} isHardHatProject={isHardHatProject} configurationSettings={configurationSettings} />
<CompilerContainer config={config} queryParams={queryParams} compileTabLogic={compileTabLogic} tooltip={toast} modal={modal} compiledFileName={currentFile} setHardHatCompilation={setHardHatCompilation.bind(plugin)} updateCurrentVersion={updateCurrentVersion} isHardHatProject={isHardHatProject} configurationSettings={configurationSettings} />
<ContractSelection contractMap={contractMap} fileProvider={fileProvider} fileManager={fileManager} contractsDetails={contractsDetails} modal={modal} />
<div className="remixui_errorBlobs p-4" data-id="compiledErrors">
<span data-id={`compilationFinishedWith_${currentVersion}`}></span>
{ compileErrors.error && <Renderer message={compileErrors.error.formattedMessage || compileErrors.error} plugin={plugin} opt={{ type: compileErrors.error.severity || 'error', errorType: compileErrors.error.type }} config={config} editor={editor} fileManager={fileManager} /> }
{ compileErrors.error && <Renderer message={compileErrors.error.formattedMessage || compileErrors.error} plugin={plugin} opt={{ type: compileErrors.error.severity || 'error', errorType: compileErrors.error.type }} config={config} fileManager={fileManager} /> }
{ compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) }
{ compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => {
if (config.get('hideWarnings')) {
if (err.severity !== 'warning') {
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} editor={editor} fileManager={fileManager} />
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} fileManager={fileManager} />
}
} else {
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} editor={editor} fileManager={fileManager} />
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} fileManager={fileManager} />
}
}) }
</div>

@ -9,7 +9,6 @@ export interface SolidityCompilerProps {
compileTabLogic: any,
currentFile: string,
contractsDetails: Record<string, any>,
editor: any,
config: any,
fileProvider: any,
fileManager: any,
@ -23,7 +22,6 @@ export interface SolidityCompilerProps {
}
export interface CompilerContainerProps {
editor: any,
config: any,
queryParams: any,
compileTabLogic: any,

Loading…
Cancel
Save