From 0635374eb836f7994bf759fa4473f750c7b5a63b Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Mon, 14 Feb 2022 17:50:45 +0100 Subject: SONAR-16007 Display secondary locations within hotspot code snippet --- .../SourceViewer/components/LineCode.tsx | 21 ++-- .../components/__tests__/LineCode-test.tsx | 7 ++ .../__tests__/__snapshots__/LineCode-test.tsx.snap | 136 +++++++++++++++++++++ 3 files changed, 155 insertions(+), 9 deletions(-) (limited to 'server/sonar-web/src/main/js/components/SourceViewer') diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx index 8904fc41747..8a65af22ba2 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx @@ -22,7 +22,7 @@ import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; import { Issue, LinearIssueLocation, SourceLine } from '../../../types/types'; import LocationIndex from '../../common/LocationIndex'; -import LocationMessage from '../../common/LocationMessage'; +import Tooltip from '../../controls/Tooltip'; import { highlightIssueLocations, highlightSymbol, @@ -141,15 +141,18 @@ export default class LineCode extends React.PureComponent { const { onLocationSelect } = this.props; const onClick = onLocationSelect ? () => onLocationSelect(index) : undefined; const ref = selected ? (node: HTMLElement | null) => (this.activeMarkerNode = node) : undefined; + return ( - - {index + 1} - {message && {message}} - + + + {index + 1} + + ); } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx index ebe3cc56430..92ee72265e2 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx @@ -28,6 +28,13 @@ it('render code', () => { expect(shallowRender({ additionalChild:
additional child
})).toMatchSnapshot( 'with additional child' ); + expect( + shallowRender({ + secondaryIssueLocations: [ + { index: 1, from: 5, to: 6, line: 16, startLine: 16, text: 'secondary-location-msg' } + ] + }) + ).toMatchSnapshot('with secondary location'); }); function shallowRender(props: Partial = {}) { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineCode-test.tsx.snap b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineCode-test.tsx.snap index 77bebd4c983..37718ed25a8 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineCode-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineCode-test.tsx.snap @@ -242,3 +242,139 @@ exports[`render code: with additional child 1`] = ` `; + +exports[`render code: with secondary location 1`] = ` + +
+
+      
+        impor
+      
+      
+        
+          
+            2
+          
+        
+      
+      
+        t
+      
+      
+         java.util.
+      
+      
+        ArrayList
+      
+      
+        ;
+      
+    
+
+ + +`; -- cgit v1.2.3