From 8438eb9a1b964b856c82c2250ffae4344f825098 Mon Sep 17 00:00:00 2001 From: Charis Kyriakou Date: Tue, 28 Jun 2022 09:48:34 +0100 Subject: [PATCH 1/2] MRVA: Display alert text even if location is undefined --- .../remote-queries/view/FileCodeSnippet.tsx | 202 ++++++++++-------- 1 file changed, 117 insertions(+), 85 deletions(-) diff --git a/extensions/ql-vscode/src/remote-queries/view/FileCodeSnippet.tsx b/extensions/ql-vscode/src/remote-queries/view/FileCodeSnippet.tsx index 23978acd3c7..bb02b979d41 100644 --- a/extensions/ql-vscode/src/remote-queries/view/FileCodeSnippet.tsx +++ b/extensions/ql-vscode/src/remote-queries/view/FileCodeSnippet.tsx @@ -55,71 +55,61 @@ const MessageContainer = styled.div` padding-bottom: 0.5em; `; -const PlainLine = ({ text }: { text: string }) => { +const PlainCode = ({ text }: { text: string }) => { return {replaceSpaceAndTabChar(text)}; }; -const HighlightedLine = ({ text }: { text: string }) => { +const HighlightedCode = ({ text }: { text: string }) => { return {replaceSpaceAndTabChar(text)}; }; const Message = ({ message, - currentLineNumber, - highlightedRegion, borderLeftColor, children }: { message: AnalysisMessage, - currentLineNumber: number, - highlightedRegion?: HighlightedRegion, borderLeftColor: string, children: React.ReactNode }) => { - if (!highlightedRegion || highlightedRegion.endLine !== currentLineNumber) { - return <>; - } - - return -
- - {message.tokens.map((token, index) => { - switch (token.t) { - case 'text': - return {token.text}; - case 'location': - return - {token.text} - ; - default: - return <>; - } - })} - {children && <> - - {children} - + return
+ + {message.tokens.map((token, index) => { + switch (token.t) { + case 'text': + return {token.text}; + case 'location': + return + {token.text} + ; + default: + return <>; } - -
- ; + })} + {children && <> + + {children} + + } +
+
; }; -const CodeLine = ({ +const Code = ({ line, lineNumber, highlightedRegion @@ -129,20 +119,80 @@ const CodeLine = ({ highlightedRegion?: HighlightedRegion }) => { if (!highlightedRegion || !shouldHighlightLine(lineNumber, highlightedRegion)) { - return ; + return ; } const partiallyHighlightedLine = parseHighlightedLine(line, lineNumber, highlightedRegion); return ( <> - - - + + + ); }; +const Line = ({ + line, + lineIndex, + startingLineIndex, + highlightedRegion, + severity, + message, + messageChildren +}: { + line: string, + lineIndex: number, + startingLineIndex: number, + highlightedRegion?: HighlightedRegion, + severity?: ResultSeverity, + message?: AnalysisMessage, + messageChildren?: React.ReactNode, +}) => { + const showMessage = message && + severity && + highlightedRegion && + highlightedRegion.endLine == startingLineIndex + lineIndex; + + return
+
+
+ {startingLineIndex + lineIndex} +
+
+ +
+
+ {showMessage && + + + {messageChildren} + + + } +
; +}; + const FileCodeSnippet = ({ fileLink, codeSnippet, @@ -173,6 +223,12 @@ const FileCodeSnippet = ({ {fileLink.filePath} + {message && severity && + + {messageChildren} + } ); } @@ -186,40 +242,16 @@ const FileCodeSnippet = ({ {code.map((line, index) => ( -
-
-
- {startingLine + index} -
-
- -
-
- {message && severity && - {messageChildren} - } -
+ ))}
From b8737d21b0a2e0a49a2e5c8f2334530a71904a85 Mon Sep 17 00:00:00 2001 From: Charis Kyriakou Date: Tue, 28 Jun 2022 13:14:27 +0100 Subject: [PATCH 2/2] Update boolean flag name --- .../ql-vscode/src/remote-queries/view/FileCodeSnippet.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ql-vscode/src/remote-queries/view/FileCodeSnippet.tsx b/extensions/ql-vscode/src/remote-queries/view/FileCodeSnippet.tsx index bb02b979d41..33e049c9048 100644 --- a/extensions/ql-vscode/src/remote-queries/view/FileCodeSnippet.tsx +++ b/extensions/ql-vscode/src/remote-queries/view/FileCodeSnippet.tsx @@ -150,7 +150,7 @@ const Line = ({ message?: AnalysisMessage, messageChildren?: React.ReactNode, }) => { - const showMessage = message && + const shouldShowMessage = message && severity && highlightedRegion && highlightedRegion.endLine == startingLineIndex + lineIndex; @@ -181,7 +181,7 @@ const Line = ({ highlightedRegion={highlightedRegion} /> - {showMessage && + {shouldShowMessage &&