diff --git a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx index 5d008958ec..279ae0aacc 100644 --- a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx +++ b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx @@ -1,71 +1,97 @@ -import { CustomTooltip } from '@remix-ui/helper'; -import React from 'react' //eslint-disable-line +import { CustomTooltip } from "@remix-ui/helper"; +import React from "react"; //eslint-disable-line +import { RemixUiStaticAnalyserState } from "../staticanalyser"; interface ErrorRendererProps { message: any; - opt: any, - warningErrors: any - editor: any, - name: string, + opt: any; + warningErrors: any; + editor: any; + name: string; + ssaState: RemixUiStaticAnalyserState } -const ErrorRenderer = ({ message, opt, editor, name }: ErrorRendererProps) => { +const ErrorRenderer = ({ message, opt, editor, name, ssaState }: ErrorRendererProps) => { const getPositionDetails = (msg: any) => { - const result = { } as Record + const result = {} as Record; // To handle some compiler warning without location like SPDX license warning etc - if (!msg.includes(':')) return { errLine: -1, errCol: -1, errFile: msg } + if (!msg.includes(":")) return { errLine: -1, errCol: -1, errFile: msg }; // extract line / column - let position = msg.match(/^(.*?):([0-9]*?):([0-9]*?)?/) - result.errLine = position ? parseInt(position[2]) - 1 : -1 - result.errCol = position ? parseInt(position[3]) : -1 + let position = msg.match(/^(.*?):([0-9]*?):([0-9]*?)?/); + result.errLine = position ? parseInt(position[2]) - 1 : -1; + result.errCol = position ? parseInt(position[3]) : -1; // extract file - position = msg.match(/^(https:.*?|http:.*?|.*?):/) - result.errFile = position ? position[1] : '' - return result - } + position = msg.match(/^(https:.*?|http:.*?|.*?):/); + result.errFile = position ? position[1] : ""; + return result; + }; const handlePointToErrorOnClick = async (location, fileName) => { - await editor.call('editor', 'discardHighlight') - await editor.call('editor', 'highlight', location, fileName, '', { focus: true }) - } + await editor.call("editor", "discardHighlight"); + await editor.call("editor", "highlight", location, fileName, "", { + focus: true, + }); + }; - if (!message) return - let position = getPositionDetails(message) - if (!position.errFile || (opt.errorType && opt.errorType === position.errFile)) { + if (!message) return; + let position = getPositionDetails(message); + if ( + !position.errFile || + (opt.errorType && opt.errorType === position.errFile) + ) { // Updated error reported includes '-->' before file details - const errorDetails = message.split('-->') + const errorDetails = message.split("-->"); // errorDetails[1] will have file details - if (errorDetails.length > 1) position = getPositionDetails(errorDetails[1]) + if (errorDetails.length > 1) position = getPositionDetails(errorDetails[1]); } - opt.errLine = position.errLine - opt.errCol = position.errCol - opt.errFile = position.errFile.trim() - const classList = opt.type === 'error' ? 'alert alert-danger' : 'alert alert-warning' + opt.errLine = position.errLine; + opt.errCol = position.errCol; + opt.errFile = position.errFile.trim(); + const classList = + opt.type === "error" ? "alert alert-danger" : "alert alert-warning"; return (
- await handlePointToErrorOnClick(opt.location, opt.fileName)} style={{ cursor: "pointer", overflow: 'hidden', textOverflow: 'ellipsis' }}> - {opt.name} - { opt.item.warning } - {opt.item.more - ? more - : +
+ await handlePointToErrorOnClick(opt.location, opt.fileName) } - - Pos: {opt.locationString} - - + style={{ + cursor: "pointer", + overflow: "hidden", + textOverflow: "ellipsis", + }} + > + {opt.name} + {opt.item.warning} + {opt.item.more ? ( + + + more + + + ) : ( + + )} +
+ + Pos: {opt.locationString} + +
+
- ) -} + ); +}; -export default ErrorRenderer +export default ErrorRenderer; diff --git a/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts index 1ace7d5ff3..f82f6452b6 100644 --- a/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts +++ b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts @@ -103,11 +103,11 @@ slitherEnabled: boolean, setStartAnalysis: React.Dispatch { {hint.formattedMessage}
- {`${hint.column}:${hint.line}`} + + {`Pos: ${hint.column}:${hint.line}`} + )) @@ -751,6 +759,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { message={x.msg} opt={x.options} warningErrors={""} + ssaState={state} editor={props.analysisModule} /> @@ -767,6 +776,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { message={x.msg} opt={x.options} warningErrors={""} + ssaState={state} editor={props.analysisModule} /> @@ -838,6 +848,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { name={`staticAnalysisModule${warning.warningModuleName}${index}`} message={warning.msg} opt={warning.options} + ssaState={state} warningErrors={""} editor={props.analysisModule} /> @@ -854,6 +865,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { message={warning.msg} opt={warning.options} warningErrors={""} + ssaState={state} editor={props.analysisModule} /> @@ -870,6 +882,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { name={`staticAnalysisModule${warning.warningModuleName}${index}`} message={warning.msg} opt={warning.options} + ssaState={state} warningErrors={""} editor={props.analysisModule} />