From 2b39ec1760c38c14655659afcb4ee8285b4864db Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 1 Jul 2021 00:09:51 +0100 Subject: [PATCH] Fixed solidity import test --- libs/remix-ui/renderer/src/lib/renderer.tsx | 37 +++++++++++++++---- .../src/lib/solidity-compiler.tsx | 6 +-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index 62426e6235..4f0795875c 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -4,14 +4,17 @@ interface RendererProps { message: any; opt?: any, plugin: any, - config: any + editor: any, + config: any, + fileManager: any } -export const Renderer = ({ message, opt = {}, plugin, config }: RendererProps) => { +export const Renderer = ({ message, opt = {}, editor, config, fileManager, plugin }: RendererProps) => { const [messageText, setMessageText] = useState(null) const [editorOptions, setEditorOptions] = useState({ useSpan: false, - type: '' + type: '', + errFile: '' }) const [classList] = useState(opt.type === 'error' ? 'alert alert-danger' : 'alert alert-warning') const [close, setClose] = useState(false) @@ -79,20 +82,40 @@ export const Renderer = ({ message, opt = {}, plugin, config }: RendererProps) = } } - const handlePointToErrorOnClick = (location, fileName) => { - plugin.call('editor', 'discardHighlight') - plugin.call('editor', 'highlight', location, fileName) + const handleErrorClick = (opt) => { + if (opt.click) { + opt.click(message) + } else if (opt.errFile !== undefined && opt.errLine !== undefined && opt.errCol !== undefined) { + _errorClick(opt.errFile, opt.errLine, opt.errCol) + } } const handleClose = () => { setClose(true) } + const _errorClick = (errFile, errLine, errCol) => { + if (errFile !== config.get('currentFile')) { + // TODO: refactor with this._components.contextView.jumpTo + const provider = fileManager.fileProviderOf(errFile) + if (provider) { + provider.exists(errFile).then(() => { + fileManager.open(errFile) + editor.gotoLine(errLine, errCol) + }).catch(error => { + if (error) return console.log(error) + }) + } + } else { + editor.gotoLine(errLine, errCol) + } + } + return ( <> { messageText && !close && ( -
handlePointToErrorOnClick(opt.location, opt.fileName)}> +
handleErrorClick(editorOptions)}> { editorOptions.useSpan ? { messageText } :
{ messageText }
}
diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 8957ddc8ba..3d62ffdf3b 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -86,15 +86,15 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
- { compileErrors.error && } + { compileErrors.error && } { 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 + return } } else { - return + return } }) }